#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ gt_abort(int /*<<< orphan*/ *);
int longvalue(char **, long *);
int /*<<< orphan*/ stderr;
void arg_int(char **ps, int *val, char *id) {
  int code;
  long longval;
  code = longvalue(ps, &longval);
  *val = longval;
  if (code == 1 || code == 3) {
    fprintf(stderr, ">E %s: missing argument value\n", id);
    gt_abort(NULL);
  } else if (code == 2 || *val != longval) {
    fprintf(stderr, ">E %s: argument value too large\n", id);
    gt_abort(NULL);
  }
}


x86 assembly (clang, -O0):
<arg_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1050 <longvalue@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x1,-0x1c(%rbp)
je     1174 <arg_int+0x44>
cmpl   $0x3,-0x1c(%rbp)
jne    119b <arg_int+0x6b>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe78(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1030 <gt_abort@plt>
jmp    11dd <arg_int+0xad>
cmpl   $0x2,-0x1c(%rbp)
je     11b6 <arg_int+0x86>
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
cmp    -0x28(%rbp),%rax
je     11d8 <arg_int+0xa8>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe55(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1030 <gt_abort@plt>
jmp    11dd <arg_int+0xad>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arg_int>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rsp,%rsi
call   1050 <longvalue@plt>
mov    (%rsp),%rcx
mov    %ecx,(%rbx)
mov    %eax,%edx
and    $0xfffffffd,%edx
cmp    $0x1,%edx
jne    1173 <arg_int+0x43>
lea    0xea7(%rip),%rsi
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rdx
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1030 <gt_abort@plt>
jmp    118c <arg_int+0x5c>
lea    0xea5(%rip),%rsi
cmp    $0x2,%eax
je     1159 <arg_int+0x29>
sub    $0xffffffff80000000,%rcx
shr    $0x20,%rcx
jne    1159 <arg_int+0x29>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c">E %s: missing argument value\0A\00"
@.str.1 = [33 x i8] c">E %s: argument value too large\0A\00"
define void @arg_int(i8** %0, i32* %1, i8* %2) {
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i64
store i8** %0, i8*** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
%9 = load i8**, i8*** %4
%10 = call i32 @longvalue(i8** %9, i64* %8)
store i32 %10, i32* %7
%11 = load i64, i64* %8
%12 = trunc i64 %11 to i32
%13 = load i32*, i32** %5
store i32 %12, i32* %13
%14 = load i32, i32* %7
%15 = icmp eq i32 %14, 1
br i1 %15, label %19, label %16
16: ; preds = %3
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 3
br i1 %18, label %19, label %24
19: ; preds = %16, %3
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %6
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i32 @gt_abort(i32* null)
br label %39
24: ; preds = %16
%25 = load i32, i32* %7
%26 = icmp eq i32 %25, 2
br i1 %26, label %33, label %27
27: ; preds = %24
%28 = load i32*, i32** %5
%29 = load i32, i32* %28
%30 = sext i32 %29 to i64
%31 = load i64, i64* %8
%32 = icmp ne i64 %30, %31
br i1 %32, label %33, label %38
33: ; preds = %27, %24
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %6
%36 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %35)
%37 = call i32 @gt_abort(i32* null)
br label %38
38: ; preds = %33, %27
br label %39
39: ; preds = %38, %19
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c">E %s: missing argument value\0A\00"
@.str.1 = [33 x i8] c">E %s: argument value too large\0A\00"
define void @arg_int(i8** %0, i32* nocapture writeonly %1, i8* %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
%6 = call i32 @longvalue(i8** %0, i64* %4)
%7 = load i64, i64* %4
%8 = trunc i64 %7 to i32
store i32 %8, i32* %1
%9 = and i32 %6, -3
%10 = icmp eq i32 %9, 1
br i1 %10, label %16, label %11
11: ; preds = %3
%12 = icmp ne i32 %6, 2
%13 = add i64 %7, 2147483648
%14 = icmp ult i64 %13, 4294967296
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %21, label %16
16: ; preds = %11, %3
%17 = phi i8* [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), %11 ]
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* %17, i8* %2)
%20 = call i32 @gt_abort(i32* null)
br label %21
21: ; preds = %16, %11
ret void
}