(module main)

(fn i32_and () -> i32
  (bit_and 6 3))

(fn i32_or () -> i32
  (bit_or 4 2))

(fn i32_xor () -> i32
  (bit_xor 7 3))

(fn i64_and () -> i64
  (bit_and 6i64 3i64))

(fn i64_or () -> i64
  (bit_or 4i64 2i64))

(fn i64_xor () -> i64
  (bit_xor 7i64 3i64))

(fn bitwise_ok () -> bool
  (if (= (i32_and) 2)
    (if (= (i32_or) 6)
      (if (= (i32_xor) 4)
        (if (= (i64_and) 2i64)
          (if (= (i64_or) 6i64)
            (= (i64_xor) 4i64)
            false)
          false)
        false)
      false)
    false))

(fn main () -> i32
  (if (bitwise_ok)
    42
    1))

(test "i32 bit and"
  (= (i32_and) 2))

(test "i32 bit or"
  (= (i32_or) 6))

(test "i32 bit xor"
  (= (i32_xor) 4))

(test "i64 bit and"
  (= (i64_and) 2i64))

(test "i64 bit or"
  (= (i64_or) 6i64))

(test "i64 bit xor"
  (= (i64_xor) 4i64))

(test "integer bitwise summary"
  (bitwise_ok))
