#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*/ exit(int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(char const *, char *);
int isoptarg(const char *opt1, const char *opt2, int argc, char **argv,
             int *i) {
  if ((strcmp(opt1, argv[*i]) == 0) || (strcmp(opt2, argv[*i]) == 0)) {
    if ((*i + 1) < argc) {
      *i = *i + 1;
      return 1;
    } else {
      printf("missing argument for: %s\n", argv[*i]);
      exit(1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<isoptarg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     118f <isoptarg+0x5f>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11e1 <isoptarg+0xb1>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
cmp    -0x1c(%rbp),%eax
jge    11bc <isoptarg+0x8c>
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11e8 <isoptarg+0xb8>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isoptarg>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8,%rbx
mov    %rcx,%r14
mov    %edx,%r15d
mov    %rsi,%rbp
movslq (%r8),%rax
mov    (%rcx,%rax,8),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     116d <isoptarg+0x3d>
movslq (%rbx),%rax
mov    (%r14,%rax,8),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    117f <isoptarg+0x4f>
movslq (%rbx),%rax
lea    0x1(%rax),%ecx
cmp    %r15d,%ecx
jge    118a <isoptarg+0x5a>
mov    %ecx,(%rbx)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r14,%rax,8),%rsi
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"missing argument for: %s\0A\00"
define i32 @isoptarg(i8* %0, i8* %1, i32 %2, i8** %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i32*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i8** %3, i8*** %10
store i32* %4, i32** %11
%12 = load i8*, i8** %7
%13 = load i8**, i8*** %10
%14 = load i32*, i32** %11
%15 = load i32, i32* %14
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %13, i64 %16
%18 = load i8*, i8** %17
%19 = call i64 @strcmp(i8* %12, i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %31, label %21
21: ; preds = %5
%22 = load i8*, i8** %8
%23 = load i8**, i8*** %10
%24 = load i32*, i32** %11
%25 = load i32, i32* %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %23, i64 %26
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %22, i8* %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %51
31: ; preds = %21, %5
%32 = load i32*, i32** %11
%33 = load i32, i32* %32
%34 = add nsw i32 %33, 1
%35 = load i32, i32* %9
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %42
37: ; preds = %31
%38 = load i32*, i32** %11
%39 = load i32, i32* %38
%40 = add nsw i32 %39, 1
%41 = load i32*, i32** %11
store i32 %40, i32* %41
store i32 1, i32* %6
br label %52
42: ; preds = %31
%43 = load i8**, i8*** %10
%44 = load i32*, i32** %11
%45 = load i32, i32* %44
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %43, i64 %46
%48 = load i8*, i8** %47
%49 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %48)
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %21
store i32 0, i32* %6
br label %52
52: ; preds = %51, %37
%53 = load i32, i32* %6
ret i32 %53
}

LLVM IR (-O2):
@.str = [26 x i8] c"missing argument for: %s\0A\00"
define i32 @isoptarg(i8* %0, i8* %1, i32 %2, i8** nocapture %3, i32* nocapture %4) {
%6 = load i32, i32* %4
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8*, i8** %3, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %0, i8* %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %5
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %3, i64 %14
%16 = load i8*, i8** %15
%17 = tail call i64 @strcmp(i8* %1, i8* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %12, %5
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
%22 = icmp slt i32 %21, %2
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 %21, i32* %4
br label %30
24: ; preds = %19
%25 = sext i32 %20 to i64
%26 = getelementptr inbounds i8*, i8** %3, i64 %25
%27 = load i8*, i8** %26
%28 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %12, %23
%31 = phi i32 [ 1, %23 ], [ 0, %12 ]
ret i32 %31
}