#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 atoi(char *);
int check_level(int, int, char *);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  for (int i = 1; i < argc; i++) {
    int v = atoi(argv[i]);
    printf("Level %d:\n", v);
    int matches =
        check_level(v, 1, "DEBUG_ALLOC") + check_level(v, 2, "DEBUG_STACK") +
        check_level(v, 4, "DEBUG_ARITH") + check_level(v, 8, "DEBUG_EVAL") +
        check_level(v, 16, "DEBUG_LAMBDA") +
        check_level(v, 32, "DEBUG_BOOTSTRAP") + check_level(v, 64, "DEBUG_IO") +
        check_level(v, 128, "DEBUG_REPL") + check_level(v, 256, "DEBUG_BIND");
    printf("\t%d matches\n", matches);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12a0 <main+0x170>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
mov    $0x1,%esi
lea    0xe80(%rip),%rdx
call   1040 <check_level@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x2,%esi
lea    0xe75(%rip),%rdx
call   1040 <check_level@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x4,%esi
lea    0xe63(%rip),%rdx
call   1040 <check_level@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x8,%esi
lea    0xe51(%rip),%rdx
call   1040 <check_level@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x10,%esi
lea    0xe3e(%rip),%rdx
call   1040 <check_level@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x20,%esi
lea    0xe2d(%rip),%rdx
call   1040 <check_level@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x40,%esi
lea    0xe1f(%rip),%rdx
call   1040 <check_level@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x80,%esi
lea    0xe0a(%rip),%rdx
call   1040 <check_level@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x100,%esi
lea    0xdf7(%rip),%rdx
call   1040 <check_level@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xde9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1261 <main+0x131>
mov    %rsi,%rbx
mov    %edi,%r13d
mov    $0x1,%ebp
lea    0xf20(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rdi
call   1050 <atoi@plt>
mov    %eax,%r15d
lea    0xe8d(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r15d,%edi
mov    $0x1,%esi
lea    0xe82(%rip),%rdx
call   1040 <check_level@plt>
mov    %eax,%r12d
mov    %r15d,%edi
mov    $0x2,%esi
lea    0xe77(%rip),%rdx
call   1040 <check_level@plt>
add    %eax,%r12d
mov    %r15d,%edi
mov    $0x4,%esi
lea    0xe6c(%rip),%rdx
call   1040 <check_level@plt>
add    %eax,%r12d
mov    %r15d,%edi
mov    $0x8,%esi
lea    0xe61(%rip),%rdx
call   1040 <check_level@plt>
add    %eax,%r12d
mov    %r15d,%edi
mov    $0x10,%esi
lea    0xe55(%rip),%rdx
call   1040 <check_level@plt>
add    %eax,%r12d
mov    %r15d,%edi
mov    $0x20,%esi
lea    0xe4b(%rip),%rdx
call   1040 <check_level@plt>
add    %eax,%r12d
mov    %r15d,%edi
mov    $0x40,%esi
lea    0xe44(%rip),%rdx
call   1040 <check_level@plt>
add    %eax,%r12d
mov    %r15d,%edi
mov    $0x80,%esi
lea    0xe36(%rip),%rdx
call   1040 <check_level@plt>
add    %eax,%r12d
mov    %r15d,%edi
mov    $0x100,%esi
lea    0xe2a(%rip),%rdx
call   1040 <check_level@plt>
add    %eax,%r12d
mov    %r14,%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1160 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Level %d:\0A\00"
@.str.1 = [12 x i8] c"DEBUG_ALLOC\00"
@.str.2 = [12 x i8] c"DEBUG_STACK\00"
@.str.3 = [12 x i8] c"DEBUG_ARITH\00"
@.str.4 = [11 x i8] c"DEBUG_EVAL\00"
@.str.5 = [13 x i8] c"DEBUG_LAMBDA\00"
@.str.6 = [16 x i8] c"DEBUG_BOOTSTRAP\00"
@.str.7 = [9 x i8] c"DEBUG_IO\00"
@.str.8 = [11 x i8] c"DEBUG_REPL\00"
@.str.9 = [11 x i8] c"DEBUG_BIND\00"
@.str.10 = [13 x i8] c"\09%d matches\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %9
9: ; preds = %50, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %53
13: ; preds = %9
%14 = load i8**, i8*** %5
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %7
%23 = call i32 @check_level(i32 %22, i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* %7
%25 = call i32 @check_level(i32 %24, i32 2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%26 = add nsw i32 %23, %25
%27 = load i32, i32* %7
%28 = call i32 @check_level(i32 %27, i32 4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%29 = add nsw i32 %26, %28
%30 = load i32, i32* %7
%31 = call i32 @check_level(i32 %30, i32 8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%32 = add nsw i32 %29, %31
%33 = load i32, i32* %7
%34 = call i32 @check_level(i32 %33, i32 16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%35 = add nsw i32 %32, %34
%36 = load i32, i32* %7
%37 = call i32 @check_level(i32 %36, i32 32, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%38 = add nsw i32 %35, %37
%39 = load i32, i32* %7
%40 = call i32 @check_level(i32 %39, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%41 = add nsw i32 %38, %40
%42 = load i32, i32* %7
%43 = call i32 @check_level(i32 %42, i32 128, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%44 = add nsw i32 %41, %43
%45 = load i32, i32* %7
%46 = call i32 @check_level(i32 %45, i32 256, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%47 = add nsw i32 %44, %46
store i32 %47, i32* %8
%48 = load i32, i32* %8
%49 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %13
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %9
53: ; preds = %9
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@.str = [11 x i8] c"Level %d:\0A\00"
@.str.1 = [12 x i8] c"DEBUG_ALLOC\00"
@.str.2 = [12 x i8] c"DEBUG_STACK\00"
@.str.3 = [12 x i8] c"DEBUG_ARITH\00"
@.str.4 = [11 x i8] c"DEBUG_EVAL\00"
@.str.5 = [13 x i8] c"DEBUG_LAMBDA\00"
@.str.6 = [16 x i8] c"DEBUG_BOOTSTRAP\00"
@.str.7 = [9 x i8] c"DEBUG_IO\00"
@.str.8 = [11 x i8] c"DEBUG_REPL\00"
@.str.9 = [11 x i8] c"DEBUG_BIND\00"
@.str.10 = [13 x i8] c"\09%d matches\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %7
6: ; preds = %7, %2
ret i32 0
7: ; preds = %4, %7
%8 = phi i64 [ 1, %4 ], [ %31, %7 ]
%9 = getelementptr inbounds i8*, i8** %1, i64 %8
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = tail call i32 @check_level(i32 %11, i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @check_level(i32 %11, i32 2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%15 = add nsw i32 %14, %13
%16 = tail call i32 @check_level(i32 %11, i32 4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%17 = add nsw i32 %15, %16
%18 = tail call i32 @check_level(i32 %11, i32 8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%19 = add nsw i32 %17, %18
%20 = tail call i32 @check_level(i32 %11, i32 16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%21 = add nsw i32 %19, %20
%22 = tail call i32 @check_level(i32 %11, i32 32, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%23 = add nsw i32 %21, %22
%24 = tail call i32 @check_level(i32 %11, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%25 = add nsw i32 %23, %24
%26 = tail call i32 @check_level(i32 %11, i32 128, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%27 = add nsw i32 %25, %26
%28 = tail call i32 @check_level(i32 %11, i32 256, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%29 = add nsw i32 %27, %28
%30 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i32 %29)
%31 = add nuw nsw i64 %8, 1
%32 = icmp eq i64 %31, %5
br i1 %32, label %6, label %7
}