#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*/ carp(char *, char *, char *);
int check_opt(char **argv, char **opt) {
  if (argv[0][2]) {
    *opt = argv[0] + 2;
    return 0;
  } else if (argv[1]) {
    *opt = argv[1];
    return 1;
  }
  carp("Option ", argv[0], " requires an argument");
  _exit(1);
}


x86 assembly (clang, -O0):
<check_opt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmpb   $0x0,0x2(%rax)
je     115f <check_opt+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x2,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11b2 <check_opt+0x92>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1189 <check_opt+0x69>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11b2 <check_opt+0x92>
jmp    118e <check_opt+0x6e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe64(%rip),%rdi
lea    0xe65(%rip),%rdx
call   1040 <carp@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_opt>:
push   %rax
mov    (%rdi),%rcx
cmpb   $0x0,0x2(%rcx)
je     1135 <check_opt+0x15>
add    $0x2,%rcx
xor    %eax,%eax
mov    %rcx,%rdx
jmp    1143 <check_opt+0x23>
mov    0x8(%rdi),%rdx
mov    $0x1,%eax
test   %rdx,%rdx
je     1148 <check_opt+0x28>
mov    %rdx,(%rsi)
pop    %rcx
ret
lea    0xeb1(%rip),%rdi
lea    0xeb2(%rip),%rdx
mov    %rcx,%rsi
call   1040 <carp@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"Option \00"
@.str.1 = [22 x i8] c" requires an argument\00"
define i32 @check_opt(i8** %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8**
store i8** %0, i8*** %4
store i8** %1, i8*** %5
%6 = load i8**, i8*** %4
%7 = getelementptr inbounds i8*, i8** %6, i64 0
%8 = load i8*, i8** %7
%9 = getelementptr inbounds i8, i8* %8, i64 2
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8, i8* %15, i64 2
%17 = load i8**, i8*** %5
store i8* %16, i8** %17
store i32 0, i32* %3
br label %35
18: ; preds = %2
%19 = load i8**, i8*** %4
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = load i8**, i8*** %4
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = load i8**, i8*** %5
store i8* %26, i8** %27
store i32 1, i32* %3
br label %35
28: ; preds = %18
br label %29
29: ; preds = %28
%30 = load i8**, i8*** %4
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = call i32 @carp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %32, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%34 = call i32 @_exit(i32 1)
unreachable
35: ; preds = %23, %12
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [8 x i8] c"Option \00"
@.str.1 = [22 x i8] c" requires an argument\00"
define i32 @check_opt(i8** nocapture %0, i8** nocapture writeonly %1) {
%3 = load i8*, i8** %0
%4 = getelementptr inbounds i8, i8* %3, i64 2
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %0, i64 1
%9 = load i8*, i8** %8
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = tail call i32 @carp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %3, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @_exit(i32 1)
unreachable
14: ; preds = %7, %2
%15 = phi i8* [ %4, %2 ], [ %9, %7 ]
%16 = phi i32 [ 0, %2 ], [ 1, %7 ]
store i8* %15, i8** %1
ret i32 %16
}