#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 */
char *get_file_extension(char *);
scalar_t__ strcmp(char *, char *);
char *get_content_type(char *filename) {
  char *file_extension = get_file_extension(filename);
  if (strcmp(file_extension, ".txt") == 0) {
    return "text/plain";
  } else if (strcmp(file_extension, ".html") == 0 ||
             strcmp(file_extension, ".htm") == 0) {
    return "text/html";
  } else if (strcmp(file_extension, ".jpg") == 0 ||
             strcmp(file_extension, "jpeg") == 0) {
    return "image/jpeg";
  } else if (strcmp(file_extension, ".gif") == 0) {
    return "image/gif";
  } else {
    return "application/octet-stream";
  }
}


x86 assembly (clang, -O0):
<get_content_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <get_file_extension@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xebc(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1163 <get_content_type+0x43>
lea    0xeab(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1220 <get_content_type+0x100>
mov    -0x18(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1197 <get_content_type+0x77>
mov    -0x18(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11a7 <get_content_type+0x87>
lea    0xe7d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1220 <get_content_type+0x100>
mov    -0x18(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11db <get_content_type+0xbb>
mov    -0x18(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11eb <get_content_type+0xcb>
lea    0xe48(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1220 <get_content_type+0x100>
mov    -0x18(%rbp),%rdi
lea    0xe3f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1215 <get_content_type+0xf5>
lea    0xe2e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1220 <get_content_type+0x100>
lea    0xe28(%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
call   1030 <get_file_extension@plt>
mov    %rax,%rbx
lea    0xecd(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11c8 <get_content_type+0xa8>
lea    0xec5(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
lea    0xec1(%rip),%r14
test   %rax,%rax
je     11cf <get_content_type+0xaf>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11cf <get_content_type+0xaf>
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
lea    0xea1(%rip),%r14
test   %rax,%rax
je     11cf <get_content_type+0xaf>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11cf <get_content_type+0xaf>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
lea    0xe7f(%rip),%rax
lea    0xe82(%rip),%r14
cmove  %rax,%r14
jmp    11cf <get_content_type+0xaf>
lea    0xe36(%rip),%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c".txt\00"
@.str.1 = [11 x i8] c"text/plain\00"
@.str.2 = [6 x i8] c".html\00"
@.str.3 = [5 x i8] c".htm\00"
@.str.4 = [10 x i8] c"text/html\00"
@.str.5 = [5 x i8] c".jpg\00"
@.str.6 = [5 x i8] c"jpeg\00"
@.str.7 = [11 x i8] c"image/jpeg\00"
@.str.8 = [5 x i8] c".gif\00"
@.str.9 = [10 x i8] c"image/gif\00"
@.str.10 = [25 x i8] c"application/octet-stream\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 = call i8* @get_file_extension(i8* %5)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %35
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15, %11
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %35
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %20
%25 = load i8*, i8** %4
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24, %20
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %35
29: ; preds = %24
%30 = load i8*, i8** %4
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %35
34: ; preds = %29
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %35
35: ; preds = %34, %33, %28, %19, %10
%36 = load i8*, i8** %2
ret i8* %36
}

LLVM IR (-O2):
@.str = [5 x i8] c".txt\00"
@.str.1 = [11 x i8] c"text/plain\00"
@.str.2 = [6 x i8] c".html\00"
@.str.3 = [5 x i8] c".htm\00"
@.str.4 = [10 x i8] c"text/html\00"
@.str.5 = [5 x i8] c".jpg\00"
@.str.6 = [5 x i8] c"jpeg\00"
@.str.7 = [11 x i8] c"image/jpeg\00"
@.str.8 = [5 x i8] c".gif\00"
@.str.9 = [10 x i8] c"image/gif\00"
@.str.10 = [25 x i8] c"application/octet-stream\00"
define i8* @get_content_type(i8* %0) {
%2 = tail call i8* @get_file_extension(i8* %0)
%3 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %1
%6 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %21, label %8
8: ; preds = %5
%9 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 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* %2, i8* getelementptr inbounds ([5 x i8], [5 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* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, 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* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0)
br label %21
21: ; preds = %17, %11, %14, %5, %8, %1
%22 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), %1 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), %8 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), %14 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), %11 ], [ %20, %17 ]
ret i8* %22
}