#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, ".gif"))
    strcpy(filetype, "image/gif");
  else if (strstr(filename, ".jpg"))
    strcpy(filetype, "image/jpeg");
  else if (strstr(filename, ".mpg"))
    strcpy(filetype, "video/mpeg");
  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    120b <get_filetype+0xeb>
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    1206 <get_filetype+0xe6>
mov    -0x8(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11bd <get_filetype+0x9d>
mov    -0x10(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1201 <get_filetype+0xe1>
mov    -0x8(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11ec <get_filetype+0xcc>
mov    -0x10(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11fc <get_filetype+0xdc>
mov    -0x10(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1201 <get_filetype+0xe1>
jmp    1206 <get_filetype+0xe6>
jmp    120b <get_filetype+0xeb>
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     1144 <get_filetype+0x24>
lea    0xec4(%rip),%rsi
jmp    11a2 <get_filetype+0x82>
lea    0xec5(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     1161 <get_filetype+0x41>
lea    0xeb6(%rip),%rsi
jmp    11a2 <get_filetype+0x82>
lea    0xeb7(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     117e <get_filetype+0x5e>
lea    0xea8(%rip),%rsi
jmp    11a2 <get_filetype+0x82>
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
lea    0xea8(%rip),%rax
lea    0xe96(%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".gif\00"
@.str.3 = [10 x i8] c"image/gif\00"
@.str.4 = [5 x i8] c".jpg\00"
@.str.5 = [11 x i8] c"image/jpeg\00"
@.str.6 = [5 x i8] c".mpg\00"
@.str.7 = [11 x i8] c"video/mpeg\00"
@.str.8 = [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 %38
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 ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %37
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 %36
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 %35
32: ; preds = %25
%33 = load i8*, i8** %4
%34 = call i32 @strcpy(i8* %33, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
br label %35
35: ; preds = %32, %29
br label %36
36: ; preds = %35, %22
br label %37
37: ; preds = %36, %15
br label %38
38: ; preds = %37, %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".gif\00"
@.str.3 = [10 x i8] c"image/gif\00"
@.str.4 = [5 x i8] c".jpg\00"
@.str.5 = [11 x i8] c"image/jpeg\00"
@.str.6 = [5 x i8] c".mpg\00"
@.str.7 = [11 x i8] c"video/mpeg\00"
@.str.8 = [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 %15
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 %15
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 %15
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
%14 = select i1 %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0)
br label %15
15: ; preds = %11, %8, %5, %2
%16 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), %8 ], [ %14, %11 ]
%17 = tail call i32 @strcpy(i8* %1, i8* %16)
ret void
}