#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*/ strcasecmp(char *, char *);
char *strrchr(char const *, char);
char *get_mime_type(const char *filename) {
  char *dot = strrchr(filename, '.');
  if (!dot)
    return "text/plain";
  if (!strcasecmp(dot, ".html"))
    return "text/html";
  else if (!strcasecmp(dot, ".jpg"))
    return "image/jpeg";
  else if (!strcasecmp(dot, ".css"))
    return "text/css";
  else if (!strcasecmp(dot, ".gif"))
    return "image/gif";
  else if (!strcasecmp(dot, ".ico"))
    return "image/x-icon";
  else if (!strcasecmp(dot, ".png"))
    return "image/png";
  else if (!strcasecmp(dot, ".js"))
    return "application/javascript";
  else
    return "text/plain";
}


x86 assembly (clang, -O0):
<get_mime_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1159 <get_mime_type+0x39>
lea    0xeb0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1283 <get_mime_type+0x163>
mov    -0x18(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1182 <get_mime_type+0x62>
lea    0xe98(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1283 <get_mime_type+0x163>
mov    -0x18(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11ab <get_mime_type+0x8b>
lea    0xe7e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1283 <get_mime_type+0x163>
mov    -0x18(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11d4 <get_mime_type+0xb4>
lea    0xe65(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1283 <get_mime_type+0x163>
mov    -0x18(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11fd <get_mime_type+0xdd>
lea    0xe4a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1283 <get_mime_type+0x163>
mov    -0x18(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1226 <get_mime_type+0x106>
lea    0xe30(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1283 <get_mime_type+0x163>
mov    -0x18(%rbp),%rdi
lea    0xe29(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    124f <get_mime_type+0x12f>
lea    0xe19(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1283 <get_mime_type+0x163>
mov    -0x18(%rbp),%rdi
lea    0xe0f(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1278 <get_mime_type+0x158>
lea    0xdfe(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1283 <get_mime_type+0x163>
lea    0xd81(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mime_type>:
push   %rbx
mov    $0x2e,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     11d6 <get_mime_type+0xb6>
mov    %rax,%rbx
lea    0xecd(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11df <get_mime_type+0xbf>
lea    0xec6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11e8 <get_mime_type+0xc8>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11f1 <get_mime_type+0xd1>
lea    0xeba(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11fa <get_mime_type+0xda>
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1203 <get_mime_type+0xe3>
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     120c <get_mime_type+0xec>
lea    0xeb1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
lea    0xea4(%rip),%rcx
lea    0xe30(%rip),%rax
cmove  %rcx,%rax
pop    %rbx
ret
lea    0xe23(%rip),%rax
pop    %rbx
ret
lea    0xe2b(%rip),%rax
pop    %rbx
ret
lea    0xe31(%rip),%rax
pop    %rbx
ret
lea    0xe38(%rip),%rax
pop    %rbx
ret
lea    0xe3d(%rip),%rax
pop    %rbx
ret
lea    0xe43(%rip),%rax
pop    %rbx
ret
lea    0xe4c(%rip),%rax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"text/plain\00"
@.str.1 = [6 x i8] c".html\00"
@.str.2 = [10 x i8] c"text/html\00"
@.str.3 = [5 x i8] c".jpg\00"
@.str.4 = [11 x i8] c"image/jpeg\00"
@.str.5 = [5 x i8] c".css\00"
@.str.6 = [9 x i8] c"text/css\00"
@.str.7 = [5 x i8] c".gif\00"
@.str.8 = [10 x i8] c"image/gif\00"
@.str.9 = [5 x i8] c".ico\00"
@.str.10 = [13 x i8] c"image/x-icon\00"
@.str.11 = [5 x i8] c".png\00"
@.str.12 = [10 x i8] c"image/png\00"
@.str.13 = [4 x i8] c".js\00"
@.str.14 = [23 x i8] c"application/javascript\00"
define i8* @get_mime_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 %26, label %4
4: ; preds = %1
%5 = tail call i32 @strcasecmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %26, label %7
7: ; preds = %4
%8 = tail call i32 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %26, label %10
10: ; preds = %7
%11 = tail call i32 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %26, label %13
13: ; preds = %10
%14 = tail call i32 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %26, label %16
16: ; preds = %13
%17 = tail call i32 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %16
%20 = tail call i32 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = tail call i32 @strcasecmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
%25 = select i1 %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0)
br label %26
26: ; preds = %22, %19, %16, %13, %10, %7, %4, %1
%27 = 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.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), %7 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), %10 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), %13 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), %16 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), %19 ], [ %25, %22 ]
ret i8* %27
}