#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void bool_test() {
  int *s, a, b, t, f, i;
  a = 0;
  s = (void *)0;
  printf("!s=%d\n", !s);
  if (!s || !s[0])
    a = 1;
  printf("a=%d\n", a);
  printf("a=%d %d %d\n", 0 || 0, 0 || 1, 1 || 1);
  printf("a=%d %d %d\n", 0 && 0, 0 && 1, 1 && 1);
  printf("a=%d %d\n", 1 ? 1 : 0, 0 ? 1 : 0);
  printf("a1\n");
  printf("a2\n");
  printf("a4\n");
  a = 4;
  printf("b=%d\n", a + (0 ? 1 : a / 2));
  a = 10;
  b = 10;
  a = (a + b) * ((a < b) ? ((b - a) * (a - b)) : a + b);
  printf("a=%d\n", a);
  t = 1;
  f = 0;
  a = 32;
  printf("exp=%d\n", f == (32 <= a && a <= 3));
  printf("r=%d\n", (t || f) + (t && f));
}


x86 assembly (clang, -O0):
<bool_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0xc(%rbp)
movq   $0x0,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%esi
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x8(%rbp)
je     115c <bool_test+0x4c>
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1163 <bool_test+0x53>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe92(%rip),%rdi
xor    %esi,%esi
mov    $0x1,%ecx
mov    %ecx,%edx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7b(%rip),%rdi
xor    %edx,%edx
mov    $0x1,%ecx
mov    %edx,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe70(%rip),%rdi
mov    $0x1,%esi
xor    %edx,%edx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x4,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    %eax,%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xa,-0xc(%rbp)
movl   $0xa,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1240 <bool_test+0x130>
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x10(%rbp),%ecx
imul   %ecx,%eax
mov    %eax,-0x24(%rbp)
jmp    1249 <bool_test+0x139>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x24(%rbp),%ecx
imul   %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x20,-0xc(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
mov    $0x20,%ecx
cmp    -0xc(%rbp),%ecx
mov    %al,-0x25(%rbp)
jg     129e <bool_test+0x18e>
cmpl   $0x3,-0xc(%rbp)
setle  %al
mov    %al,-0x25(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x25(%rbp),%cl
and    $0x1,%cl
movzbl %cl,%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xd79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x2d(%rbp)
jne    12db <bool_test+0x1cb>
cmpl   $0x0,-0x18(%rbp)
setne  %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x34(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x2e(%rbp)
je     12ff <bool_test+0x1ef>
cmpl   $0x0,-0x18(%rbp)
setne  %al
mov    %al,-0x2e(%rbp)
mov    -0x34(%rbp),%esi
mov    -0x2e(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    %eax,%esi
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bool_test>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec9(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb9(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x1,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe95(%rip),%rdi
mov    $0x1,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe65(%rip),%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x190,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe49(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3e(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"!s=%d\0A\00"
@.str.1 = [6 x i8] c"a=%d\0A\00"
@.str.2 = [12 x i8] c"a=%d %d %d\0A\00"
@.str.3 = [9 x i8] c"a=%d %d\0A\00"
@.str.4 = [4 x i8] c"a1\0A\00"
@.str.5 = [4 x i8] c"a2\0A\00"
@.str.6 = [4 x i8] c"a4\0A\00"
@.str.7 = [6 x i8] c"b=%d\0A\00"
@.str.8 = [8 x i8] c"exp=%d\0A\00"
@.str.9 = [6 x i8] c"r=%d\0A\00"
define void @bool_test() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %2
store i32* null, i32** %1
%7 = load i32*, i32** %1
%8 = icmp ne i32* %7, null
%9 = xor i1 %8, true
%10 = zext i1 %9 to i32
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32*, i32** %1
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %19
14: ; preds = %0
%15 = load i32*, i32** %1
%16 = getelementptr inbounds i32, i32* %15, i64 0
%17 = load i32, i32* %16
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %14, %0
store i32 1, i32* %2
br label %20
20: ; preds = %19, %14
%21 = load i32, i32* %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 1, i32 1)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 0, i32 1)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 0)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
store i32 4, i32* %2
%29 = load i32, i32* %2
%30 = load i32, i32* %2
%31 = sdiv i32 %30, 2
%32 = add nsw i32 %29, %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %32)
store i32 10, i32* %2
store i32 10, i32* %3
%34 = load i32, i32* %2
%35 = load i32, i32* %3
%36 = add nsw i32 %34, %35
%37 = load i32, i32* %2
%38 = load i32, i32* %3
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %48
40: ; preds = %20
%41 = load i32, i32* %3
%42 = load i32, i32* %2
%43 = sub nsw i32 %41, %42
%44 = load i32, i32* %2
%45 = load i32, i32* %3
%46 = sub nsw i32 %44, %45
%47 = mul nsw i32 %43, %46
br label %52
48: ; preds = %20
%49 = load i32, i32* %2
%50 = load i32, i32* %3
%51 = add nsw i32 %49, %50
br label %52
52: ; preds = %48, %40
%53 = phi i32 [ %47, %40 ], [ %51, %48 ]
%54 = mul nsw i32 %36, %53
store i32 %54, i32* %2
%55 = load i32, i32* %2
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %55)
store i32 1, i32* %4
store i32 0, i32* %5
store i32 32, i32* %2
%57 = load i32, i32* %5
%58 = load i32, i32* %2
%59 = icmp sle i32 32, %58
br i1 %59, label %60, label %63
60: ; preds = %52
%61 = load i32, i32* %2
%62 = icmp sle i32 %61, 3
br label %63
63: ; preds = %60, %52
%64 = phi i1 [ false, %52 ], [ %62, %60 ]
%65 = zext i1 %64 to i32
%66 = icmp eq i32 %57, %65
%67 = zext i1 %66 to i32
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 %67)
%69 = load i32, i32* %4
%70 = icmp ne i32 %69, 0
br i1 %70, label %74, label %71
71: ; preds = %63
%72 = load i32, i32* %5
%73 = icmp ne i32 %72, 0
br label %74
74: ; preds = %71, %63
%75 = phi i1 [ true, %63 ], [ %73, %71 ]
%76 = zext i1 %75 to i32
%77 = load i32, i32* %4
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %74
%80 = load i32, i32* %5
%81 = icmp ne i32 %80, 0
br label %82
82: ; preds = %79, %74
%83 = phi i1 [ false, %74 ], [ %81, %79 ]
%84 = zext i1 %83 to i32
%85 = add nsw i32 %76, %84
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 %85)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"!s=%d\0A\00"
@.str.1 = [6 x i8] c"a=%d\0A\00"
@.str.2 = [12 x i8] c"a=%d %d %d\0A\00"
@.str.3 = [9 x i8] c"a=%d %d\0A\00"
@.str.7 = [6 x i8] c"b=%d\0A\00"
@.str.8 = [8 x i8] c"exp=%d\0A\00"
@.str.9 = [6 x i8] c"r=%d\0A\00"
@str = [3 x i8] c"a1\00"
@str.10 = [3 x i8] c"a2\00"
@str.11 = [3 x i8] c"a4\00"
define void @bool_test() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 1)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 1)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 1, i32 1)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 0, i32 1)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 0)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.10, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.11, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 6)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 400)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 1)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 1)
ret void
}