#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 *);
char *get_argv(int, char **, int, char *);
int arg_parse_ints(int i, int argc, char *argv[], int n, int *p[]) {
  int j;
  for (j = 0; j < n; ++j) {
    char *arg = get_argv(argc, argv, i, "int");
    ;
    if (arg) {
      *(p[j]) = atoi(arg);
      ++i;
    } else {
      return -1;
    }
  }
  return i;
}


x86 assembly (clang, -O0):
<arg_parse_ints>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11b7 <arg_parse_ints+0x97>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xea3(%rip),%rcx
call   1030 <get_argv@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1198 <arg_parse_ints+0x78>
mov    -0x38(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rdx
mov    (%rax,%rdx,8),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a4 <arg_parse_ints+0x84>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bd <arg_parse_ints+0x9d>
jmp    11a9 <arg_parse_ints+0x89>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1140 <arg_parse_ints+0x20>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arg_parse_ints>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%eax
test   %ecx,%ecx
jle    118f <arg_parse_ints+0x6f>
mov    %r8,%r15
mov    %rdx,%r13
mov    %esi,%ebx
mov    %ecx,%ebp
mov    %eax,0x4(%rsp)
mov    %eax,%r12d
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r12,%r14,1),%edx
mov    %ebx,%edi
mov    %r13,%rsi
lea    0xea0(%rip),%rcx
call   1030 <get_argv@plt>
test   %rax,%rax
je     118a <arg_parse_ints+0x6a>
mov    %rax,%rdi
call   1040 <atoi@plt>
mov    (%r15,%r14,8),%rcx
mov    %eax,(%rcx)
add    $0x1,%r14
cmp    %r14,%rbp
jne    1150 <arg_parse_ints+0x30>
mov    0x4(%rsp),%eax
add    %r14d,%eax
jmp    118f <arg_parse_ints+0x6f>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"int\00"
define i32 @arg_parse_ints(i32 %0, i32 %1, i8** %2, i32 %3, i32** %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i32**
%12 = alloca i32
%13 = alloca i8*
store i32 %0, i32* %7
store i32 %1, i32* %8
store i8** %2, i8*** %9
store i32 %3, i32* %10
store i32** %4, i32*** %11
store i32 0, i32* %12
br label %14
14: ; preds = %37, %5
%15 = load i32, i32* %12
%16 = load i32, i32* %10
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %40
18: ; preds = %14
%19 = load i32, i32* %8
%20 = load i8**, i8*** %9
%21 = load i32, i32* %7
%22 = call i8* @get_argv(i32 %19, i8** %20, i32 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %22, i8** %13
%23 = load i8*, i8** %13
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %35
25: ; preds = %18
%26 = load i8*, i8** %13
%27 = call i32 @atoi(i8* %26)
%28 = load i32**, i32*** %11
%29 = load i32, i32* %12
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32*, i32** %28, i64 %30
%32 = load i32*, i32** %31
store i32 %27, i32* %32
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %36
35: ; preds = %18
store i32 -1, i32* %6
br label %42
36: ; preds = %25
br label %37
37: ; preds = %36
%38 = load i32, i32* %12
%39 = add nsw i32 %38, 1
store i32 %39, i32* %12
br label %14
40: ; preds = %14
%41 = load i32, i32* %7
store i32 %41, i32* %6
br label %42
42: ; preds = %40, %35
%43 = load i32, i32* %6
ret i32 %43
}

LLVM IR (-O2):
@.str = [4 x i8] c"int\00"
define i32 @arg_parse_ints(i32 %0, i32 %1, i8** %2, i32 %3, i32** nocapture %4) {
%6 = icmp sgt i32 %3, 0
br i1 %6, label %7, label %21
7: ; preds = %5
%8 = zext i32 %3 to i64
br label %9
9: ; preds = %7, %14
%10 = phi i64 [ 0, %7 ], [ %19, %14 ]
%11 = phi i32 [ %0, %7 ], [ %18, %14 ]
%12 = tail call i8* @get_argv(i32 %1, i8** %2, i32 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i8* %12, null
br i1 %13, label %21, label %14
14: ; preds = %9
%15 = tail call i32 @atoi(i8* %12)
%16 = getelementptr inbounds i32*, i32** %4, i64 %10
%17 = load i32*, i32** %16
store i32 %15, i32* %17
%18 = add nsw i32 %11, 1
%19 = add nuw nsw i64 %10, 1
%20 = icmp eq i64 %19, %8
br i1 %20, label %21, label %9
21: ; preds = %14, %9, %5
%22 = phi i32 [ %0, %5 ], [ -1, %9 ], [ %18, %14 ]
ret i32 %22
}