#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*/ stderr;
char cmd_chkopt(int argc, char **argv, int *idx, char opt) {
  if (*idx < argc && argv[*idx][0] != '-') {
    (*idx)++;
    return 0;
  } else {
    if (opt != 0)
      fprintf(stderr, "\n\nMissing argument to -%c option!\n", opt);
    return 1;
  }
}


x86 assembly (clang, -O0):
<cmd_chkopt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1166 <cmd_chkopt+0x56>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     1166 <cmd_chkopt+0x56>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movb   $0x0,-0x1(%rbp)
jmp    1190 <cmd_chkopt+0x80>
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
je     118c <cmd_chkopt+0x7c>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xe7d(%rip),%rsi
movsbl -0x19(%rbp),%edx
call   1030 <fprintf@plt>
movb   $0x1,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_chkopt>:
push   %rbx
movslq (%rdx),%rax
cmp    %edi,%eax
jge    1121 <cmd_chkopt+0x11>
mov    (%rsi,%rax,8),%rsi
cmpb   $0x2d,(%rsi)
jne    1141 <cmd_chkopt+0x31>
mov    $0x1,%bl
test   %cl,%cl
je     1148 <cmd_chkopt+0x38>
mov    0x2eb2(%rip),%rax
mov    (%rax),%edi
movsbl %cl,%edx
lea    0xec6(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1148 <cmd_chkopt+0x38>
add    $0x1,%eax
mov    %eax,(%rdx)
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"\0A\0AMissing argument to -%c option!\0A\00"
define signext i8 @cmd_chkopt(i32 %0, i8** %1, i32* %2, i8 signext %3) {
%5 = alloca i8
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i8
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i32* %2, i32** %8
store i8 %3, i8* %9
%10 = load i32*, i32** %8
%11 = load i32, i32* %10
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %29
14: ; preds = %4
%15 = load i8**, i8*** %7
%16 = load i32*, i32** %8
%17 = load i32, i32* %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %15, i64 %18
%20 = load i8*, i8** %19
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 45
br i1 %24, label %25, label %29
25: ; preds = %14
%26 = load i32*, i32** %8
%27 = load i32, i32* %26
%28 = add nsw i32 %27, 1
store i32 %28, i32* %26
store i8 0, i8* %5
br label %38
29: ; preds = %14, %4
%30 = load i8, i8* %9
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = load i8, i8* %9
%36 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8 signext %35)
br label %37
37: ; preds = %33, %29
store i8 1, i8* %5
br label %38
38: ; preds = %37, %25
%39 = load i8, i8* %5
ret i8 %39
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"\0A\0AMissing argument to -%c option!\0A\00"
define signext i8 @cmd_chkopt(i32 %0, i8** nocapture %1, i32* nocapture %2, i8 signext %3) {
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, %0
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = sext i32 %5 to i64
%9 = getelementptr inbounds i8*, i8** %1, i64 %8
%10 = load i8*, i8** %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 45
br i1 %12, label %15, label %13
13: ; preds = %7
%14 = add nsw i32 %5, 1
store i32 %14, i32* %2
br label %20
15: ; preds = %7, %4
%16 = icmp eq i8 %3, 0
br i1 %16, label %20, label %17
17: ; preds = %15
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8 signext %3)
br label %20
20: ; preds = %15, %17, %13
%21 = phi i8 [ 0, %13 ], [ 1, %17 ], [ 1, %15 ]
ret i8 %21
}