#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 const *);
int /*<<< orphan*/ clParseError(int, char **, int, char *);
int strcasecmp(char const *, char const *);
int readOptionInt(int argc, char **argv, int *i, char const *opt, int *arg) {
  int tmp;
  {
    if (*i < argc) {
      tmp = strcasecmp((char const *)*(argv + *i), opt);
      if (tmp == 0) {
        (*i)++;
        if (*i < argc) {
          *arg = atoi((char const *)*(argv + *i));
          return (1);
        } else {
          clParseError(argc, argv, *i, (char *)"Option expects one argument");
        }
        return (0);
      }
    } else {
      clParseError(argc, argv, *i, (char *)"Error parsing command line.");
    }
    return (0);
  }
}


x86 assembly (clang, -O0):
<readOptionInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    11eb <readOptionInt+0xbb>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcasecmp@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    11e6 <readOptionInt+0xb6>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    11c1 <readOptionInt+0x91>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    120b <readOptionInt+0xdb>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe2b(%rip),%rcx
call   1040 <clParseError@plt>
movl   $0x0,-0x4(%rbp)
jmp    120b <readOptionInt+0xdb>
jmp    1204 <readOptionInt+0xd4>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe1d(%rip),%rcx
call   1040 <clParseError@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readOptionInt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
movslq (%rdx),%rbx
cmp    %edi,%ebx
jge    1180 <readOptionInt+0x50>
mov    %r8,%r14
mov    %rdx,%r13
mov    (%r15,%rbx,8),%rdi
mov    %rcx,%rsi
call   1030 <strcasecmp@plt>
xor    %r12d,%r12d
test   %eax,%eax
jne    1196 <readOptionInt+0x66>
lea    0x1(%rbx),%edx
mov    %edx,0x0(%r13)
cmp    %ebp,%edx
jge    11a8 <readOptionInt+0x78>
mov    0x8(%r15,%rbx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,(%r14)
mov    $0x1,%r12d
jmp    1196 <readOptionInt+0x66>
lea    0xe95(%rip),%rcx
mov    %ebp,%edi
mov    %r15,%rsi
mov    %ebx,%edx
call   1040 <clParseError@plt>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe51(%rip),%rcx
mov    %ebp,%edi
mov    %r15,%rsi
call   1040 <clParseError@plt>
jmp    1196 <readOptionInt+0x66>

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

LLVM IR (-O2):
@.str = [28 x i8] c"Option expects one argument\00"
@.str.1 = [28 x i8] c"Error parsing command line.\00"
define i32 @readOptionInt(i32 %0, i8** %1, i32* nocapture %2, i8* nocapture %3, i32* nocapture writeonly %4) {
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, %0
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = sext i32 %6 to i64
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i32 @strcasecmp(i8* %11, i8* %3)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %26
14: ; preds = %8
%15 = add nsw i32 %6, 1
store i32 %15, i32* %2
%16 = icmp slt i32 %15, %0
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = sext i32 %15 to i64
%19 = getelementptr inbounds i8*, i8** %1, i64 %18
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
store i32 %21, i32* %4
br label %26
22: ; preds = %14
%23 = tail call i32 @clParseError(i32 %0, i8** %1, i32 %15, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %26
24: ; preds = %5
%25 = tail call i32 @clParseError(i32 %0, i8** %1, i32 %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %8, %22, %17
%27 = phi i32 [ 1, %17 ], [ 0, %22 ], [ 0, %8 ], [ 0, %24 ]
ret i32 %27
}