#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 getbc(int);
int getnum_l1b();
const int getnum_l0a(int z) {
  static int l[4] = {0x7fffffff, 4, 8, 16};
  int i = 1, j;
  z = l[z];
  while (i < z) {
    j = getbc(1);
    if (j < 0)
      return j;
    if (j)
      return i;
    i++;
  }
  j = getbc(1);
  if (j < 0)
    return j;
  if (j)
    return i;
  j = getnum_l1b();
  if (j < 0)
    return j;
  return j + i;
}


x86 assembly (clang, -O0):
<getnum_l0a>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movslq -0x8(%rbp),%rcx
lea    0x2f03(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1194 <getnum_l0a+0x74>
mov    $0x1,%edi
call   1030 <getbc@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    1171 <getnum_l0a+0x51>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f3 <getnum_l0a+0xd3>
cmpl   $0x0,-0x10(%rbp)
je     1186 <getnum_l0a+0x66>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f3 <getnum_l0a+0xd3>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <getnum_l0a+0x23>
mov    $0x1,%edi
call   1030 <getbc@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    11b6 <getnum_l0a+0x96>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f3 <getnum_l0a+0xd3>
cmpl   $0x0,-0x10(%rbp)
je     11cb <getnum_l0a+0xab>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f3 <getnum_l0a+0xd3>
mov    $0x0,%al
call   1040 <getnum_l1b@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    11ea <getnum_l0a+0xca>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f3 <getnum_l0a+0xd3>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getnum_l0a>:
push   %rbp
push   %rbx
push   %rax
movslq %edi,%rax
lea    0xed3(%rip),%rcx
mov    (%rcx,%rax,4),%eax
cmp    $0x3,%eax
mov    $0x2,%ebp
cmovge %eax,%ebp
mov    $0x1,%ebx
mov    $0x1,%edi
call   1030 <getbc@plt>
test   %eax,%eax
js     117b <getnum_l0a+0x5b>
jne    117d <getnum_l0a+0x5d>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1140 <getnum_l0a+0x20>
mov    $0x1,%edi
call   1030 <getbc@plt>
test   %eax,%eax
js     117b <getnum_l0a+0x5b>
jne    1177 <getnum_l0a+0x57>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getnum_l1b@plt>
test   %eax,%eax
cmovs  %ebx,%ebp
add    %eax,%ebp
mov    %ebp,%ebx
jmp    117d <getnum_l0a+0x5d>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@getnum_l0a.l = internal global [4 x i32] [i32 2147483647, i32 4, i32 8, i32 16]
define i32 @getnum_l0a(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 1, i32* %4
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [4 x i32], [4 x i32]* @getnum_l0a.l, i64 0, i64 %7
%9 = load i32, i32* %8
store i32 %9, i32* %3
br label %10
10: ; preds = %25, %1
%11 = load i32, i32* %4
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %28
14: ; preds = %10
%15 = call i32 @getbc(i32 1)
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = load i32, i32* %5
store i32 %19, i32* %2
br label %49
20: ; preds = %14
%21 = load i32, i32* %5
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = load i32, i32* %4
store i32 %24, i32* %2
br label %49
25: ; preds = %20
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %10
28: ; preds = %10
%29 = call i32 @getbc(i32 1)
store i32 %29, i32* %5
%30 = load i32, i32* %5
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load i32, i32* %5
store i32 %33, i32* %2
br label %49
34: ; preds = %28
%35 = load i32, i32* %5
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = load i32, i32* %4
store i32 %38, i32* %2
br label %49
39: ; preds = %34
%40 = call i32 (...) @getnum_l1b()
store i32 %40, i32* %5
%41 = load i32, i32* %5
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = load i32, i32* %5
store i32 %44, i32* %2
br label %49
45: ; preds = %39
%46 = load i32, i32* %5
%47 = load i32, i32* %4
%48 = add nsw i32 %46, %47
store i32 %48, i32* %2
br label %49
49: ; preds = %45, %43, %37, %32, %23, %18
%50 = load i32, i32* %2
ret i32 %50
}

LLVM IR (-O2):
@getnum_l0a.l = internal unnamed_addr constant [4 x i32] [i32 2147483647, i32 4, i32 8, i32 16]
define i32 @getnum_l0a(i32 %0) {
%2 = sext i32 %0 to i64
%3 = getelementptr inbounds [4 x i32], [4 x i32]* @getnum_l0a.l, i64 0, i64 %2
%4 = load i32, i32* %3
%5 = call i32 @llvm.smax.i32(i32 %4, i32 2)
br label %6
6: ; preds = %1, %12
%7 = phi i32 [ %13, %12 ], [ 1, %1 ]
%8 = tail call i32 @getbc(i32 1)
%9 = icmp slt i32 %8, 0
br i1 %9, label %25, label %10
10: ; preds = %6
%11 = icmp eq i32 %8, 0
br i1 %11, label %12, label %25
12: ; preds = %10
%13 = add nuw nsw i32 %7, 1
%14 = icmp eq i32 %13, %5
br i1 %14, label %15, label %6
15: ; preds = %12
%16 = tail call i32 @getbc(i32 1)
%17 = icmp slt i32 %16, 0
br i1 %17, label %25, label %18
18: ; preds = %15
%19 = icmp eq i32 %16, 0
br i1 %19, label %20, label %25
20: ; preds = %18
%21 = tail call i32 (...) @getnum_l1b()
%22 = icmp slt i32 %21, 0
%23 = select i1 %22, i32 0, i32 %5
%24 = add nsw i32 %23, %21
br label %25
25: ; preds = %10, %6, %20, %18, %15
%26 = phi i32 [ %16, %15 ], [ %5, %18 ], [ %24, %20 ], [ %7, %10 ], [ %8, %6 ]
ret i32 %26
}