#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 find_arg(int, char **, char *);
char *find_arg_str(int argc, char *argv[], char *key, char *def) {
  int i = find_arg(argc, argv, key);
  return (i > 0 && i < argc - 1) ? argv[i + 1] : def;
}


x86 assembly (clang, -O0):
<find_arg_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <find_arg@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    116f <find_arg_str+0x5f>
mov    -0x24(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    116f <find_arg_str+0x5f>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
jmp    1177 <find_arg_str+0x67>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_arg_str>:
push   %rbp
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
call   1030 <find_arg@plt>
test   %eax,%eax
jle    1133 <find_arg_str+0x23>
add    $0xffffffff,%ebp
cmp    %ebp,%eax
jge    1133 <find_arg_str+0x23>
mov    %eax,%eax
mov    0x8(%rbx,%rax,8),%r14
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @find_arg_str(i32 %0, i8** %1, i8* %2, i8* readnone %3) {
%5 = tail call i32 @find_arg(i32 %0, i8** %1, i8* %2)
%6 = icmp sgt i32 %5, 0
%7 = add nsw i32 %0, -1
%8 = icmp slt i32 %5, %7
%9 = select i1 %6, i1 %8, i1 false
br i1 %9, label %10, label %15
10: ; preds = %4
%11 = add nuw nsw i32 %5, 1
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
br label %15
15: ; preds = %4, %10
%16 = phi i8* [ %14, %10 ], [ %3, %4 ]
ret i8* %16
}