#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_filetype(char *filename, char *filetype) {
  if (strstr(filename, ".html"))
    strcpy(filetype, "text/html");
  else if (strstr(filename, ".css"))
    strcpy(filetype, "text/css");
  else if (strstr(filename, ".gif"))
    strcpy(filetype, "image/gif");
  else if (strstr(filename, ".jpg"))
    strcpy(filetype, "image/jpeg");
  else if (strstr(filename, ".ogg"))
    strcpy(filetype, "video/ogg");
  else if (strstr(filename, ".mp4"))
    strcpy(filetype, "video/mp4");
  else
    strcpy(filetype, "text/plain");
}


x86 assembly (clang, -O0):
<get_filetype>:
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_filetype+0x3f>
mov    -0x10(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1273 <get_filetype+0x153>
mov    -0x8(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     118e <get_filetype+0x6e>
mov    -0x10(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1030 <strcpy@plt>
jmp    126e <get_filetype+0x14e>
mov    -0x8(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11bd <get_filetype+0x9d>
mov    -0x10(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1269 <get_filetype+0x149>
mov    -0x8(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11ec <get_filetype+0xcc>
mov    -0x10(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1264 <get_filetype+0x144>
mov    -0x8(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     121b <get_filetype+0xfb>
mov    -0x10(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1030 <strcpy@plt>
jmp    125f <get_filetype+0x13f>
mov    -0x8(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     124a <get_filetype+0x12a>
mov    -0x10(%rbp),%rdi
lea    0xe11(%rip),%rsi
call   1030 <strcpy@plt>
jmp    125a <get_filetype+0x13a>
mov    -0x10(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   1030 <strcpy@plt>
jmp    125f <get_filetype+0x13f>
jmp    1264 <get_filetype+0x144>
jmp    1269 <get_filetype+0x149>
jmp    126e <get_filetype+0x14e>
jmp    1273 <get_filetype+0x153>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_filetype>:
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_filetype+0x27>
lea    0xec4(%rip),%rsi
jmp    11df <get_filetype+0xbf>
lea    0xec2(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     1164 <get_filetype+0x44>
lea    0xeb3(%rip),%rsi
jmp    11df <get_filetype+0xbf>
lea    0xeb3(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     1181 <get_filetype+0x61>
lea    0xea4(%rip),%rsi
jmp    11df <get_filetype+0xbf>
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     119e <get_filetype+0x7e>
lea    0xe96(%rip),%rsi
jmp    11df <get_filetype+0xbf>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     11bb <get_filetype+0x9b>
lea    0xe89(%rip),%rsi
jmp    11df <get_filetype+0xbf>
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
lea    0xe87(%rip),%rax
lea    0xe76(%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".gif\00"
@.str.5 = [10 x i8] c"image/gif\00"
@.str.6 = [5 x i8] c".jpg\00"
@.str.7 = [11 x i8] c"image/jpeg\00"
@.str.8 = [5 x i8] c".ogg\00"
@.str.9 = [10 x i8] c"video/ogg\00"
@.str.10 = [5 x i8] c".mp4\00"
@.str.11 = [10 x i8] c"video/mp4\00"
@.str.12 = [11 x i8] c"text/plain\00"
define void @get_filetype(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 %54
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 %53
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 ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %52
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 ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
br label %51
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 %50
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 ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
br label %49
46: ; preds = %39
%47 = load i8*, i8** %4
%48 = call i32 @strcpy(i8* %47, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
br label %49
49: ; preds = %46, %43
br label %50
50: ; preds = %49, %36
br label %51
51: ; preds = %50, %29
br label %52
52: ; preds = %51, %22
br label %53
53: ; preds = %52, %15
br label %54
54: ; preds = %53, %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".gif\00"
@.str.5 = [10 x i8] c"image/gif\00"
@.str.6 = [5 x i8] c".jpg\00"
@.str.7 = [11 x i8] c"image/jpeg\00"
@.str.8 = [5 x i8] c".ogg\00"
@.str.9 = [10 x i8] c"video/ogg\00"
@.str.10 = [5 x i8] c".mp4\00"
@.str.11 = [10 x i8] c"video/mp4\00"
@.str.12 = [11 x i8] c"text/plain\00"
define void @get_filetype(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 %21
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 %21
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 %21
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 %21
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 %21
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
%20 = select i1 %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0)
br label %21
21: ; preds = %17, %14, %11, %8, %5, %2
%22 = 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 ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), %8 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), %11 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), %14 ], [ %20, %17 ]
%23 = tail call i32 @strcpy(i8* %1, i8* %22)
ret void
}