#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 */
scalar_t__ argcmpTestOptions(char *, char *);
char *assert_malloc(scalar_t__);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int argcmpass(char *options, const int argc, char *argv[], int *argindex,
              char **dest) {
  char *opts = assert_malloc(strlen(options) + 1);
  strcpy(opts, options);
  if (argcmpTestOptions(argv[*argindex], opts)) {
    if (*argindex >= argc - 1) {
      fprintf(stderr,
              "error: Invalid argument, expected value after option \"%s\"\n",
              options);
      exit(1);
    }
    (*argindex)++;
    if (strcmp("NULL", argv[*argindex]) != 0)
      *dest = argv[*argindex];
    else
      *dest = NULL;
    return 1;
  } else
    return 0;
}


x86 assembly (clang, -O0):
<argcmpass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1060 <assert_malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <argcmpTestOptions@plt>
cmp    $0x0,%rax
je     126c <argcmpass+0xfc>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     120a <argcmpass+0x9a>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe05(%rip),%rsi
call   1080 <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),%rsi
lea    0xe10(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1255 <argcmpass+0xe5>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
jmp    1260 <argcmpass+0xf0>
mov    -0x30(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1273 <argcmpass+0x103>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<argcmpass>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r13
mov    %rdx,%r15
mov    %esi,%ebp
mov    %rdi,%r12
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1060 <assert_malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
movslq 0x0(%r13),%rax
mov    (%r15,%rax,8),%rdi
mov    %rbx,%rsi
call   1050 <argcmpTestOptions@plt>
test   %rax,%rax
je     11ed <argcmpass+0x7d>
movslq 0x0(%r13),%rax
add    $0xffffffff,%ebp
cmp    %ebp,%eax
jge    120a <argcmpass+0x9a>
lea    0x1(%rax),%rcx
mov    %ecx,0x0(%r13)
mov    0x8(%r15,%rax,8),%rsi
lea    0xe62(%rip),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11f1 <argcmpass+0x81>
movslq 0x0(%r13),%rax
mov    (%r15,%rax,8),%rax
jmp    11f3 <argcmpass+0x83>
xor    %eax,%eax
jmp    11fb <argcmpass+0x8b>
xor    %eax,%eax
mov    %rax,(%r14)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
lea    0xde6(%rip),%rsi
mov    %r12,%rdx
call   1080 <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"
@.str.1 = [5 x i8] c"NULL\00"
define i32 @argcmpass(i8* %0, i32 %1, i8** %2, i32* %3, i8** %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32*
%11 = alloca i8**
%12 = alloca i8*
store i8* %0, i8** %7
store i32 %1, i32* %8
store i8** %2, i8*** %9
store i32* %3, i32** %10
store i8** %4, i8*** %11
%13 = load i8*, i8** %7
%14 = call i64 @strlen(i8* %13)
%15 = add nsw i64 %14, 1
%16 = call i8* @assert_malloc(i64 %15)
store i8* %16, i8** %12
%17 = load i8*, i8** %12
%18 = load i8*, i8** %7
%19 = call i32 @strcpy(i8* %17, i8* %18)
%20 = load i8**, i8*** %9
%21 = load i32*, i32** %10
%22 = load i32, i32* %21
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %20, i64 %23
%25 = load i8*, i8** %24
%26 = load i8*, i8** %12
%27 = call i64 @argcmpTestOptions(i8* %25, i8* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %63
29: ; preds = %5
%30 = load i32*, i32** %10
%31 = load i32, i32* %30
%32 = load i32, i32* %8
%33 = sub nsw i32 %32, 1
%34 = icmp sge i32 %31, %33
br i1 %34, label %35, label %40
35: ; preds = %29
%36 = load i32, i32* @stderr
%37 = load i8*, i8** %7
%38 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %37)
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %29
%41 = load i32*, i32** %10
%42 = load i32, i32* %41
%43 = add nsw i32 %42, 1
store i32 %43, i32* %41
%44 = load i8**, i8*** %9
%45 = load i32*, i32** %10
%46 = load i32, i32* %45
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %44, i64 %47
%49 = load i8*, i8** %48
%50 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %60
52: ; preds = %40
%53 = load i8**, i8*** %9
%54 = load i32*, i32** %10
%55 = load i32, i32* %54
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %53, i64 %56
%58 = load i8*, i8** %57
%59 = load i8**, i8*** %11
store i8* %58, i8** %59
br label %62
60: ; preds = %40
%61 = load i8**, i8*** %11
store i8* null, i8** %61
br label %62
62: ; preds = %60, %52
store i32 1, i32* %6
br label %64
63: ; preds = %5
store i32 0, i32* %6
br label %64
64: ; preds = %63, %62
%65 = load i32, i32* %6
ret i32 %65
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [59 x i8] c"error: Invalid argument, expected value after option \22%s\22\0A\00"
@.str.1 = [5 x i8] c"NULL\00"
define i32 @argcmpass(i8* %0, i32 %1, i8** nocapture %2, i32* nocapture %3, i8** nocapture writeonly %4) {
%6 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%7 = add nsw i64 %6, 1
%8 = tail call i8* @assert_malloc(i64 %7)
%9 = tail call i32 @strcpy(i8* %8, i8* %0)
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8*, i8** %2, i64 %11
%13 = load i8*, i8** %12
%14 = tail call i64 @argcmpTestOptions(i8* %13, i8* %8)
%15 = icmp eq i64 %14, 0
br i1 %15, label %38, label %16
16: ; preds = %5
%17 = load i32, i32* %3
%18 = add nsw i32 %1, -1
%19 = icmp slt i32 %17, %18
br i1 %19, label %24, label %20
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %0)
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %16
%25 = add nsw i32 %17, 1
store i32 %25, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %2, i64 %26
%28 = load i8*, i8** %27
%29 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %36, label %31
31: ; preds = %24
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %2, i64 %33
%35 = load i8*, i8** %34
br label %36
36: ; preds = %24, %31
%37 = phi i8* [ %35, %31 ], [ null, %24 ]
store i8* %37, i8** %4
br label %38
38: ; preds = %5, %36
%39 = phi i32 [ 1, %36 ], [ 0, %5 ]
ret i32 %39
}