#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__ strcmp(char *, char *);
char *strrchr(char *, char);
char *get_content_type(char *filename) {
  char *ext = strrchr(filename, '.');
  if (!ext) {
    return "text/plain";
  }
  if (strcmp(ext, ".html") == 0 || strcmp(ext, ".htm") == 0) {
    return "text/html";
  }
  if (strcmp(ext, ".txt") == 0) {
    return "text/plain";
  }
  if (strcmp(ext, ".css") == 0) {
    return "text/css";
  }
  if (strcmp(ext, ".jpg") == 0 || strcmp(ext, ".jpeg") == 0) {
    return "image/jpeg";
  }
  if (strcmp(ext, ".gif") == 0) {
    return "image/gif";
  }
  if (strcmp(ext, ".png") == 0) {
    return "image/png";
  }
  return "text/plain";
}


x86 assembly (clang, -O0):
<get_content_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1159 <get_content_type+0x39>
lea    0xeb0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1294 <get_content_type+0x174>
mov    -0x18(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     118d <get_content_type+0x6d>
mov    -0x18(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    119d <get_content_type+0x7d>
lea    0xe82(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1294 <get_content_type+0x174>
mov    -0x18(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c7 <get_content_type+0xa7>
lea    0xe42(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1294 <get_content_type+0x174>
mov    -0x18(%rbp),%rdi
lea    0xe53(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f1 <get_content_type+0xd1>
lea    0xe42(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1294 <get_content_type+0x174>
mov    -0x18(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1225 <get_content_type+0x105>
mov    -0x18(%rbp),%rdi
lea    0xe22(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1235 <get_content_type+0x115>
lea    0xe12(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1294 <get_content_type+0x174>
mov    -0x18(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    125f <get_content_type+0x13f>
lea    0xdf8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1294 <get_content_type+0x174>
mov    -0x18(%rbp),%rdi
lea    0xdee(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1289 <get_content_type+0x169>
lea    0xddd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1294 <get_content_type+0x174>
lea    0xd70(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_content_type>:
push   %r15
push   %r14
push   %rbx
mov    $0x2e,%esi
call   1030 <strrchr@plt>
lea    0xeca(%rip),%r15
test   %rax,%rax
je     1211 <get_content_type+0xf1>
mov    %rax,%rbx
lea    0xec2(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
lea    0xebe(%rip),%r14
test   %rax,%rax
je     1214 <get_content_type+0xf4>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1214 <get_content_type+0xf4>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    %r15,%r14
test   %rax,%rax
je     1214 <get_content_type+0xf4>
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     121d <get_content_type+0xfd>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
lea    0xe80(%rip),%r14
test   %rax,%rax
je     1214 <get_content_type+0xf4>
lea    0xe6e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1214 <get_content_type+0xf4>
lea    0xe6b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1226 <get_content_type+0x106>
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
lea    0xe59(%rip),%rax
lea    0xdf5(%rip),%r14
cmove  %rax,%r14
jmp    1214 <get_content_type+0xf4>
mov    %r15,%r14
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe06(%rip),%r14
jmp    1214 <get_content_type+0xf4>
lea    0xe21(%rip),%r14
jmp    1214 <get_content_type+0xf4>

LLVM IR (-O0):
@.str = [11 x i8] c"text/plain\00"
@.str.1 = [6 x i8] c".html\00"
@.str.2 = [5 x i8] c".htm\00"
@.str.3 = [10 x i8] c"text/html\00"
@.str.4 = [5 x i8] c".txt\00"
@.str.5 = [5 x i8] c".css\00"
@.str.6 = [9 x i8] c"text/css\00"
@.str.7 = [5 x i8] c".jpg\00"
@.str.8 = [6 x i8] c".jpeg\00"
@.str.9 = [11 x i8] c"image/jpeg\00"
@.str.10 = [5 x i8] c".gif\00"
@.str.11 = [10 x i8] c"image/gif\00"
@.str.12 = [5 x i8] c".png\00"
@.str.13 = [10 x i8] c"image/png\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* @strrchr(i8* %5, i8 signext 46)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
br label %49
10: ; preds = %1
%11 = load i8*, i8** %4
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14, %10
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %49
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
br label %49
24: ; preds = %19
%25 = load i8*, i8** %4
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %49
29: ; preds = %24
%30 = load i8*, i8** %4
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = load i8*, i8** %4
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33, %29
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %49
38: ; preds = %33
%39 = load i8*, i8** %4
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %49
43: ; preds = %38
%44 = load i8*, i8** %4
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %43
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %49
48: ; preds = %43
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
br label %49
49: ; preds = %48, %47, %42, %37, %28, %23, %18, %9
%50 = load i8*, i8** %2
ret i8* %50
}

LLVM IR (-O2):
@.str = [11 x i8] c"text/plain\00"
@.str.1 = [6 x i8] c".html\00"
@.str.2 = [5 x i8] c".htm\00"
@.str.3 = [10 x i8] c"text/html\00"
@.str.4 = [5 x i8] c".txt\00"
@.str.5 = [5 x i8] c".css\00"
@.str.6 = [9 x i8] c"text/css\00"
@.str.7 = [5 x i8] c".jpg\00"
@.str.8 = [6 x i8] c".jpeg\00"
@.str.9 = [11 x i8] c"image/jpeg\00"
@.str.10 = [5 x i8] c".gif\00"
@.str.11 = [10 x i8] c"image/gif\00"
@.str.12 = [5 x i8] c".png\00"
@.str.13 = [10 x i8] c"image/png\00"
define i8* @get_content_type(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%3 = icmp eq i8* %2, null
br i1 %3, label %29, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %29, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %29, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %29, label %13
13: ; preds = %10
%14 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %29, label %16
16: ; preds = %13
%17 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %29, label %19
19: ; preds = %16
%20 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %29, label %22
22: ; preds = %19
%23 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %22
%26 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
%28 = select i1 %27, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0)
br label %29
29: ; preds = %25, %22, %16, %19, %13, %10, %4, %7, %1
%30 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %7 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %10 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), %13 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), %19 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), %16 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), %22 ], [ %28, %25 ]
ret i8* %30
}