#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 f(int, int);
int /*<<< orphan*/ printf(char *);
void main(int argc, char **argv) {
  int a;
  a = f(1, 0) ? f(2, 1) ? f(3, 1) : f(4, 1) : f(5, 1);
  printf("\n");
  a = f(1, 1) ? f(2, 1) ? f(3, 1) : f(4, 1) : f(5, 1);
  printf("\n");
  a = f(1, 1) ? f(2, 1) : f(3, 1) ? f(4, 1) : f(5, 1);
  printf("\n");
  a = f(1, 0) ? f(2, 1) : f(3, 1) ? f(4, 1) : f(5, 1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <f@plt>
cmp    $0x0,%eax
je     1190 <main+0x70>
mov    $0x2,%edi
mov    $0x1,%esi
call   1030 <f@plt>
cmp    $0x0,%eax
je     1173 <main+0x53>
mov    $0x3,%edi
mov    $0x1,%esi
call   1030 <f@plt>
mov    %eax,-0x18(%rbp)
jmp    1185 <main+0x65>
mov    $0x4,%edi
mov    $0x1,%esi
call   1030 <f@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11a2 <main+0x82>
mov    $0x5,%edi
mov    $0x1,%esi
call   1030 <f@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    0xe51(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1030 <f@plt>
cmp    $0x0,%eax
je     1215 <main+0xf5>
mov    $0x2,%edi
mov    $0x1,%esi
call   1030 <f@plt>
cmp    $0x0,%eax
je     11f8 <main+0xd8>
mov    $0x3,%edi
mov    $0x1,%esi
call   1030 <f@plt>
mov    %eax,-0x20(%rbp)
jmp    120a <main+0xea>
mov    $0x4,%edi
mov    $0x1,%esi
call   1030 <f@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1227 <main+0x107>
mov    $0x5,%edi
mov    $0x1,%esi
call   1030 <f@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    0xdcc(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1030 <f@plt>
cmp    $0x0,%eax
je     1265 <main+0x145>
mov    $0x2,%edi
mov    $0x1,%esi
call   1030 <f@plt>
mov    %eax,-0x28(%rbp)
jmp    12ac <main+0x18c>
mov    $0x3,%edi
mov    $0x1,%esi
call   1030 <f@plt>
cmp    $0x0,%eax
je     1294 <main+0x174>
mov    $0x4,%edi
mov    $0x1,%esi
call   1030 <f@plt>
mov    %eax,-0x2c(%rbp)
jmp    12a6 <main+0x186>
mov    $0x5,%edi
mov    $0x1,%esi
call   1030 <f@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    0xd47(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <f@plt>
cmp    $0x0,%eax
je     12ea <main+0x1ca>
mov    $0x2,%edi
mov    $0x1,%esi
call   1030 <f@plt>
mov    %eax,-0x30(%rbp)
jmp    1331 <main+0x211>
mov    $0x3,%edi
mov    $0x1,%esi
call   1030 <f@plt>
cmp    $0x0,%eax
je     1319 <main+0x1f9>
mov    $0x4,%edi
mov    $0x1,%esi
call   1030 <f@plt>
mov    %eax,-0x34(%rbp)
jmp    132b <main+0x20b>
mov    $0x5,%edi
mov    $0x1,%esi
call   1030 <f@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x14(%rbp)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <f@plt>
mov    $0x5,%ebx
mov    $0x5,%edi
test   %eax,%eax
je     1155 <main+0x35>
mov    $0x2,%edi
mov    $0x1,%esi
call   1040 <f@plt>
cmp    $0x1,%eax
mov    $0x3,%edi
adc    $0x0,%edi
mov    $0x1,%esi
call   1040 <f@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <f@plt>
test   %eax,%eax
je     1196 <main+0x76>
mov    $0x2,%edi
mov    $0x1,%esi
call   1040 <f@plt>
cmp    $0x1,%eax
mov    $0x3,%ebx
adc    $0x0,%ebx
mov    %ebx,%edi
mov    $0x1,%esi
call   1040 <f@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <f@plt>
mov    $0x2,%ebx
mov    $0x2,%edi
test   %eax,%eax
jne    11e3 <main+0xc3>
mov    $0x3,%edi
mov    $0x1,%esi
call   1040 <f@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
or     $0x4,%edi
mov    $0x1,%esi
call   1040 <f@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <f@plt>
test   %eax,%eax
jne    1220 <main+0x100>
mov    $0x3,%edi
mov    $0x1,%esi
call   1040 <f@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
or     $0x4,%ebx
mov    %ebx,%edi
mov    $0x1,%esi
pop    %rbx
jmp    1040 <f@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = call i32 @f(i32 1, i32 0)
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = call i32 @f(i32 2, i32 1)
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @f(i32 3, i32 1)
br label %15
13: ; preds = %8
%14 = call i32 @f(i32 4, i32 1)
br label %15
15: ; preds = %13, %11
%16 = phi i32 [ %12, %11 ], [ %14, %13 ]
br label %19
17: ; preds = %2
%18 = call i32 @f(i32 5, i32 1)
br label %19
19: ; preds = %17, %15
%20 = phi i32 [ %16, %15 ], [ %18, %17 ]
store i32 %20, i32* %5
%21 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @f(i32 1, i32 1)
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %33
24: ; preds = %19
%25 = call i32 @f(i32 2, i32 1)
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 @f(i32 3, i32 1)
br label %31
29: ; preds = %24
%30 = call i32 @f(i32 4, i32 1)
br label %31
31: ; preds = %29, %27
%32 = phi i32 [ %28, %27 ], [ %30, %29 ]
br label %35
33: ; preds = %19
%34 = call i32 @f(i32 5, i32 1)
br label %35
35: ; preds = %33, %31
%36 = phi i32 [ %32, %31 ], [ %34, %33 ]
store i32 %36, i32* %5
%37 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%38 = call i32 @f(i32 1, i32 1)
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = call i32 @f(i32 2, i32 1)
br label %51
42: ; preds = %35
%43 = call i32 @f(i32 3, i32 1)
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 @f(i32 4, i32 1)
br label %49
47: ; preds = %42
%48 = call i32 @f(i32 5, i32 1)
br label %49
49: ; preds = %47, %45
%50 = phi i32 [ %46, %45 ], [ %48, %47 ]
br label %51
51: ; preds = %49, %40
%52 = phi i32 [ %41, %40 ], [ %50, %49 ]
store i32 %52, i32* %5
%53 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%54 = call i32 @f(i32 1, i32 0)
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %51
%57 = call i32 @f(i32 2, i32 1)
br label %67
58: ; preds = %51
%59 = call i32 @f(i32 3, i32 1)
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = call i32 @f(i32 4, i32 1)
br label %65
63: ; preds = %58
%64 = call i32 @f(i32 5, i32 1)
br label %65
65: ; preds = %63, %61
%66 = phi i32 [ %62, %61 ], [ %64, %63 ]
br label %67
67: ; preds = %65, %56
%68 = phi i32 [ %57, %56 ], [ %66, %65 ]
store i32 %68, i32* %5
ret void
}

LLVM IR (-O2):
define void @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @f(i32 1, i32 0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = tail call i32 @f(i32 2, i32 1)
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i32 4, i32 3
br label %9
9: ; preds = %2, %5
%10 = phi i32 [ %8, %5 ], [ 5, %2 ]
%11 = tail call i32 @f(i32 %10, i32 1)
%12 = tail call i32 @putchar(i32 10)
%13 = tail call i32 @f(i32 1, i32 1)
%14 = icmp eq i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %9
%16 = tail call i32 @f(i32 2, i32 1)
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i32 4, i32 3
br label %19
19: ; preds = %9, %15
%20 = phi i32 [ %18, %15 ], [ 5, %9 ]
%21 = tail call i32 @f(i32 %20, i32 1)
%22 = tail call i32 @putchar(i32 10)
%23 = tail call i32 @f(i32 1, i32 1)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %19
%26 = tail call i32 @f(i32 3, i32 1)
%27 = icmp eq i32 %26, 0
%28 = select i1 %27, i32 5, i32 4
br label %29
29: ; preds = %25, %19
%30 = phi i32 [ 2, %19 ], [ %28, %25 ]
%31 = tail call i32 @f(i32 %30, i32 1)
%32 = tail call i32 @putchar(i32 10)
%33 = tail call i32 @f(i32 1, i32 0)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %29
%36 = tail call i32 @f(i32 3, i32 1)
%37 = icmp eq i32 %36, 0
%38 = select i1 %37, i32 5, i32 4
br label %39
39: ; preds = %35, %29
%40 = phi i32 [ 2, %29 ], [ %38, %35 ]
%41 = tail call i32 @f(i32 %40, i32 1)
ret void
}