#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 */
scalar_t__ do_problem(int);
int /*<<< orphan*/ printf(char *, char *);
long strtol(char *, char **, int);
int main(int argc, char **argv) {
  long num;
  char *endptr = NULL;
  int i;
  if (argc < 2) {
    printf("Usage: %s [problem number]\n", *argv);
    return 0;
  }
  for (i = 1; i < argc; i++) {
    num = strtol(argv[i], &endptr, 10);
    if (num <= 0 || *endptr || do_problem((int)num) < 0) {
      printf("Usage: %s [problem number]\n", *argv);
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1177 <main+0x47>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    120a <main+0xda>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1203 <main+0xd3>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jle    11d8 <main+0xa8>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11d8 <main+0xa8>
mov    -0x18(%rbp),%rax
mov    %eax,%edi
call   1050 <do_problem@plt>
cmp    $0x0,%rax
jge    11f0 <main+0xc0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe1a(%rip),%rdi
call   1030 <printf@plt>
jmp    1203 <main+0xd3>
jmp    11f5 <main+0xc5>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117e <main+0x4e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
movq   $0x0,(%rsp)
cmp    $0x2,%edi
jge    1166 <main+0x36>
mov    (%r12),%rsi
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %edi,%r15d
mov    $0x1,%ebx
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbx,8),%rdi
mov    %r14,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
test   %rax,%rax
jle    1148 <main+0x18>
mov    (%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    1148 <main+0x18>
mov    %eax,%edi
call   1050 <do_problem@plt>
test   %rax,%rax
js     1148 <main+0x18>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1180 <main+0x50>
jmp    1158 <main+0x28>

LLVM IR (-O0):
@.str = [28 x i8] c"Usage: %s [problem number]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = load i8*, i8** %12
%14 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 0, i32* %3
br label %48
15: ; preds = %2
store i32 1, i32* %8
br label %16
16: ; preds = %44, %15
%17 = load i32, i32* %8
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %47
20: ; preds = %16
%21 = load i8**, i8*** %5
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i64 @strtol(i8* %25, i8** %7, i32 10)
store i64 %26, i64* %6
%27 = load i64, i64* %6
%28 = icmp sle i64 %27, 0
br i1 %28, label %39, label %29
29: ; preds = %20
%30 = load i8*, i8** %7
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br i1 %33, label %39, label %34
34: ; preds = %29
%35 = load i64, i64* %6
%36 = trunc i64 %35 to i32
%37 = call i64 @do_problem(i32 %36)
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %34, %29, %20
%40 = load i8**, i8*** %5
%41 = load i8*, i8** %40
%42 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %41)
br label %47
43: ; preds = %34
br label %44
44: ; preds = %43
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %16
47: ; preds = %39, %16
store i32 0, i32* %3
br label %48
48: ; preds = %47, %11
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [28 x i8] c"Usage: %s [problem number]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = icmp slt i32 %0, 2
br i1 %5, label %25, label %6
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %10
8: ; preds = %20
%9 = icmp eq i64 %24, %7
br i1 %9, label %28, label %10
10: ; preds = %6, %8
%11 = phi i64 [ 1, %6 ], [ %24, %8 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
%14 = call i64 @strtol(i8* %13, i8** %3, i32 10)
%15 = icmp slt i64 %14, 1
br i1 %15, label %25, label %16
16: ; preds = %10
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = trunc i64 %14 to i32
%22 = tail call i64 @do_problem(i32 %21)
%23 = icmp slt i64 %22, 0
%24 = add nuw nsw i64 %11, 1
br i1 %23, label %25, label %8
25: ; preds = %10, %16, %20, %2
%26 = load i8*, i8** %1
%27 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %8, %25
ret i32 0
}