#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*/ debug(char *);
int /*<<< orphan*/ error(char *, char const *);
int /*<<< orphan*/ strcmp(char *, char const *);
int mode_parse(int *mode, char const *mode_string) {
  if (mode_string == NULL) {
    *mode = -1;
    return (-9);
  }
  if (!strcmp("t2", mode_string)) {
    debug("Found mode t2.\n");
    *mode = 2;
    return (0);
  } else if (!strcmp("t3", mode_string)) {
    debug("Found mode t3.\n");
    *mode = 3;
    return (0);
  } else if (!strcmp("vector", mode_string)) {
    debug("Found mode vector.\n");
    *mode = 0xBEEF;
    return (0);
  } else if (!strcmp("as-t2", mode_string)) {
    debug("Found mode as-t2.\n");
    *mode = 0xDEAD;
    return (0);
  } else {
    error("Mode not recognized: %s.\n", mode_string);
    *mode = -1;
    return (-9);
  }
}


x86 assembly (clang, -O0):
<mode_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1161 <mode_parse+0x31>
mov    -0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
movl   $0xfffffff7,-0x4(%rbp)
jmp    126e <mode_parse+0x13e>
mov    -0x18(%rbp),%rsi
lea    0xed5(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    119c <mode_parse+0x6c>
lea    0xe7f(%rip),%rdi
call   1030 <debug@plt>
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    126e <mode_parse+0x13e>
mov    -0x18(%rbp),%rsi
lea    0xe69(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11d7 <mode_parse+0xa7>
lea    0xe57(%rip),%rdi
call   1030 <debug@plt>
mov    -0x10(%rbp),%rax
movl   $0x3,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    126e <mode_parse+0x13e>
mov    -0x18(%rbp),%rsi
lea    0xe41(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1212 <mode_parse+0xe2>
lea    0xe33(%rip),%rdi
call   1030 <debug@plt>
mov    -0x10(%rbp),%rax
movl   $0xbeef,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    126e <mode_parse+0x13e>
mov    -0x18(%rbp),%rsi
lea    0xe21(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    124d <mode_parse+0x11d>
lea    0xe12(%rip),%rdi
call   1030 <debug@plt>
mov    -0x10(%rbp),%rax
movl   $0xdead,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    126e <mode_parse+0x13e>
mov    -0x18(%rbp),%rsi
lea    0xdff(%rip),%rdi
call   1050 <error@plt>
mov    -0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
movl   $0xfffffff7,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mode_parse>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0xfffffff7,%r15d
mov    $0xffffffff,%ebp
test   %rsi,%rsi
je     1201 <mode_parse+0xd1>
mov    %rsi,%rbx
lea    0xee9(%rip),%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11ab <mode_parse+0x7b>
lea    0xea8(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11c1 <mode_parse+0x91>
lea    0xea8(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11d7 <mode_parse+0xa7>
lea    0xeb0(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11ed <mode_parse+0xbd>
lea    0xeb6(%rip),%rdi
mov    %rbx,%rsi
call   1050 <error@plt>
jmp    1201 <mode_parse+0xd1>
lea    0xe4e(%rip),%rdi
call   1030 <debug@plt>
xor    %r15d,%r15d
mov    $0x2,%ebp
jmp    1201 <mode_parse+0xd1>
lea    0xe4b(%rip),%rdi
call   1030 <debug@plt>
xor    %r15d,%r15d
mov    $0x3,%ebp
jmp    1201 <mode_parse+0xd1>
lea    0xe4c(%rip),%rdi
call   1030 <debug@plt>
xor    %r15d,%r15d
mov    $0xbeef,%ebp
jmp    1201 <mode_parse+0xd1>
lea    0xe50(%rip),%rdi
call   1030 <debug@plt>
xor    %r15d,%r15d
mov    $0xdead,%ebp
mov    %ebp,(%r14)
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"t2\00"
@.str.1 = [16 x i8] c"Found mode t2.\0A\00"
@.str.2 = [3 x i8] c"t3\00"
@.str.3 = [16 x i8] c"Found mode t3.\0A\00"
@.str.4 = [7 x i8] c"vector\00"
@.str.5 = [20 x i8] c"Found mode vector.\0A\00"
@.str.6 = [6 x i8] c"as-t2\00"
@.str.7 = [19 x i8] c"Found mode as-t2.\0A\00"
@.str.8 = [26 x i8] c"Mode not recognized: %s.\0A\00"
define i32 @mode_parse(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = load i32*, i32** %4
store i32 -1, i32* %9
store i32 -9, i32* %3
br label %42
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = call i32 @debug(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32*, i32** %4
store i32 2, i32* %16
store i32 0, i32* %3
br label %42
17: ; preds = %10
%18 = load i8*, i8** %5
%19 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %17
%22 = call i32 @debug(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32*, i32** %4
store i32 3, i32* %23
store i32 0, i32* %3
br label %42
24: ; preds = %17
%25 = load i8*, i8** %5
%26 = call i32 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %24
%29 = call i32 @debug(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%30 = load i32*, i32** %4
store i32 48879, i32* %30
store i32 0, i32* %3
br label %42
31: ; preds = %24
%32 = load i8*, i8** %5
%33 = call i32 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %32)
%34 = icmp ne i32 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %31
%36 = call i32 @debug(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%37 = load i32*, i32** %4
store i32 57005, i32* %37
store i32 0, i32* %3
br label %42
38: ; preds = %31
%39 = load i8*, i8** %5
%40 = call i32 @error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %39)
%41 = load i32*, i32** %4
store i32 -1, i32* %41
store i32 -9, i32* %3
br label %42
42: ; preds = %38, %35, %28, %21, %14, %8
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [3 x i8] c"t2\00"
@.str.1 = [16 x i8] c"Found mode t2.\0A\00"
@.str.2 = [3 x i8] c"t3\00"
@.str.3 = [16 x i8] c"Found mode t3.\0A\00"
@.str.4 = [7 x i8] c"vector\00"
@.str.5 = [20 x i8] c"Found mode vector.\0A\00"
@.str.6 = [6 x i8] c"as-t2\00"
@.str.7 = [19 x i8] c"Found mode as-t2.\0A\00"
@.str.8 = [26 x i8] c"Mode not recognized: %s.\0A\00"
define i32 @mode_parse(i32* nocapture writeonly %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %26, label %4
4: ; preds = %2
%5 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @debug(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %26
9: ; preds = %4
%10 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @debug(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %26
14: ; preds = %9
%15 = tail call i32 @strcmp(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = tail call i32 @debug(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %26
19: ; preds = %14
%20 = tail call i32 @strcmp(i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %1)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 @debug(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %26
24: ; preds = %19
%25 = tail call i32 @error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %1)
br label %26
26: ; preds = %2, %24, %22, %17, %12, %7
%27 = phi i32 [ -1, %24 ], [ 57005, %22 ], [ 48879, %17 ], [ 3, %12 ], [ 2, %7 ], [ -1, %2 ]
%28 = phi i32 [ -9, %24 ], [ 0, %22 ], [ 0, %17 ], [ 0, %12 ], [ 0, %7 ], [ -9, %2 ]
store i32 %27, i32* %0
ret i32 %28
}