#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*/ strcpy(char *, char *);
scalar_t__ strstr(char *, char *);
void get_mimetype(char *filepath, char *mimetype) {
  if (strstr(filepath, ".html"))
    strcpy(mimetype, "text/html");
  else if (strstr(filepath, ".css"))
    strcpy(mimetype, "text/css");
  else if (strstr(filepath, ".txt"))
    strcpy(mimetype, "text/plain");
  else if (strstr(filepath, ".png"))
    strcpy(mimetype, "image/png");
  else if (strstr(filepath, ".gif"))
    strcpy(mimetype, "image/gif");
  else if (strstr(filepath, ".jpg"))
    strcpy(mimetype, "image/jpeg");
  else if (strstr(filepath, ".pdf"))
    strcpy(mimetype, "application/pdf");
  else
    strcpy(mimetype, "application/octet-stream");
}


x86 assembly (clang, -O0):
<get_mimetype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     115f <get_mimetype+0x3f>
mov    -0x10(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1030 <strcpy@plt>
jmp    12a7 <get_mimetype+0x187>
mov    -0x8(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     118e <get_mimetype+0x6e>
mov    -0x10(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1030 <strcpy@plt>
jmp    12a2 <get_mimetype+0x182>
mov    -0x8(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11bd <get_mimetype+0x9d>
mov    -0x10(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1030 <strcpy@plt>
jmp    129d <get_mimetype+0x17d>
mov    -0x8(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11ec <get_mimetype+0xcc>
mov    -0x10(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1298 <get_mimetype+0x178>
mov    -0x8(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     121b <get_mimetype+0xfb>
mov    -0x10(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1293 <get_mimetype+0x173>
mov    -0x8(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     124a <get_mimetype+0x12a>
mov    -0x10(%rbp),%rdi
lea    0xe11(%rip),%rsi
call   1030 <strcpy@plt>
jmp    128e <get_mimetype+0x16e>
mov    -0x8(%rbp),%rdi
lea    0xe07(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     1279 <get_mimetype+0x159>
mov    -0x10(%rbp),%rdi
lea    0xdf2(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1289 <get_mimetype+0x169>
mov    -0x10(%rbp),%rdi
lea    0xded(%rip),%rsi
call   1030 <strcpy@plt>
jmp    128e <get_mimetype+0x16e>
jmp    1293 <get_mimetype+0x173>
jmp    1298 <get_mimetype+0x178>
jmp    129d <get_mimetype+0x17d>
jmp    12a2 <get_mimetype+0x182>
jmp    12a7 <get_mimetype+0x187>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mimetype>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xecf(%rip),%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     1147 <get_mimetype+0x27>
lea    0xec4(%rip),%rsi
jmp    11ff <get_mimetype+0xdf>
lea    0xec2(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     1167 <get_mimetype+0x47>
lea    0xeb3(%rip),%rsi
jmp    11ff <get_mimetype+0xdf>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     1184 <get_mimetype+0x64>
lea    0xea1(%rip),%rsi
jmp    11ff <get_mimetype+0xdf>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     11a1 <get_mimetype+0x81>
lea    0xe94(%rip),%rsi
jmp    11ff <get_mimetype+0xdf>
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     11be <get_mimetype+0x9e>
lea    0xe86(%rip),%rsi
jmp    11ff <get_mimetype+0xdf>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     11db <get_mimetype+0xbb>
lea    0xe78(%rip),%rsi
jmp    11ff <get_mimetype+0xdf>
lea    0xe7a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
lea    0xe7d(%rip),%rax
lea    0xe66(%rip),%rsi
cmove  %rax,%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
@.str = [6 x i8] c".html\00"
@.str.1 = [10 x i8] c"text/html\00"
@.str.2 = [5 x i8] c".css\00"
@.str.3 = [9 x i8] c"text/css\00"
@.str.4 = [5 x i8] c".txt\00"
@.str.5 = [11 x i8] c"text/plain\00"
@.str.6 = [5 x i8] c".png\00"
@.str.7 = [10 x i8] c"image/png\00"
@.str.8 = [5 x i8] c".gif\00"
@.str.9 = [10 x i8] c"image/gif\00"
@.str.10 = [5 x i8] c".jpg\00"
@.str.11 = [11 x i8] c"image/jpeg\00"
@.str.12 = [5 x i8] c".pdf\00"
@.str.13 = [16 x i8] c"application/pdf\00"
@.str.14 = [25 x i8] c"application/octet-stream\00"
define void @get_mimetype(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = call i64 @strstr(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %62
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = call i64 @strstr(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %61
18: ; preds = %11
%19 = load i8*, i8** %3
%20 = call i64 @strstr(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i8*, i8** %4
%24 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
br label %60
25: ; preds = %18
%26 = load i8*, i8** %3
%27 = call i64 @strstr(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i8*, i8** %4
%31 = call i32 @strcpy(i8* %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
br label %59
32: ; preds = %25
%33 = load i8*, i8** %3
%34 = call i64 @strstr(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load i8*, i8** %4
%38 = call i32 @strcpy(i8* %37, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
br label %58
39: ; preds = %32
%40 = load i8*, i8** %3
%41 = call i64 @strstr(i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load i8*, i8** %4
%45 = call i32 @strcpy(i8* %44, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
br label %57
46: ; preds = %39
%47 = load i8*, i8** %3
%48 = call i64 @strstr(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = load i8*, i8** %4
%52 = call i32 @strcpy(i8* %51, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0))
br label %56
53: ; preds = %46
%54 = load i8*, i8** %4
%55 = call i32 @strcpy(i8* %54, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0))
br label %56
56: ; preds = %53, %50
br label %57
57: ; preds = %56, %43
br label %58
58: ; preds = %57, %36
br label %59
59: ; preds = %58, %29
br label %60
60: ; preds = %59, %22
br label %61
61: ; preds = %60, %15
br label %62
62: ; preds = %61, %8
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c".html\00"
@.str.1 = [10 x i8] c"text/html\00"
@.str.2 = [5 x i8] c".css\00"
@.str.3 = [9 x i8] c"text/css\00"
@.str.4 = [5 x i8] c".txt\00"
@.str.5 = [11 x i8] c"text/plain\00"
@.str.6 = [5 x i8] c".png\00"
@.str.7 = [10 x i8] c"image/png\00"
@.str.8 = [5 x i8] c".gif\00"
@.str.9 = [10 x i8] c"image/gif\00"
@.str.10 = [5 x i8] c".jpg\00"
@.str.11 = [11 x i8] c"image/jpeg\00"
@.str.12 = [5 x i8] c".pdf\00"
@.str.13 = [16 x i8] c"application/pdf\00"
@.str.14 = [25 x i8] c"application/octet-stream\00"
define void @get_mimetype(i8* %0, i8* %1) {
%3 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %24
5: ; preds = %2
%6 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %8
%12 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0)
br label %24
24: ; preds = %20, %17, %14, %11, %8, %5, %2
%25 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), %8 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), %11 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), %14 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), %17 ], [ %23, %20 ]
%26 = tail call i32 @strcpy(i8* %1, i8* %25)
ret void
}