#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*/ c();
int /*<<< orphan*/ d();
int /*<<< orphan*/ e();
int /*<<< orphan*/ f();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
void b(int i) {
  printf("this is b\n");
  if (i == 1) {
    c();
    f();
  } else {
    for (int i = 0; i < 2; i++) {
      d();
    }
    sleep(1);
    int *t = NULL;
    printf("%d\n", *t);
    e();
  }
}


x86 assembly (clang, -O0):
<b>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x1,-0x4(%rbp)
jne    1196 <b+0x36>
mov    $0x0,%al
call   1070 <c@plt>
mov    $0x0,%al
call   1040 <f@plt>
jmp    11e9 <b+0x89>
movl   $0x0,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11bc <b+0x5c>
mov    $0x0,%al
call   1030 <d@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119d <b+0x3d>
mov    $0x1,%edi
call   1080 <sleep@plt>
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <e@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<b>:
push   %rbx
mov    %edi,%ebx
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
cmp    $0x1,%ebx
jne    1193 <b+0x23>
call   1080 <c@plt>
xor    %eax,%eax
pop    %rbx
jmp    1050 <f@plt>
call   1040 <d@plt>
xor    %eax,%eax
call   1040 <d@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
pop    %rbx
jmp    1070 <e@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"this is b\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define void @b(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
store i32 %0, i32* %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = call i32 (...) @c()
%10 = call i32 (...) @f()
br label %26
11: ; preds = %1
store i32 0, i32* %3
br label %12
12: ; preds = %17, %11
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = call i32 (...) @d()
br label %17
17: ; preds = %15
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %12
20: ; preds = %12
%21 = call i32 @sleep(i32 1)
store i32* null, i32** %4
%22 = load i32*, i32** %4
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = call i32 (...) @e()
br label %26
26: ; preds = %20, %8
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d\0A\00"
@str = [10 x i8] c"this is b\00"
define void @b(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%3 = icmp eq i32 %0, 1
br i1 %3, label %10, label %4
4: ; preds = %1
%5 = tail call i32 (...) @d()
%6 = tail call i32 (...) @d()
%7 = tail call i32 @sleep(i32 1)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 undef)
%9 = tail call i32 (...) @e()
br label %13
10: ; preds = %1
%11 = tail call i32 (...) @c()
%12 = tail call i32 (...) @f()
br label %13
13: ; preds = %4, %10
ret void
}