#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*/ check();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int main() {
  check();
  check();
  check();
  printf("let's get ready for ruuuuumble\n");
  printf("first malloc\n");
  if (malloc(1)) {
    printf("second malloc\n");
    if (malloc(2)) {
      printf("third malloc \n");
      malloc(3);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <check@plt>
mov    $0x0,%al
call   1050 <check@plt>
mov    $0x0,%al
call   1050 <check@plt>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <malloc@plt>
cmp    $0x0,%rax
je     11bb <main+0x8b>
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
mov    $0x2,%edi
call   1040 <malloc@plt>
cmp    $0x0,%rax
je     11b6 <main+0x86>
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
mov    $0x3,%edi
call   1040 <malloc@plt>
jmp    11bb <main+0x8b>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1050 <check@plt>
xor    %eax,%eax
call   1050 <check@plt>
xor    %eax,%eax
call   1050 <check@plt>
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     119e <main+0x6e>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     119e <main+0x6e>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1040 <malloc@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [32 x i8] c"let's get ready for ruuuuumble\0A\00"
@.str.1 = [14 x i8] c"first malloc\0A\00"
@.str.2 = [15 x i8] c"second malloc\0A\00"
@.str.3 = [15 x i8] c"third malloc \0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @check()
%3 = call i32 (...) @check()
%4 = call i32 (...) @check()
%5 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%7 = call i64 @malloc(i32 1)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%11 = call i64 @malloc(i32 2)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%15 = call i64 @malloc(i32 3)
br label %16
16: ; preds = %13, %9
br label %17
17: ; preds = %16, %0
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@str = [31 x i8] c"let's get ready for ruuuuumble\00"
@str.4 = [13 x i8] c"first malloc\00"
@str.5 = [14 x i8] c"second malloc\00"
@str.6 = [14 x i8] c"third malloc \00"
define i32 @main() {
%1 = tail call i32 (...) @check()
%2 = tail call i32 (...) @check()
%3 = tail call i32 (...) @check()
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.4, i64 0, i64 0))
%6 = tail call i64 @malloc(i32 1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.5, i64 0, i64 0))
%10 = tail call i64 @malloc(i32 2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.6, i64 0, i64 0))
%14 = tail call i64 @malloc(i32 3)
br label %15
15: ; preds = %8, %12, %0
ret i32 0
}