#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 /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ usage();
void parsecmdargs(int argc, char **argv, int *loadonly, int *pageNo) {
  int i;
  if (argc < 2)
    usage();
  for (i = 1; i < argc - 1; i++) {
    if (!strcmp(argv[i], "-loadonly")) {
      *loadonly = 1;
    } else if (!strcmp(argv[i], "-page") && i + 1 < argc) {
      ++i;
      *pageNo = atoi(argv[i]);
    } else {
      usage();
    }
  }
}


x86 assembly (clang, -O0):
<parsecmdargs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpl   $0x2,-0x4(%rbp)
jge    1158 <parsecmdargs+0x28>
mov    $0x0,%al
call   1040 <usage@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1216 <parsecmdargs+0xe6>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe7d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11a0 <parsecmdargs+0x70>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    1203 <parsecmdargs+0xd3>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe57(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11f7 <parsecmdargs+0xc7>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cmp    -0x4(%rbp),%eax
jge    11f7 <parsecmdargs+0xc7>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    11fe <parsecmdargs+0xce>
mov    $0x0,%al
call   1040 <usage@plt>
jmp    1203 <parsecmdargs+0xd3>
jmp    1208 <parsecmdargs+0xd8>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115f <parsecmdargs+0x2f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsecmdargs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,0x8(%rsp)
mov    %rdx,0x10(%rsp)
cmp    $0x1,%edi
jg     1162 <parsecmdargs+0x32>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <usage@plt>
mov    %rdi,(%rsp)
cmp    $0x2,%edi
jne    117a <parsecmdargs+0x4a>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%rbx
mov    (%rsp),%rax
lea    -0x1(%rax),%r12d
mov    $0x1,%r15d
lea    0xe6e(%rip),%r13
jmp    11b4 <parsecmdargs+0x84>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x10(%rsp),%rax
movl   $0x1,(%rax)
add    $0x1,%r15d
cmp    %r12d,%r15d
jge    116b <parsecmdargs+0x3b>
movslq %r15d,%rax
mov    (%rbx,%rax,8),%r14
mov    %r14,%rdi
mov    %r13,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11a0 <parsecmdargs+0x70>
mov    %r14,%rdi
lea    0xe36(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    1200 <parsecmdargs+0xd0>
lea    0x1(%r15),%ebp
cmp    (%rsp),%ebp
jge    1200 <parsecmdargs+0xd0>
movslq %ebp,%rax
mov    (%rbx,%rax,8),%rdi
call   1050 <atoi@plt>
mov    0x8(%rsp),%rcx
mov    %eax,(%rcx)
mov    %ebp,%r15d
jmp    11ab <parsecmdargs+0x7b>
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <usage@plt>
jmp    11ab <parsecmdargs+0x7b>

LLVM IR (-O0):
@.str = [10 x i8] c"-loadonly\00"
@.str.1 = [6 x i8] c"-page\00"
define void @parsecmdargs(i32 %0, i8** %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = call i32 (...) @usage()
br label %14
14: ; preds = %12, %4
store i32 1, i32* %9
br label %15
15: ; preds = %57, %14
%16 = load i32, i32* %9
%17 = load i32, i32* %5
%18 = sub nsw i32 %17, 1
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %60
20: ; preds = %15
%21 = load i8**, i8*** %6
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 @strcmp(i8* %25, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%27 = icmp ne i32 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %20
%29 = load i32*, i32** %7
store i32 1, i32* %29
br label %56
30: ; preds = %20
%31 = load i8**, i8*** %6
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 @strcmp(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %53, label %38
38: ; preds = %30
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
%41 = load i32, i32* %5
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %53
43: ; preds = %38
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
%46 = load i8**, i8*** %6
%47 = load i32, i32* %9
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 @atoi(i8* %50)
%52 = load i32*, i32** %8
store i32 %51, i32* %52
br label %55
53: ; preds = %38, %30
%54 = call i32 (...) @usage()
br label %55
55: ; preds = %53, %43
br label %56
56: ; preds = %55, %28
br label %57
57: ; preds = %56
%58 = load i32, i32* %9
%59 = add nsw i32 %58, 1
store i32 %59, i32* %9
br label %15
60: ; preds = %15
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"-loadonly\00"
@.str.1 = [6 x i8] c"-page\00"
define void @parsecmdargs(i32 %0, i8** nocapture %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 (...) @usage()
br label %36
8: ; preds = %4
%9 = add nsw i32 %0, -1
%10 = icmp eq i32 %0, 2
br i1 %10, label %36, label %11
11: ; preds = %8, %32
%12 = phi i32 [ %34, %32 ], [ 1, %8 ]
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %15, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %11
store i32 1, i32* %2
br label %32
19: ; preds = %11
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %15, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = add nsw i32 %12, 1
%24 = icmp slt i32 %23, %0
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = sext i32 %23 to i64
%27 = getelementptr inbounds i8*, i8** %1, i64 %26
%28 = load i8*, i8** %27
%29 = tail call i32 @atoi(i8* %28)
store i32 %29, i32* %3
br label %32
30: ; preds = %22, %19
%31 = tail call i32 (...) @usage()
br label %32
32: ; preds = %18, %30, %25
%33 = phi i32 [ %12, %30 ], [ %23, %25 ], [ %12, %18 ]
%34 = add nsw i32 %33, 1
%35 = icmp slt i32 %34, %9
br i1 %35, label %11, label %36
36: ; preds = %32, %6, %8
ret void
}