int main() {
  if (foo(0) != 1 || foo(1) != 0 || foo(0x800) != 1 || foo(0x801) != 0 ||
      foo((__int128)1 << 63) != 0 || foo((__int128)-1 << 63) != 1 ||
      foo(((__int128)-1 << 63) | 1) != 0 ||
      foo(((__int128)-1 << 63) | 0x800) != 1 ||
      foo(((__int128)-1 << 63) | 0x801) != 0)
    __builtin_abort();
  if (bar(0) != 1 || bar(1) != 0 || bar(0x800) != 1 || bar(0x801) != 0 ||
      bar(1LL << 31) != 0 || bar(-1LL << 31) != 1 ||
      bar((-1LL << 31) | 1) != 0 || bar((-1LL << 31) | 0x800) != 1 ||
      bar((-1LL << 31) | 0x801) != 0)
    __builtin_abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
mov    $0x0,%al
call   1050 <foo@plt>
cmp    $0x1,%eax
jne    1276 <main+0x146>
mov    $0x1,%edi
mov    $0x0,%al
call   1050 <foo@plt>
cmp    $0x0,%eax
jne    1276 <main+0x146>
mov    $0x800,%edi
mov    $0x0,%al
call   1050 <foo@plt>
cmp    $0x1,%eax
jne    1276 <main+0x146>
mov    $0x801,%edi
mov    $0x0,%al
call   1050 <foo@plt>
cmp    $0x0,%eax
jne    1276 <main+0x146>
movabs $0x8000000000000000,%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <foo@plt>
cmp    $0x0,%eax
jne    1276 <main+0x146>
movabs $0x8000000000000000,%rax
mov    %rax,-0x30(%rbp)
movq   $0xffffffffffffffff,-0x28(%rbp)
ff
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x0,%al
call   1050 <foo@plt>
cmp    $0x1,%eax
jne    1276 <main+0x146>
movabs $0x8000000000000001,%rax
mov    %rax,-0x40(%rbp)
movq   $0xffffffffffffffff,-0x38(%rbp)
ff
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    $0x0,%al
call   1050 <foo@plt>
cmp    $0x0,%eax
jne    1276 <main+0x146>
movabs $0x8000000000000800,%rax
mov    %rax,-0x50(%rbp)
movq   $0xffffffffffffffff,-0x48(%rbp)
ff
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    $0x0,%al
call   1050 <foo@plt>
cmp    $0x1,%eax
jne    1276 <main+0x146>
movabs $0x8000000000000801,%rax
mov    %rax,-0x60(%rbp)
movq   $0xffffffffffffffff,-0x58(%rbp)
ff
mov    -0x60(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    $0x0,%al
call   1050 <foo@plt>
cmp    $0x0,%eax
je     127b <main+0x14b>
call   1030 <abort@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1040 <bar@plt>
cmp    $0x1,%eax
jne    133d <main+0x20d>
mov    $0x1,%edi
mov    $0x0,%al
call   1040 <bar@plt>
cmp    $0x0,%eax
jne    133d <main+0x20d>
mov    $0x800,%edi
mov    $0x0,%al
call   1040 <bar@plt>
cmp    $0x1,%eax
jne    133d <main+0x20d>
mov    $0x801,%edi
mov    $0x0,%al
call   1040 <bar@plt>
cmp    $0x0,%eax
jne    133d <main+0x20d>
mov    $0x80000000,%edi
mov    $0x0,%al
call   1040 <bar@plt>
cmp    $0x0,%eax
jne    133d <main+0x20d>
mov    $0xffffffff80000000,%rdi
mov    $0x0,%al
call   1040 <bar@plt>
cmp    $0x1,%eax
jne    133d <main+0x20d>
mov    $0xffffffff80000001,%rdi
mov    $0x0,%al
call   1040 <bar@plt>
cmp    $0x0,%eax
jne    133d <main+0x20d>
mov    $0xffffffff80000800,%rdi
mov    $0x0,%al
call   1040 <bar@plt>
cmp    $0x1,%eax
jne    133d <main+0x20d>
mov    $0xffffffff80000801,%rdi
mov    $0x0,%al
call   1040 <bar@plt>
cmp    $0x0,%eax
je     1342 <main+0x212>
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
xor    %eax,%eax
call   1050 <foo@plt>
cmp    $0x1,%eax
jne    12b1 <main+0x181>
mov    $0x1,%edi
xor    %eax,%eax
call   1050 <foo@plt>
test   %eax,%eax
jne    12b1 <main+0x181>
mov    $0x800,%edi
xor    %eax,%eax
call   1050 <foo@plt>
cmp    $0x1,%eax
jne    12b1 <main+0x181>
mov    $0x801,%edi
xor    %eax,%eax
call   1050 <foo@plt>
test   %eax,%eax
jne    12b1 <main+0x181>
movabs $0x8000000000000000,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <foo@plt>
test   %eax,%eax
jne    12b1 <main+0x181>
mov    %rbx,%rdi
mov    $0xffffffffffffffff,%rsi
xor    %eax,%eax
call   1050 <foo@plt>
cmp    $0x1,%eax
jne    12b1 <main+0x181>
lea    0x1(%rbx),%rdi
mov    $0xffffffffffffffff,%rsi
xor    %eax,%eax
call   1050 <foo@plt>
test   %eax,%eax
jne    12b1 <main+0x181>
lea    0x800(%rbx),%rdi
mov    $0xffffffffffffffff,%rsi
xor    %eax,%eax
call   1050 <foo@plt>
cmp    $0x1,%eax
jne    12b1 <main+0x181>
add    $0x801,%rbx
mov    %rbx,%rdi
mov    $0xffffffffffffffff,%rsi
xor    %eax,%eax
call   1050 <foo@plt>
test   %eax,%eax
jne    12b1 <main+0x181>
xor    %edi,%edi
xor    %eax,%eax
call   1040 <bar@plt>
cmp    $0x1,%eax
jne    12b1 <main+0x181>
mov    $0x1,%edi
xor    %eax,%eax
call   1040 <bar@plt>
test   %eax,%eax
jne    12b1 <main+0x181>
mov    $0x800,%edi
xor    %eax,%eax
call   1040 <bar@plt>
cmp    $0x1,%eax
jne    12b1 <main+0x181>
mov    $0x801,%edi
xor    %eax,%eax
call   1040 <bar@plt>
test   %eax,%eax
jne    12b1 <main+0x181>
mov    $0x80000000,%edi
xor    %eax,%eax
call   1040 <bar@plt>
test   %eax,%eax
jne    12b1 <main+0x181>
mov    $0xffffffff80000000,%rdi
xor    %eax,%eax
call   1040 <bar@plt>
cmp    $0x1,%eax
jne    12b1 <main+0x181>
mov    $0xffffffff80000001,%rdi
xor    %eax,%eax
call   1040 <bar@plt>
test   %eax,%eax
jne    12b1 <main+0x181>
mov    $0xffffffff80000800,%rdi
xor    %eax,%eax
call   1040 <bar@plt>
cmp    $0x1,%eax
jne    12b1 <main+0x181>
mov    $0xffffffff80000801,%rdi
xor    %eax,%eax
call   1040 <bar@plt>
test   %eax,%eax
jne    12b1 <main+0x181>
xor    %eax,%eax
pop    %rbx
ret
call   1030 <abort@plt>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i128
%3 = alloca i128
%4 = alloca i128
%5 = alloca i128
%6 = alloca i128
store i32 0, i32* %1
%7 = call i32 (i32, ...) bitcast (i32 (...)* @foo to i32 (i32, ...)*)(i32 0)
%8 = icmp ne i32 %7, 1
br i1 %8, label %58, label %9
9: ; preds = %0
%10 = call i32 (i32, ...) bitcast (i32 (...)* @foo to i32 (i32, ...)*)(i32 1)
%11 = icmp ne i32 %10, 0
br i1 %11, label %58, label %12
12: ; preds = %9
%13 = call i32 (i32, ...) bitcast (i32 (...)* @foo to i32 (i32, ...)*)(i32 2048)
%14 = icmp ne i32 %13, 1
br i1 %14, label %58, label %15
15: ; preds = %12
%16 = call i32 (i32, ...) bitcast (i32 (...)* @foo to i32 (i32, ...)*)(i32 2049)
%17 = icmp ne i32 %16, 0
br i1 %17, label %58, label %18
18: ; preds = %15
store i128 9223372036854775808, i128* %2
%19 = bitcast i128* %2 to { i64, i64 }*
%20 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %19, i32 0, i32 0
%21 = load i64, i64* %20
%22 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %19, i32 0, i32 1
%23 = load i64, i64* %22
%24 = call i32 (i64, i64, ...) bitcast (i32 (...)* @foo to i32 (i64, i64, ...)*)(i64 %21, i64 %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %58, label %26
26: ; preds = %18
store i128 -9223372036854775808, i128* %3
%27 = bitcast i128* %3 to { i64, i64 }*
%28 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %27, i32 0, i32 0
%29 = load i64, i64* %28
%30 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %27, i32 0, i32 1
%31 = load i64, i64* %30
%32 = call i32 (i64, i64, ...) bitcast (i32 (...)* @foo to i32 (i64, i64, ...)*)(i64 %29, i64 %31)
%33 = icmp ne i32 %32, 1
br i1 %33, label %58, label %34
34: ; preds = %26
store i128 -9223372036854775807, i128* %4
%35 = bitcast i128* %4 to { i64, i64 }*
%36 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %35, i32 0, i32 0
%37 = load i64, i64* %36
%38 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %35, i32 0, i32 1
%39 = load i64, i64* %38
%40 = call i32 (i64, i64, ...) bitcast (i32 (...)* @foo to i32 (i64, i64, ...)*)(i64 %37, i64 %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %58, label %42
42: ; preds = %34
store i128 -9223372036854773760, i128* %5
%43 = bitcast i128* %5 to { i64, i64 }*
%44 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %43, i32 0, i32 0
%45 = load i64, i64* %44
%46 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %43, i32 0, i32 1
%47 = load i64, i64* %46
%48 = call i32 (i64, i64, ...) bitcast (i32 (...)* @foo to i32 (i64, i64, ...)*)(i64 %45, i64 %47)
%49 = icmp ne i32 %48, 1
br i1 %49, label %58, label %50
50: ; preds = %42
store i128 -9223372036854773759, i128* %6
%51 = bitcast i128* %6 to { i64, i64 }*
%52 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %51, i32 0, i32 0
%53 = load i64, i64* %52
%54 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %51, i32 0, i32 1
%55 = load i64, i64* %54
%56 = call i32 (i64, i64, ...) bitcast (i32 (...)* @foo to i32 (i64, i64, ...)*)(i64 %53, i64 %55)
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %50, %42, %34, %26, %18, %15, %12, %9, %0
unreachable
59: ; preds = %50
%60 = call i32 (i32, ...) bitcast (i32 (...)* @bar to i32 (i32, ...)*)(i32 0)
%61 = icmp ne i32 %60, 1
br i1 %61, label %86, label %62
62: ; preds = %59
%63 = call i32 (i32, ...) bitcast (i32 (...)* @bar to i32 (i32, ...)*)(i32 1)
%64 = icmp ne i32 %63, 0
br i1 %64, label %86, label %65
65: ; preds = %62
%66 = call i32 (i32, ...) bitcast (i32 (...)* @bar to i32 (i32, ...)*)(i32 2048)
%67 = icmp ne i32 %66, 1
br i1 %67, label %86, label %68
68: ; preds = %65
%69 = call i32 (i32, ...) bitcast (i32 (...)* @bar to i32 (i32, ...)*)(i32 2049)
%70 = icmp ne i32 %69, 0
br i1 %70, label %86, label %71
71: ; preds = %68
%72 = call i32 (i64, ...) bitcast (i32 (...)* @bar to i32 (i64, ...)*)(i64 2147483648)
%73 = icmp ne i32 %72, 0
br i1 %73, label %86, label %74
74: ; preds = %71
%75 = call i32 (i64, ...) bitcast (i32 (...)* @bar to i32 (i64, ...)*)(i64 -2147483648)
%76 = icmp ne i32 %75, 1
br i1 %76, label %86, label %77
77: ; preds = %74
%78 = call i32 (i64, ...) bitcast (i32 (...)* @bar to i32 (i64, ...)*)(i64 -2147483647)
%79 = icmp ne i32 %78, 0
br i1 %79, label %86, label %80
80: ; preds = %77
%81 = call i32 (i64, ...) bitcast (i32 (...)* @bar to i32 (i64, ...)*)(i64 -2147481600)
%82 = icmp ne i32 %81, 1
br i1 %82, label %86, label %83
83: ; preds = %80
%84 = call i32 (i64, ...) bitcast (i32 (...)* @bar to i32 (i64, ...)*)(i64 -2147481599)
%85 = icmp ne i32 %84, 0
br i1 %85, label %86, label %87
86: ; preds = %83, %80, %77, %74, %71, %68, %65, %62, %59
unreachable
87: ; preds = %83
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (i32, ...) bitcast (i32 (...)* @foo to i32 (i32, ...)*)(i32 0)
%2 = icmp eq i32 %1, 1
br i1 %2, label %3, label %27
3: ; preds = %0
%4 = tail call i32 (i32, ...) bitcast (i32 (...)* @foo to i32 (i32, ...)*)(i32 1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %27
6: ; preds = %3
%7 = tail call i32 (i32, ...) bitcast (i32 (...)* @foo to i32 (i32, ...)*)(i32 2048)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = tail call i32 (i32, ...) bitcast (i32 (...)* @foo to i32 (i32, ...)*)(i32 2049)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %9
%13 = tail call i32 (i64, i64, ...) bitcast (i32 (...)* @foo to i32 (i64, i64, ...)*)(i64 -9223372036854775808, i64 0)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %27
15: ; preds = %12
%16 = tail call i32 (i64, i64, ...) bitcast (i32 (...)* @foo to i32 (i64, i64, ...)*)(i64 -9223372036854775808, i64 -1)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %27
18: ; preds = %15
%19 = tail call i32 (i64, i64, ...) bitcast (i32 (...)* @foo to i32 (i64, i64, ...)*)(i64 -9223372036854775807, i64 -1)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %18
%22 = tail call i32 (i64, i64, ...) bitcast (i32 (...)* @foo to i32 (i64, i64, ...)*)(i64 -9223372036854773760, i64 -1)
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = tail call i32 (i64, i64, ...) bitcast (i32 (...)* @foo to i32 (i64, i64, ...)*)(i64 -9223372036854773759, i64 -1)
%26 = icmp eq i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %24, %21, %18, %15, %12, %9, %6, %3, %0
tail call void @abort()
unreachable
28: ; preds = %24
%29 = tail call i32 (i32, ...) bitcast (i32 (...)* @bar to i32 (i32, ...)*)(i32 0)
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %55
31: ; preds = %28
%32 = tail call i32 (i32, ...) bitcast (i32 (...)* @bar to i32 (i32, ...)*)(i32 1)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %55
34: ; preds = %31
%35 = tail call i32 (i32, ...) bitcast (i32 (...)* @bar to i32 (i32, ...)*)(i32 2048)
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %55
37: ; preds = %34
%38 = tail call i32 (i32, ...) bitcast (i32 (...)* @bar to i32 (i32, ...)*)(i32 2049)
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %55
40: ; preds = %37
%41 = tail call i32 (i64, ...) bitcast (i32 (...)* @bar to i32 (i64, ...)*)(i64 2147483648)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %55
43: ; preds = %40
%44 = tail call i32 (i64, ...) bitcast (i32 (...)* @bar to i32 (i64, ...)*)(i64 -2147483648)
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %55
46: ; preds = %43
%47 = tail call i32 (i64, ...) bitcast (i32 (...)* @bar to i32 (i64, ...)*)(i64 -2147483647)
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %55
49: ; preds = %46
%50 = tail call i32 (i64, ...) bitcast (i32 (...)* @bar to i32 (i64, ...)*)(i64 -2147481600)
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = tail call i32 (i64, ...) bitcast (i32 (...)* @bar to i32 (i64, ...)*)(i64 -2147481599)
%54 = icmp eq i32 %53, 0
br i1 %54, label %56, label %55
55: ; preds = %52, %49, %46, %43, %40, %37, %34, %31, %28
tail call void @abort()
unreachable
56: ; preds = %52
ret i32 0
}