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


x86 assembly (clang, -O0):
<arg_parse_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xeb9(%rip),%rcx
call   1030 <get_argv@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1194 <arg_parse_int+0x74>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1040 <str_2_int@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x2c(%rbp),%esi
mov    $0x1,%ecx
mov    $0xffffffff,%edx
cmp    $0x0,%esi
cmovne %edx,%ecx
imul   %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    119b <arg_parse_int+0x7b>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arg_parse_int>:
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edi,%ebx
lea    0xed0(%rip),%rcx
mov    %esi,%edi
mov    %rdx,%rsi
mov    %ebx,%edx
call   1030 <get_argv@plt>
test   %rax,%rax
je     115a <arg_parse_int+0x3a>
mov    %rax,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <str_2_int@plt>
lea    0x1(%rbx),%ecx
test   %eax,%eax
not    %ebx
cmove  %ecx,%ebx
jmp    115f <arg_parse_int+0x3f>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"int\00"
define i32 @arg_parse_int(i32 %0, i32 %1, i8** %2, i32* %3) {
%5 = tail call i8* @get_argv(i32 %1, i8** %2, i32 %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = tail call i32 @str_2_int(i8* %5, i32* %3, i32 0)
%9 = add nsw i32 %0, 1
%10 = icmp eq i32 %8, 0
%11 = xor i32 %0, -1
%12 = select i1 %10, i32 %9, i32 %11
br label %13
13: ; preds = %4, %7
%14 = phi i32 [ %12, %7 ], [ -1, %4 ]
ret i32 %14
}