#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 bio_read(int);
int t2_getnumpasses() {
  int n;
  if (!bio_read(1))
    return 1;
  if (!bio_read(1))
    return 2;
  if ((n = bio_read(2)) != 3)
    return 3 + n;
  if ((n = bio_read(5)) != 31)
    return 6 + n;
  return 37 + bio_read(7);
}


x86 assembly (clang, -O0):
<t2_getnumpasses>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
call   1030 <bio_read@plt>
cmp    $0x0,%eax
jne    1137 <t2_getnumpasses+0x27>
movl   $0x1,-0x4(%rbp)
jmp    11ae <t2_getnumpasses+0x9e>
mov    $0x1,%edi
call   1030 <bio_read@plt>
cmp    $0x0,%eax
jne    1156 <t2_getnumpasses+0x46>
movl   $0x2,-0x4(%rbp)
jmp    11ae <t2_getnumpasses+0x9e>
mov    $0x2,%edi
call   1030 <bio_read@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x3,%eax
je     117a <t2_getnumpasses+0x6a>
mov    -0x8(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x4(%rbp)
jmp    11ae <t2_getnumpasses+0x9e>
mov    $0x5,%edi
call   1030 <bio_read@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x1f,%eax
je     119e <t2_getnumpasses+0x8e>
mov    -0x8(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x4(%rbp)
jmp    11ae <t2_getnumpasses+0x9e>
mov    $0x7,%edi
call   1030 <bio_read@plt>
add    $0x25,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t2_getnumpasses>:
push   %rbx
mov    $0x1,%ebx
mov    $0x1,%edi
call   1030 <bio_read@plt>
test   %eax,%eax
je     1174 <t2_getnumpasses+0x64>
mov    $0x1,%edi
call   1030 <bio_read@plt>
test   %eax,%eax
je     1161 <t2_getnumpasses+0x51>
mov    $0x2,%edi
call   1030 <bio_read@plt>
cmp    $0x3,%eax
jne    1168 <t2_getnumpasses+0x58>
mov    $0x5,%edi
call   1030 <bio_read@plt>
cmp    $0x1f,%eax
jne    116f <t2_getnumpasses+0x5f>
mov    $0x7,%edi
call   1030 <bio_read@plt>
mov    %eax,%ebx
add    $0x25,%ebx
jmp    1174 <t2_getnumpasses+0x64>
mov    $0x2,%ebx
jmp    1174 <t2_getnumpasses+0x64>
mov    %eax,%ebx
add    $0x3,%ebx
jmp    1174 <t2_getnumpasses+0x64>
mov    %eax,%ebx
add    $0x6,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @t2_getnumpasses() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @bio_read(i32 1)
%4 = icmp ne i32 %3, 0
br i1 %4, label %6, label %5
5: ; preds = %0
store i32 1, i32* %1
br label %25
6: ; preds = %0
%7 = call i32 @bio_read(i32 1)
%8 = icmp ne i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %6
store i32 2, i32* %1
br label %25
10: ; preds = %6
%11 = call i32 @bio_read(i32 2)
store i32 %11, i32* %2
%12 = icmp ne i32 %11, 3
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* %2
%15 = add nsw i32 3, %14
store i32 %15, i32* %1
br label %25
16: ; preds = %10
%17 = call i32 @bio_read(i32 5)
store i32 %17, i32* %2
%18 = icmp ne i32 %17, 31
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %2
%21 = add nsw i32 6, %20
store i32 %21, i32* %1
br label %25
22: ; preds = %16
%23 = call i32 @bio_read(i32 7)
%24 = add nsw i32 37, %23
store i32 %24, i32* %1
br label %25
25: ; preds = %22, %19, %13, %9, %5
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
define i32 @t2_getnumpasses() {
%1 = tail call i32 @bio_read(i32 1)
%2 = icmp eq i32 %1, 0
br i1 %2, label %19, label %3
3: ; preds = %0
%4 = tail call i32 @bio_read(i32 1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %3
%7 = tail call i32 @bio_read(i32 2)
%8 = icmp eq i32 %7, 3
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = add nsw i32 %7, 3
br label %19
11: ; preds = %6
%12 = tail call i32 @bio_read(i32 5)
%13 = icmp eq i32 %12, 31
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = add nsw i32 %12, 6
br label %19
16: ; preds = %11
%17 = tail call i32 @bio_read(i32 7)
%18 = add nsw i32 %17, 37
br label %19
19: ; preds = %3, %0, %16, %14, %9
%20 = phi i32 [ %10, %9 ], [ %15, %14 ], [ %18, %16 ], [ 1, %0 ], [ 2, %3 ]
ret i32 %20
}