#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*/ del_arg(int, char **, int);
scalar_t__ strcmp(char *, char *);
int find_int_arg(int argc, char **argv, char *arg, int def) {
  int i;
  for (i = 0; i < argc - 1; ++i) {
    if (!argv[i])
      continue;
    if (0 == strcmp(argv[i], arg)) {
      def = atoi(argv[i + 1]);
      del_arg(argc, argv, i);
      del_arg(argc, argv, i);
      break;
    }
  }
  return def;
}


x86 assembly (clang, -O0):
<find_int_arg>:
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   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11e8 <find_int_arg+0xb8>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1176 <find_int_arg+0x46>
jmp    11da <find_int_arg+0xaa>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11d5 <find_int_arg+0xa5>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1040 <del_arg@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1040 <del_arg@plt>
jmp    11e8 <find_int_arg+0xb8>
jmp    11da <find_int_arg+0xaa>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114d <find_int_arg+0x1d>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_int_arg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
cmp    $0x2,%edi
jl     11a9 <find_int_arg+0x79>
mov    %rdx,%r13
mov    %rsi,%r15
mov    %edi,%r14d
lea    -0x1(%r14),%ebp
xor    %ebx,%ebx
jmp    1169 <find_int_arg+0x39>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%rbp
je     11a9 <find_int_arg+0x79>
mov    (%r15,%rbx,8),%rdi
test   %rdi,%rdi
je     1160 <find_int_arg+0x30>
mov    %r13,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1160 <find_int_arg+0x30>
mov    0x8(%r15,%rbx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    %r14d,%edi
mov    %r15,%rsi
mov    %ebx,%edx
call   1040 <del_arg@plt>
mov    %r14d,%edi
mov    %r15,%rsi
mov    %ebx,%edx
call   1040 <del_arg@plt>
mov    %ebp,%eax
jmp    11ac <find_int_arg+0x7c>
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @find_int_arg(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 0, i32* %9
br label %10
10: ; preds = %49, %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 %52
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 = icmp ne i8* %20, null
br i1 %21, label %23, label %22
22: ; preds = %15
br label %49
23: ; preds = %15
%24 = load i8**, i8*** %6
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = load i8*, i8** %7
%30 = call i64 @strcmp(i8* %28, i8* %29)
%31 = icmp eq i64 0, %30
br i1 %31, label %32, label %48
32: ; preds = %23
%33 = load i8**, i8*** %6
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %33, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @atoi(i8* %38)
store i32 %39, i32* %8
%40 = load i32, i32* %5
%41 = load i8**, i8*** %6
%42 = load i32, i32* %9
%43 = call i32 @del_arg(i32 %40, i8** %41, i32 %42)
%44 = load i32, i32* %5
%45 = load i8**, i8*** %6
%46 = load i32, i32* %9
%47 = call i32 @del_arg(i32 %44, i8** %45, i32 %46)
br label %52
48: ; preds = %23
br label %49
49: ; preds = %48, %22
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
br label %10
52: ; preds = %32, %10
%53 = load i32, i32* %8
ret i32 %53
}

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