#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 *);
scalar_t__ strncmp(char *, char *, int);
int mode_finder(char *mode) {
  if (strncmp("NAME", mode, 4) == 0) {
    return 0;
  } else if (strncmp("PERM", mode, 4) == 0) {
    return 1;
  } else if (strncmp("TYPE", mode, 4) == 0) {
    return 2;
  } else if (strncmp("REGEX", mode, 5) == 0) {
    return 3;
  } else if (strncmp("SIZE", mode, 4) == 0) {
    return 4;
  }
  printf("You did not enter a valid search mode\n");
  exit(1);
}


x86 assembly (clang, -O0):
<mode_finder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb9(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1167 <mode_finder+0x37>
movl   $0x0,-0x4(%rbp)
jmp    123d <mode_finder+0x10d>
mov    -0x10(%rbp),%rsi
lea    0xe93(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1192 <mode_finder+0x62>
movl   $0x1,-0x4(%rbp)
jmp    123d <mode_finder+0x10d>
mov    -0x10(%rbp),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11bd <mode_finder+0x8d>
movl   $0x2,-0x4(%rbp)
jmp    123d <mode_finder+0x10d>
mov    -0x10(%rbp),%rsi
lea    0xe47(%rip),%rdi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11e8 <mode_finder+0xb8>
movl   $0x3,-0x4(%rbp)
jmp    123d <mode_finder+0x10d>
mov    -0x10(%rbp),%rsi
lea    0xe22(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1213 <mode_finder+0xe3>
movl   $0x4,-0x4(%rbp)
jmp    123d <mode_finder+0x10d>
jmp    1218 <mode_finder+0xe8>
jmp    121d <mode_finder+0xed>
jmp    1222 <mode_finder+0xf2>
jmp    1227 <mode_finder+0xf7>
lea    0xdec(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mode_finder>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec3(%rip),%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11ce <mode_finder+0x9e>
lea    0xeaf(%rip),%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11d2 <mode_finder+0xa2>
lea    0xe9b(%rip),%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11d9 <mode_finder+0xa9>
lea    0xe87(%rip),%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11e0 <mode_finder+0xb0>
lea    0xe74(%rip),%rdi
mov    $0x4,%ebp
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11e5 <mode_finder+0xb5>
lea    0xe5b(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
xor    %ebp,%ebp
jmp    11e5 <mode_finder+0xb5>
mov    $0x1,%ebp
jmp    11e5 <mode_finder+0xb5>
mov    $0x2,%ebp
jmp    11e5 <mode_finder+0xb5>
mov    $0x3,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"NAME\00"
@.str.1 = [5 x i8] c"PERM\00"
@.str.2 = [5 x i8] c"TYPE\00"
@.str.3 = [6 x i8] c"REGEX\00"
@.str.4 = [5 x i8] c"SIZE\00"
@.str.5 = [39 x i8] c"You did not enter a valid search mode\0A\00"
define i32 @mode_finder(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %4, i32 4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 0, i32* %2
br label %35
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %9, i32 4)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 1, i32* %2
br label %35
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %14, i32 4)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 2, i32* %2
br label %35
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = call i64 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %19, i32 5)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 3, i32* %2
br label %35
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %24, i32 4)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 4, i32* %2
br label %35
28: ; preds = %23
br label %29
29: ; preds = %28
br label %30
30: ; preds = %29
br label %31
31: ; preds = %30
br label %32
32: ; preds = %31
%33 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %27, %22, %17, %12, %7
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
@.str = [5 x i8] c"NAME\00"
@.str.1 = [5 x i8] c"PERM\00"
@.str.2 = [5 x i8] c"TYPE\00"
@.str.3 = [6 x i8] c"REGEX\00"
@.str.4 = [5 x i8] c"SIZE\00"
@str = [38 x i8] c"You did not enter a valid search mode\00"
define i32 @mode_finder(i8* %0) {
%2 = tail call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0, i32 4)
%3 = icmp eq i64 %2, 0
br i1 %3, label %19, label %4
4: ; preds = %1
%5 = tail call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %19, label %7
7: ; preds = %4
%8 = tail call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %7
%11 = tail call i64 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 5)
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %10
%14 = tail call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %0, i32 4)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %13, %10, %7, %4, %1
%20 = phi i32 [ 0, %1 ], [ 1, %4 ], [ 2, %7 ], [ 3, %10 ], [ 4, %13 ]
ret i32 %20
}