#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 *);
scalar_t__ strcmp(char *, char *);
int getMaxNumReactions(int argc, char *argv[]) {
  int argNum = 0;
  for (argNum = 0; argNum != argc; ++argNum) {
    if (strcmp(argv[argNum], "-r") == 0 && argNum + 1 <= argc - 1) {
      int maxRxns = atoi(argv[argNum + 1]);
      return maxRxns;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<getMaxNumReactions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     11b6 <getMaxNumReactions+0x96>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xea4(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a3 <getMaxNumReactions+0x83>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     11a3 <getMaxNumReactions+0x83>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11bd <getMaxNumReactions+0x9d>
jmp    11a8 <getMaxNumReactions+0x88>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <getMaxNumReactions+0x1d>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMaxNumReactions>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edi,%edi
je     1182 <getMaxNumReactions+0x62>
mov    %rsi,%r12
lea    -0x1(%rdi),%eax
movslq %eax,%r15
mov    %edi,%r13d
xor    %ebx,%ebx
lea    0xebe(%rip),%r14
jmp    1159 <getMaxNumReactions+0x39>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r13
je     1182 <getMaxNumReactions+0x62>
mov    (%r12,%rbx,8),%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1150 <getMaxNumReactions+0x30>
cmp    %r15,%rbx
jge    1150 <getMaxNumReactions+0x30>
mov    0x8(%r12,%rbx,8),%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <atoi@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-r\00"
define i32 @getMaxNumReactions(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %6
br label %8
8: ; preds = %36, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %4
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %39
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %35
20: ; preds = %12
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
%23 = load i32, i32* %4
%24 = sub nsw i32 %23, 1
%25 = icmp sle i32 %22, %24
br i1 %25, label %26, label %35
26: ; preds = %20
%27 = load i8**, i8*** %5
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %27, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %7
%34 = load i32, i32* %7
store i32 %34, i32* %3
br label %40
35: ; preds = %20, %12
br label %36
36: ; preds = %35
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %8
39: ; preds = %8
store i32 -1, i32* %3
br label %40
40: ; preds = %39, %26
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [3 x i8] c"-r\00"
define i32 @getMaxNumReactions(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %24, label %4
4: ; preds = %2
%5 = add nsw i32 %0, -1
%6 = sext i32 %5 to i64
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %4, %22
%9 = phi i64 [ 0, %4 ], [ %16, %22 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
%14 = icmp slt i64 %9, %6
%15 = select i1 %13, i1 %14, i1 false
%16 = add nuw nsw i64 %9, 1
br i1 %15, label %17, label %22
17: ; preds = %8
%18 = and i64 %16, 4294967295
%19 = getelementptr inbounds i8*, i8** %1, i64 %18
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
br label %24
22: ; preds = %8
%23 = icmp eq i64 %16, %7
br i1 %23, label %24, label %8
24: ; preds = %22, %2, %17
%25 = phi i32 [ %21, %17 ], [ -1, %2 ], [ -1, %22 ]
ret i32 %25
}