#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*/ die(char *, char const *, char const *);
int strlen(char const *);
scalar_t__ strncmp(char *, char const *, int);
int get_test_opt(char **argref, const char *name, int *argi, int argc,
                 char *argv[], const char *expect_msg) {
  char *arg = *argref;
  int namelen = strlen(name);
  if (strncmp(arg, name, namelen))
    return 0;
  arg += namelen;
  if (*arg == '=') {
    (*argref) = arg + 1;
  } else if (!*arg) {
    (*argi)++;
    if ((*argi) >= argc)
      die("--%s expects %s", name, expect_msg);
    (*argref) = argv[(*argi)];
  } else {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<get_test_opt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x44(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     118c <get_test_opt+0x5c>
movl   $0x0,-0x4(%rbp)
jmp    122f <get_test_opt+0xff>
mov    -0x44(%rbp),%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
jne    11c1 <get_test_opt+0x91>
mov    -0x40(%rbp),%rcx
add    $0x1,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    1228 <get_test_opt+0xf8>
mov    -0x40(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1217 <get_test_opt+0xe7>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
cmp    -0x24(%rbp),%eax
jl     11fc <get_test_opt+0xcc>
mov    -0x18(%rbp),%rsi
mov    -0x38(%rbp),%rdx
lea    0xe09(%rip),%rdi
call   1050 <die@plt>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    1223 <get_test_opt+0xf3>
movl   $0x0,-0x4(%rbp)
jmp    122f <get_test_opt+0xff>
jmp    1228 <get_test_opt+0xf8>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_test_opt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x8(%rsp)
mov    %r8,0x10(%rsp)
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %rdi,%r13
mov    (%rdi),%rbx
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    11d6 <get_test_opt+0xa6>
mov    %r15d,%esi
mov    %r13,(%rsp)
mov    0x8(%rsp),%r13
mov    0x10(%rsp),%r15
movslq %r12d,%rcx
mov    (%rbx,%rcx,1),%dl
test   %dl,%dl
je     11a2 <get_test_opt+0x72>
cmp    $0x3d,%dl
jne    11d6 <get_test_opt+0xa6>
add    %rcx,%rbx
add    $0x1,%rbx
jmp    11ca <get_test_opt+0x9a>
mov    (%r14),%eax
add    $0x1,%eax
mov    %eax,(%r14)
cmp    %esi,%eax
jl     11c4 <get_test_opt+0x94>
lea    0xe4a(%rip),%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
call   1050 <die@plt>
mov    (%r14),%eax
cltq
mov    (%r15,%rax,8),%rbx
mov    (%rsp),%rax
mov    %rbx,(%rax)
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"--%s expects %s\00"
define i32 @get_test_opt(i8** %0, i8* %1, i32* %2, i32 %3, i8** %4, i8* %5) {
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i8**
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32
store i8** %0, i8*** %8
store i8* %1, i8** %9
store i32* %2, i32** %10
store i32 %3, i32* %11
store i8** %4, i8*** %12
store i8* %5, i8** %13
%16 = load i8**, i8*** %8
%17 = load i8*, i8** %16
store i8* %17, i8** %14
%18 = load i8*, i8** %9
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %15
%20 = load i8*, i8** %14
%21 = load i8*, i8** %9
%22 = load i32, i32* %15
%23 = call i64 @strncmp(i8* %20, i8* %21, i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %6
store i32 0, i32* %7
br label %66
26: ; preds = %6
%27 = load i32, i32* %15
%28 = load i8*, i8** %14
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds i8, i8* %28, i64 %29
store i8* %30, i8** %14
%31 = load i8*, i8** %14
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 61
br i1 %34, label %35, label %39
35: ; preds = %26
%36 = load i8*, i8** %14
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = load i8**, i8*** %8
store i8* %37, i8** %38
br label %65
39: ; preds = %26
%40 = load i8*, i8** %14
%41 = load i8, i8* %40
%42 = icmp ne i8 %41, 0
br i1 %42, label %63, label %43
43: ; preds = %39
%44 = load i32*, i32** %10
%45 = load i32, i32* %44
%46 = add nsw i32 %45, 1
store i32 %46, i32* %44
%47 = load i32*, i32** %10
%48 = load i32, i32* %47
%49 = load i32, i32* %11
%50 = icmp sge i32 %48, %49
br i1 %50, label %51, label %55
51: ; preds = %43
%52 = load i8*, i8** %9
%53 = load i8*, i8** %13
%54 = call i32 @die(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %52, i8* %53)
br label %55
55: ; preds = %51, %43
%56 = load i8**, i8*** %12
%57 = load i32*, i32** %10
%58 = load i32, i32* %57
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %56, i64 %59
%61 = load i8*, i8** %60
%62 = load i8**, i8*** %8
store i8* %61, i8** %62
br label %64
63: ; preds = %39
store i32 0, i32* %7
br label %66
64: ; preds = %55
br label %65
65: ; preds = %64, %35
store i32 1, i32* %7
br label %66
66: ; preds = %65, %63, %25
%67 = load i32, i32* %7
ret i32 %67
}

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