#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*/ printf(char *, char *);
scalar_t__ strcmp(char *, char *);
char *strrchr(char *, char);
const char *get_content_type(char *filename) {
  char *ext = strrchr(filename + 1, '.') + 1;
  printf("%s\n", filename);
  if (strcmp(ext, "html") == 0)
    return "text/html";
  else if (strcmp(ext, "js") == 0)
    return "application/javascript";
  else if (strcmp(ext, "css") == 0)
    return "text/css";
  else if (strcmp(ext, "jpg") == 0)
    return "image/jpeg";
  else if (strcmp(ext, "png") == 0)
    return "image/png";
  return "text";
}


x86 assembly (clang, -O0):
<get_content_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1190 <get_content_type+0x60>
lea    0xe7d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1257 <get_content_type+0x127>
mov    -0x18(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11ba <get_content_type+0x8a>
lea    0xe60(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1257 <get_content_type+0x127>
mov    -0x18(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11e4 <get_content_type+0xb4>
lea    0xe4d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1257 <get_content_type+0x127>
mov    -0x18(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    120e <get_content_type+0xde>
lea    0xe30(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1257 <get_content_type+0x127>
mov    -0x18(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1238 <get_content_type+0x108>
lea    0xe11(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1257 <get_content_type+0x127>
jmp    123d <get_content_type+0x10d>
jmp    1242 <get_content_type+0x112>
jmp    1247 <get_content_type+0x117>
jmp    124c <get_content_type+0x11c>
lea    0xdf7(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_content_type>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
add    $0x1,%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,%r14
add    $0x1,%r14
lea    0xead(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xea7(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11d1 <get_content_type+0xa1>
lea    0xe98(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11da <get_content_type+0xaa>
lea    0xea3(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11e3 <get_content_type+0xb3>
lea    0xe93(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11ec <get_content_type+0xbc>
lea    0xe94(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
lea    0xe7c(%rip),%rcx
lea    0xe7f(%rip),%rax
cmove  %rcx,%rax
jmp    11f3 <get_content_type+0xc3>
lea    0xe2c(%rip),%rax
jmp    11f3 <get_content_type+0xc3>
lea    0xe30(%rip),%rax
jmp    11f3 <get_content_type+0xc3>
lea    0xe3e(%rip),%rax
jmp    11f3 <get_content_type+0xc3>
lea    0xe42(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [5 x i8] c"html\00"
@.str.2 = [10 x i8] c"text/html\00"
@.str.3 = [3 x i8] c"js\00"
@.str.4 = [23 x i8] c"application/javascript\00"
@.str.5 = [4 x i8] c"css\00"
@.str.6 = [9 x i8] c"text/css\00"
@.str.7 = [4 x i8] c"jpg\00"
@.str.8 = [11 x i8] c"image/jpeg\00"
@.str.9 = [4 x i8] c"png\00"
@.str.10 = [10 x i8] c"image/png\00"
@.str.11 = [5 x i8] c"text\00"
define i8* @get_content_type(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = call i8* @strrchr(i8* %6, i8 signext 46)
%8 = getelementptr inbounds i8, i8* %7, i64 1
store i8* %8, i8** %4
%9 = load i8*, i8** %3
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %4
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %40
15: ; preds = %1
%16 = load i8*, i8** %4
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %40
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %40
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %40
30: ; preds = %25
%31 = load i8*, i8** %4
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %40
35: ; preds = %30
br label %36
36: ; preds = %35
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37
br label %39
39: ; preds = %38
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %40
40: ; preds = %39, %34, %29, %24, %19, %14
%41 = load i8*, i8** %2
ret i8* %41
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [5 x i8] c"html\00"
@.str.2 = [10 x i8] c"text/html\00"
@.str.3 = [3 x i8] c"js\00"
@.str.4 = [23 x i8] c"application/javascript\00"
@.str.5 = [4 x i8] c"css\00"
@.str.6 = [9 x i8] c"text/css\00"
@.str.7 = [4 x i8] c"jpg\00"
@.str.8 = [11 x i8] c"image/jpeg\00"
@.str.9 = [4 x i8] c"png\00"
@.str.10 = [10 x i8] c"image/png\00"
@.str.11 = [5 x i8] c"text\00"
define i8* @get_content_type(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 1
%3 = tail call i8* @strrchr(i8* %2, i8 signext 46)
%4 = getelementptr inbounds i8, i8* %3, i64 1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %21, label %8
8: ; preds = %1
%9 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %8
%12 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %11
%15 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0)
br label %21
21: ; preds = %17, %14, %11, %8, %1
%22 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %1 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), %8 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), %11 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), %14 ], [ %20, %17 ]
ret i8* %22
}