int main() {
  char *q = foo(1);
  if (q != ((void *)0)) {
    if (strcmp(q, "rb"))
      abort();
    free(q);
  }
  q = bar(0);
  if (q != ((void *)0)) {
    if (strcmp(q, "wb"))
      abort();
    free(q);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
mov    $0x0,%al
call   1070 <foo@plt>
cltq
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a3 <main+0x53>
mov    -0x10(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     119a <main+0x4a>
call   1040 <abort@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1050 <bar@plt>
cltq
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11e4 <main+0x94>
mov    -0x10(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     11db <main+0x8b>
call   1040 <abort@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x1,%edi
xor    %eax,%eax
call   1070 <foo@plt>
test   %eax,%eax
je     117f <main+0x2f>
movslq %eax,%rbx
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11ae <main+0x5e>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1050 <bar@plt>
test   %eax,%eax
je     11aa <main+0x5a>
movslq %eax,%rbx
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11ae <main+0x5e>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret
call   1040 <abort@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i32 (i32, ...) bitcast (i32 (...)* @foo to i32 (i32, ...)*)(i32 1)
%4 = sext i32 %3 to i64
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %15
8: ; preds = %0
%9 = load i8*, i8** %2
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
unreachable
13: ; preds = %8
%14 = load i8*, i8** %2
br label %15
15: ; preds = %13, %0
%16 = call i32 (i32, ...) bitcast (i32 (...)* @bar to i32 (i32, ...)*)(i32 0)
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %2
%19 = load i8*, i8** %2
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %28
21: ; preds = %15
%22 = load i8*, i8** %2
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21
unreachable
26: ; preds = %21
%27 = load i8*, i8** %2
br label %28
28: ; preds = %26, %15
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @main() {
%1 = tail call i32 (i32, ...) bitcast (i32 (...)* @foo to i32 (i32, ...)*)(i32 1)
%2 = sext i32 %1 to i64
%3 = inttoptr i64 %2 to i8*
%4 = icmp eq i32 %1, 0
br i1 %4, label %10, label %5
5: ; preds = %0
%6 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %5
tail call void @abort()
unreachable
9: ; preds = %5
tail call void @free(i8* %3)
br label %10
10: ; preds = %9, %0
%11 = tail call i32 (i32, ...) bitcast (i32 (...)* @bar to i32 (i32, ...)*)(i32 0)
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i8*
%14 = icmp eq i32 %11, 0
br i1 %14, label %20, label %15
15: ; preds = %10
%16 = tail call i32 @strcmp(i8* %13, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %15
tail call void @abort()
unreachable
19: ; preds = %15
tail call void @free(i8* %13)
br label %20
20: ; preds = %19, %10
ret i32 0
}