#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 IMB_str_atoi(char *);
int IMB_chk_arg_int(int *val, char ***argv, int *argc, int iarg) {
  int ok;
  ok = 1;
  if (iarg < *argc) {
    int tst = IMB_str_atoi((*argv)[iarg]);
    if (tst >= 0) {
      *val = tst;
    } else
      ok = 0;
  } else
    ok = 0;
  return ok;
}


x86 assembly (clang, -O0):
<IMB_chk_arg_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    1178 <IMB_chk_arg_int+0x68>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <IMB_str_atoi@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     116c <IMB_chk_arg_int+0x5c>
mov    -0x24(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    1173 <IMB_chk_arg_int+0x63>
movl   $0x0,-0x20(%rbp)
jmp    117f <IMB_chk_arg_int+0x6f>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IMB_chk_arg_int>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
cmp    %ecx,(%rdx)
jle    1138 <IMB_chk_arg_int+0x28>
mov    %rdi,%r14
mov    (%rsi),%rax
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <IMB_str_atoi@plt>
test   %eax,%eax
js     1138 <IMB_chk_arg_int+0x28>
mov    %eax,(%r14)
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @IMB_chk_arg_int(i32* nocapture writeonly %0, i8*** nocapture %1, i32* nocapture %2, i32 %3) {
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, %3
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = load i8**, i8*** %1
%9 = sext i32 %3 to i64
%10 = getelementptr inbounds i8*, i8** %8, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i32 @IMB_str_atoi(i8* %11)
%13 = icmp sgt i32 %12, -1
br i1 %13, label %14, label %15
14: ; preds = %7
store i32 %12, i32* %0
br label %15
15: ; preds = %4, %14, %7
%16 = phi i32 [ 1, %14 ], [ 0, %7 ], [ 0, %4 ]
ret i32 %16
}