#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 */
scalar_t__ strstr(char *, char *);
char *file_type(char *filename) {
  char *type;
  if (strstr(filename, ".html")) {
    type = "text/html";
  } else if (strstr(filename, ".gif")) {
    type = "image/gif";
  } else if (strstr(filename, ".jpg")) {
    type = "image/jpeg";
  } else if (strstr(filename, ".js")) {
    type = "applicatiion/javascript";
  } else {
    type = "text/plain";
  }
  return type;
}


x86 assembly (clang, -O0):
<file_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     1146 <file_type+0x36>
lea    0xec9(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11de <file_type+0xce>
mov    -0x8(%rbp),%rdi
lea    0xebf(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     1170 <file_type+0x60>
lea    0xeae(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11d9 <file_type+0xc9>
mov    -0x8(%rbp),%rdi
lea    0xea4(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     119a <file_type+0x8a>
lea    0xe93(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11d4 <file_type+0xc4>
mov    -0x8(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     11c4 <file_type+0xb4>
lea    0xe78(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11cf <file_type+0xbf>
lea    0xe80(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11d4 <file_type+0xc4>
jmp    11d9 <file_type+0xc9>
jmp    11de <file_type+0xce>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_type>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <strstr@plt>
test   %rax,%rax
je     112e <file_type+0x1e>
lea    0xeda(%rip),%rax
pop    %rbx
ret
lea    0xedb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     114b <file_type+0x3b>
lea    0xecc(%rip),%rax
pop    %rbx
ret
lea    0xecd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     1168 <file_type+0x58>
lea    0xebe(%rip),%rax
pop    %rbx
ret
lea    0xec0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
lea    0xeca(%rip),%rcx
lea    0xeab(%rip),%rax
cmove  %rcx,%rax
pop    %rbx
ret

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 = [4 x i8] c".js\00"
@.str.7 = [24 x i8] c"applicatiion/javascript\00"
@.str.8 = [11 x i8] c"text/plain\00"
define i8* @file_type(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @strstr(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %27
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i64 @strstr(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %26
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = call i64 @strstr(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %25
18: ; preds = %13
%19 = load i8*, i8** %2
%20 = call i64 @strstr(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %24
23: ; preds = %18
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %24
24: ; preds = %23, %22
br label %25
25: ; preds = %24, %17
br label %26
26: ; preds = %25, %12
br label %27
27: ; preds = %26, %7
%28 = load i8*, i8** %3
ret i8* %28
}

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 = [4 x i8] c".js\00"
@.str.7 = [24 x i8] c"applicatiion/javascript\00"
@.str.8 = [11 x i8] c"text/plain\00"
define i8* @file_type(i8* %0) {
%2 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %14
4: ; preds = %1
%5 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0)
br label %14
14: ; preds = %10, %7, %4, %1
%15 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %1 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), %7 ], [ %13, %10 ]
ret i8* %15
}