#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 */
long INT_MIN;
long LONG_MAX;
scalar_t__ argcmpTestOptions(char *, char *);
char *assert_malloc(scalar_t__);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
long strtol(char *, char **, int /*<<< orphan*/);
int argcmpassint(char *options, const int argc, char *argv[], int *argindex,
                 int *dest) {
  char *opt = argv[*argindex];
  char *opts = assert_malloc(strlen(options) + 1);
  strcpy(opts, options);
  if (argcmpTestOptions(opt, opts)) {
    if (*argindex >= argc - 1) {
      fprintf(stderr,
              "error: Invalid argument, expected value after option \"%s\"\n",
              options);
      exit(1);
    }
    (*argindex)++;
    char *endptr, *value = argv[*argindex];
    long parsed = strtol(value, &endptr, 0);
    if (parsed < INT_MIN) {
      fprintf(stderr, "error: Value of option \"%s\" is too small.\n", opt);
      exit(1);
    } else if (parsed == LONG_MAX) {
      fprintf(stderr, "error: Value of option \"%s\" is too big.\n", opt);
      exit(1);
    } else if (value == endptr) {
      fprintf(stderr, "error: Invalid number in option \"%s\".\n", opt);
      exit(1);
    } else
      *dest = (int)parsed;
    return 1;
  } else
    return 0;
}


x86 assembly (clang, -O0):
<argcmpassint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1060 <assert_malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1050 <argcmpTestOptions@plt>
cmp    $0x0,%rax
je     1304 <argcmpassint+0x194>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     1212 <argcmpassint+0xa2>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xdfd(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x48(%rbp),%rsi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    0x2d9a(%rip),%rcx
cmp    (%rcx),%rax
jge    127a <argcmpassint+0x10a>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xdd0(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x58(%rbp),%rax
mov    0x2d4b(%rip),%rcx
cmp    (%rcx),%rax
jne    12b1 <argcmpassint+0x141>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xdc4(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x50(%rbp),%rax
cmp    -0x48(%rbp),%rax
jne    12e2 <argcmpassint+0x172>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xdbc(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x58(%rbp),%rax
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
jmp    12f3 <argcmpassint+0x183>
jmp    12f8 <argcmpassint+0x188>
movl   $0x1,-0x4(%rbp)
jmp    130b <argcmpassint+0x19b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<argcmpassint>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,0x8(%rsp)
mov    %rcx,%rbx
mov    %rdx,%r12
mov    %esi,%ebp
mov    %rdi,%r13
movslq (%rcx),%rax
mov    (%rdx,%rax,8),%r15
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1060 <assert_malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <argcmpTestOptions@plt>
test   %rax,%rax
je     1212 <argcmpassint+0xa2>
movslq (%rbx),%rax
add    $0xffffffff,%ebp
cmp    %ebp,%eax
jge    1223 <argcmpassint+0xb3>
lea    0x1(%rax),%rcx
mov    %ecx,(%rbx)
mov    0x8(%r12,%rax,8),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    0x2dfc(%rip),%rcx
cmp    (%rcx),%rax
jl     1238 <argcmpassint+0xc8>
mov    0x2dd8(%rip),%rcx
cmp    (%rcx),%rax
je     124a <argcmpassint+0xda>
cmp    0x10(%rsp),%rbx
je     125c <argcmpassint+0xec>
mov    0x8(%rsp),%rcx
mov    %eax,(%rcx)
mov    $0x1,%eax
jmp    1214 <argcmpassint+0xa4>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
lea    0xdcd(%rip),%rsi
mov    %r13,%rdx
jmp    126f <argcmpassint+0xff>
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
lea    0xdf3(%rip),%rsi
jmp    126c <argcmpassint+0xfc>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
jmp    126c <argcmpassint+0xfc>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
lea    0xe23(%rip),%rsi
mov    %r15,%rdx
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [59 x i8] c"error: Invalid argument, expected value after option \22%s\22\0A\00"
@INT_MIN = global i64 0
@.str.1 = [43 x i8] c"error: Value of option \22%s\22 is too small.\0A\00"
@LONG_MAX = global i64 0
@.str.2 = [41 x i8] c"error: Value of option \22%s\22 is too big.\0A\00"
@.str.3 = [39 x i8] c"error: Invalid number in option \22%s\22.\0A\00"
define i32 @argcmpassint(i8* %0, i32 %1, i8** %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i64
store i8* %0, i8** %7
store i32 %1, i32* %8
store i8** %2, i8*** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
%17 = load i8**, i8*** %9
%18 = load i32*, i32** %10
%19 = load i32, i32* %18
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %17, i64 %20
%22 = load i8*, i8** %21
store i8* %22, i8** %12
%23 = load i8*, i8** %7
%24 = call i64 @strlen(i8* %23)
%25 = add nsw i64 %24, 1
%26 = call i8* @assert_malloc(i64 %25)
store i8* %26, i8** %13
%27 = load i8*, i8** %13
%28 = load i8*, i8** %7
%29 = call i32 @strcpy(i8* %27, i8* %28)
%30 = load i8*, i8** %12
%31 = load i8*, i8** %13
%32 = call i64 @argcmpTestOptions(i8* %30, i8* %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %90
34: ; preds = %5
%35 = load i32*, i32** %10
%36 = load i32, i32* %35
%37 = load i32, i32* %8
%38 = sub nsw i32 %37, 1
%39 = icmp sge i32 %36, %38
br i1 %39, label %40, label %45
40: ; preds = %34
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %7
%43 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %42)
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %34
%46 = load i32*, i32** %10
%47 = load i32, i32* %46
%48 = add nsw i32 %47, 1
store i32 %48, i32* %46
%49 = load i8**, i8*** %9
%50 = load i32*, i32** %10
%51 = load i32, i32* %50
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %49, i64 %52
%54 = load i8*, i8** %53
store i8* %54, i8** %15
%55 = load i8*, i8** %15
%56 = call i64 @strtol(i8* %55, i8** %14, i32 0)
store i64 %56, i64* %16
%57 = load i64, i64* %16
%58 = load i64, i64* @INT_MIN
%59 = icmp slt i64 %57, %58
br i1 %59, label %60, label %65
60: ; preds = %45
%61 = load i32, i32* @stderr
%62 = load i8*, i8** %12
%63 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %62)
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %45
%66 = load i64, i64* %16
%67 = load i64, i64* @LONG_MAX
%68 = icmp eq i64 %66, %67
br i1 %68, label %69, label %74
69: ; preds = %65
%70 = load i32, i32* @stderr
%71 = load i8*, i8** %12
%72 = call i32 @fprintf(i32 %70, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %71)
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %65
%75 = load i8*, i8** %15
%76 = load i8*, i8** %14
%77 = icmp eq i8* %75, %76
br i1 %77, label %78, label %83
78: ; preds = %74
%79 = load i32, i32* @stderr
%80 = load i8*, i8** %12
%81 = call i32 @fprintf(i32 %79, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %80)
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %74
%84 = load i64, i64* %16
%85 = trunc i64 %84 to i32
%86 = load i32*, i32** %11
store i32 %85, i32* %86
br label %87
87: ; preds = %83
br label %88
88: ; preds = %87
br label %89
89: ; preds = %88
store i32 1, i32* %6
br label %91
90: ; preds = %5
store i32 0, i32* %6
br label %91
91: ; preds = %90, %89
%92 = load i32, i32* %6
ret i32 %92
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [59 x i8] c"error: Invalid argument, expected value after option \22%s\22\0A\00"
@INT_MIN = global i64 0
@.str.1 = [43 x i8] c"error: Value of option \22%s\22 is too small.\0A\00"
@LONG_MAX = global i64 0
@.str.2 = [41 x i8] c"error: Value of option \22%s\22 is too big.\0A\00"
@.str.3 = [39 x i8] c"error: Invalid number in option \22%s\22.\0A\00"
define i32 @argcmpassint(i8* %0, i32 %1, i8** nocapture %2, i32* nocapture %3, i32* nocapture writeonly %4) {
%6 = alloca i8*
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8*, i8** %2, i64 %8
%10 = load i8*, i8** %9
%11 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%12 = add nsw i64 %11, 1
%13 = tail call i8* @assert_malloc(i64 %12)
%14 = tail call i32 @strcpy(i8* %13, i8* %0)
%15 = tail call i64 @argcmpTestOptions(i8* %10, i8* %13)
%16 = icmp eq i64 %15, 0
br i1 %16, label %54, label %17
17: ; preds = %5
%18 = load i32, i32* %3
%19 = add nsw i32 %1, -1
%20 = icmp slt i32 %18, %19
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %0)
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %17
%26 = add nsw i32 %18, 1
store i32 %26, i32* %3
%27 = bitcast i8** %6 to i8*
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds i8*, i8** %2, i64 %28
%30 = load i8*, i8** %29
%31 = call i64 @strtol(i8* %30, i8** %6, i32 0)
%32 = load i64, i64* @INT_MIN
%33 = icmp slt i64 %31, %32
br i1 %33, label %34, label %38
34: ; preds = %25
%35 = load i32, i32* @stderr
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%37 = tail call i32 @exit(i32 1)
unreachable
38: ; preds = %25
%39 = load i64, i64* @LONG_MAX
%40 = icmp eq i64 %31, %39
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = load i32, i32* @stderr
%43 = tail call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%44 = tail call i32 @exit(i32 1)
unreachable
45: ; preds = %38
%46 = load i8*, i8** %6
%47 = icmp eq i8* %30, %46
br i1 %47, label %48, label %52
48: ; preds = %45
%49 = load i32, i32* @stderr
%50 = tail call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%51 = tail call i32 @exit(i32 1)
unreachable
52: ; preds = %45
%53 = trunc i64 %31 to i32
store i32 %53, i32* %4
br label %54
54: ; preds = %5, %52
%55 = phi i32 [ 1, %52 ], [ 0, %5 ]
ret i32 %55
}