#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 */
char *get_argv(int, char **, int, char *);
int arg_parse_str(int i, int argc, char *argv[], char **p) {
  char *arg = get_argv(argc, argv, i, "string");
  ;
  *p = arg ? arg : 0;
  return arg ? ++i : -1;
}


x86 assembly (clang, -O0):
<arg_parse_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x4(%rbp),%edx
lea    0xec9(%rip),%rcx
call   1030 <get_argv@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1158 <arg_parse_str+0x48>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1163 <arg_parse_str+0x53>
xor    %eax,%eax
mov    %rax,-0x28(%rbp)
jmp    1163 <arg_parse_str+0x53>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x20(%rbp)
je     118a <arg_parse_str+0x7a>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    %eax,-0x2c(%rbp)
jmp    1197 <arg_parse_str+0x87>
mov    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    1197 <arg_parse_str+0x87>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arg_parse_str>:
push   %rbp
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %edi,%ebp
lea    0xee1(%rip),%rcx
mov    %esi,%edi
mov    %rdx,%rsi
mov    %ebp,%edx
call   1030 <get_argv@plt>
mov    %rax,(%rbx)
add    $0x1,%ebp
cmp    $0x1,%rax
sbb    %eax,%eax
or     %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"string\00"
define i32 @arg_parse_str(i32 %0, i32 %1, i8** %2, i8** %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i8** %3, i8*** %8
%10 = load i32, i32* %6
%11 = load i8**, i8*** %7
%12 = load i32, i32* %5
%13 = call i8* @get_argv(i32 %10, i8** %11, i32 %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %9
%14 = load i8*, i8** %9
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %4
%17 = load i8*, i8** %9
br label %19
18: ; preds = %4
br label %19
19: ; preds = %18, %16
%20 = phi i8* [ %17, %16 ], [ null, %18 ]
%21 = load i8**, i8*** %8
store i8* %20, i8** %21
%22 = load i8*, i8** %9
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %28
27: ; preds = %19
br label %28
28: ; preds = %27, %24
%29 = phi i32 [ %26, %24 ], [ -1, %27 ]
ret i32 %29
}

LLVM IR (-O2):
@.str = [7 x i8] c"string\00"
define i32 @arg_parse_str(i32 %0, i32 %1, i8** %2, i8** nocapture writeonly %3) {
%5 = tail call i8* @get_argv(i32 %1, i8** %2, i32 %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
store i8* %5, i8** %3
%7 = add nsw i32 %0, 1
%8 = select i1 %6, i32 -1, i32 %7
ret i32 %8
}