#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 Scan_int(int argc, char **argv, char *flag, int value) {
  int i;
  for (i = 1; i < argc - 1; i++)
    if (strcmp(argv[i], flag) == 0)
      value = atoi(argv[i + 1]);
  return (value);
}


x86 assembly (clang, -O0):
<Scan_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1199 <Scan_int+0x79>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1186 <Scan_int+0x66>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    118b <Scan_int+0x6b>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113d <Scan_int+0x1d>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Scan_int>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
cmp    $0x3,%edi
jl     117d <Scan_int+0x5d>
mov    %rdx,%r15
mov    %rsi,%r13
mov    %edi,%r12d
add    $0xffffffff,%r12d
mov    $0x1,%ebx
jmp    1158 <Scan_int+0x38>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rbx
cmp    %rbp,%r12
je     117d <Scan_int+0x5d>
mov    0x0(%r13,%rbx,8),%rdi
mov    %r15,%rsi
call   1030 <strcmp@plt>
lea    0x1(%rbx),%rbp
test   %rax,%rax
jne    1150 <Scan_int+0x30>
mov    0x8(%r13,%rbx,8),%rdi
call   1040 <atoi@plt>
mov    %eax,%r14d
jmp    1150 <Scan_int+0x30>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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