#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 */
scalar_t__ bar(int /*<<< orphan*/);
scalar_t__ foo(int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  printf("%d\n", foo(0) || bar(0));
  printf("%d\n", foo(1) || bar(0));
  printf("%d\n", foo(0) && bar(0));
  printf("%d\n", foo(1) && bar(0));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1050 <foo@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x5(%rbp)
jne    1169 <main+0x39>
xor    %edi,%edi
call   1030 <bar@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
and    $0x1,%al
movzbl %al,%esi
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <foo@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x6(%rbp)
jne    11aa <main+0x7a>
xor    %edi,%edi
call   1030 <bar@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x6(%rbp)
mov    -0x6(%rbp),%al
and    $0x1,%al
movzbl %al,%esi
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <foo@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x7(%rbp)
je     11e8 <main+0xb8>
xor    %edi,%edi
call   1030 <bar@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x7(%rbp)
mov    -0x7(%rbp),%al
and    $0x1,%al
movzbl %al,%esi
lea    0xe09(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <foo@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x8(%rbp)
je     1229 <main+0xf9>
xor    %edi,%edi
call   1030 <bar@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x8(%rbp)
mov    -0x8(%rbp),%al
and    $0x1,%al
movzbl %al,%esi
lea    0xdc8(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   1050 <foo@plt>
mov    $0x1,%ebx
mov    $0x1,%esi
test   %rax,%rax
jne    1157 <main+0x27>
xor    %edi,%edi
call   1030 <bar@plt>
xor    %esi,%esi
test   %rax,%rax
setne  %sil
lea    0xea2(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <foo@plt>
test   %rax,%rax
jne    1181 <main+0x51>
xor    %edi,%edi
call   1030 <bar@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
lea    0xe78(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %ebx,%ebx
xor    %edi,%edi
call   1050 <foo@plt>
mov    $0x0,%esi
test   %rax,%rax
je     11b2 <main+0x82>
xor    %edi,%edi
call   1030 <bar@plt>
xor    %esi,%esi
test   %rax,%rax
setne  %sil
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <foo@plt>
test   %rax,%rax
je     11dc <main+0xac>
xor    %edi,%edi
call   1030 <bar@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
lea    0xe1d(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 @foo(i32 0)
%3 = icmp ne i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %0
%5 = call i64 @bar(i32 0)
%6 = icmp ne i64 %5, 0
br label %7
7: ; preds = %4, %0
%8 = phi i1 [ true, %0 ], [ %6, %4 ]
%9 = zext i1 %8 to i32
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i64 @foo(i32 1)
%12 = icmp ne i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %7
%14 = call i64 @bar(i32 0)
%15 = icmp ne i64 %14, 0
br label %16
16: ; preds = %13, %7
%17 = phi i1 [ true, %7 ], [ %15, %13 ]
%18 = zext i1 %17 to i32
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = call i64 @foo(i32 0)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = call i64 @bar(i32 0)
%24 = icmp ne i64 %23, 0
br label %25
25: ; preds = %22, %16
%26 = phi i1 [ false, %16 ], [ %24, %22 ]
%27 = zext i1 %26 to i32
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = call i64 @foo(i32 1)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = call i64 @bar(i32 0)
%33 = icmp ne i64 %32, 0
br label %34
34: ; preds = %31, %25
%35 = phi i1 [ false, %25 ], [ %33, %31 ]
%36 = zext i1 %35 to i32
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i64 @foo(i32 0)
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = tail call i64 @bar(i32 0)
%5 = icmp ne i64 %4, 0
%6 = zext i1 %5 to i32
br label %7
7: ; preds = %3, %0
%8 = phi i32 [ 1, %0 ], [ %6, %3 ]
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = tail call i64 @foo(i32 1)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = tail call i64 @bar(i32 0)
%14 = icmp ne i64 %13, 0
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %12, %7
%17 = phi i32 [ 1, %7 ], [ %15, %12 ]
%18 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = tail call i64 @foo(i32 0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %16
%22 = tail call i64 @bar(i32 0)
%23 = icmp ne i64 %22, 0
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %21, %16
%26 = phi i32 [ 0, %16 ], [ %24, %21 ]
%27 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = tail call i64 @foo(i32 1)
%29 = icmp eq i64 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %25
%31 = tail call i64 @bar(i32 0)
%32 = icmp ne i64 %31, 0
%33 = zext i1 %32 to i32
br label %34
34: ; preds = %30, %25
%35 = phi i32 [ 0, %25 ], [ %33, %30 ]
%36 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %35)
ret i32 0
}