#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__ strcasecmp(char const *, char *);
int strlen(char const *);
const char *get_mime_type(const char *name) {
  size_t dot = strlen(name) - 1;
  while (dot >= 0 && name[dot] != '.')
    --dot;
  if (0 == strcasecmp(name + dot, ".html"))
    return "text/html";
  if (0 == strcasecmp(name + dot, ".htm"))
    return "text/html";
  if (0 == strcasecmp(name + dot, ".css"))
    return "text/css";
  if (0 == strcasecmp(name + dot, ".js"))
    return "text/javascript";
  if (0 == strcasecmp(name + dot, ".jpg"))
    return "image/jpg";
  if (0 == strcasecmp(name + dot, ".png"))
    return "image/png";
  if (0 == strcasecmp(name + dot, ".gif"))
    return "image/gif";
  return "application/octet-stream";
}


x86 assembly (clang, -O0):
<get_mime_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
jb     1163 <get_mime_type+0x43>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1173 <get_mime_type+0x53>
jmp    1184 <get_mime_type+0x64>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    113e <get_mime_type+0x1e>
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11b6 <get_mime_type+0x96>
lea    0xe59(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ed <get_mime_type+0x1cd>
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11e8 <get_mime_type+0xc8>
lea    0xe27(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ed <get_mime_type+0x1cd>
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    121a <get_mime_type+0xfa>
lea    0xe09(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ed <get_mime_type+0x1cd>
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
lea    0xdfa(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    124c <get_mime_type+0x12c>
lea    0xde4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ed <get_mime_type+0x1cd>
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
lea    0xddc(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    127e <get_mime_type+0x15e>
lea    0xdc7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ed <get_mime_type+0x1cd>
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
lea    0xdb9(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    12b0 <get_mime_type+0x190>
lea    0xda4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ed <get_mime_type+0x1cd>
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
lea    0xd96(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    12e2 <get_mime_type+0x1c2>
lea    0xd81(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ed <get_mime_type+0x1cd>
lea    0xd7b(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mime_type>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
movslq %eax,%rbx
add    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpb   $0x2e,-0x1(%rbx)
lea    -0x1(%rbx),%rbx
jne    1140 <get_mime_type+0x20>
lea    0xeaf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
lea    0xea6(%rip),%r14
test   %rax,%rax
je     1219 <get_mime_type+0xf9>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1219 <get_mime_type+0xf9>
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11f7 <get_mime_type+0xd7>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1200 <get_mime_type+0xe0>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1209 <get_mime_type+0xe9>
lea    0xe82(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1212 <get_mime_type+0xf2>
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
lea    0xe70(%rip),%rax
lea    0xe73(%rip),%r14
cmove  %rax,%r14
jmp    1219 <get_mime_type+0xf9>
lea    0xe1c(%rip),%r14
jmp    1219 <get_mime_type+0xf9>
lea    0xe20(%rip),%r14
jmp    1219 <get_mime_type+0xf9>
lea    0xe2c(%rip),%r14
jmp    1219 <get_mime_type+0xf9>
lea    0xe32(%rip),%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
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".htm\00"
@.str.3 = [5 x i8] c".css\00"
@.str.4 = [9 x i8] c"text/css\00"
@.str.5 = [4 x i8] c".js\00"
@.str.6 = [16 x i8] c"text/javascript\00"
@.str.7 = [5 x i8] c".jpg\00"
@.str.8 = [10 x i8] c"image/jpg\00"
@.str.9 = [5 x i8] c".png\00"
@.str.10 = [10 x i8] c"image/png\00"
@.str.11 = [5 x i8] c".gif\00"
@.str.12 = [10 x i8] c"image/gif\00"
@.str.13 = [25 x i8] c"application/octet-stream\00"
define i8* @get_mime_type(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
%7 = sub nsw i32 %6, 1
%8 = sext i32 %7 to i64
store i64 %8, i64* %4
br label %9
9: ; preds = %21, %1
%10 = load i64, i64* %4
%11 = icmp uge i64 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i8*, i8** %3
%14 = load i64, i64* %4
%15 = getelementptr inbounds i8, i8* %13, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 46
br label %19
19: ; preds = %12, %9
%20 = phi i1 [ false, %9 ], [ %18, %12 ]
br i1 %20, label %21, label %24
21: ; preds = %19
%22 = load i64, i64* %4
%23 = add i64 %22, -1
store i64 %23, i64* %4
br label %9
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = load i64, i64* %4
%27 = getelementptr inbounds i8, i8* %25, i64 %26
%28 = call i64 @strcasecmp(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%29 = icmp eq i64 0, %28
br i1 %29, label %30, label %31
30: ; preds = %24
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %74
31: ; preds = %24
%32 = load i8*, i8** %3
%33 = load i64, i64* %4
%34 = getelementptr inbounds i8, i8* %32, i64 %33
%35 = call i64 @strcasecmp(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp eq i64 0, %35
br i1 %36, label %37, label %38
37: ; preds = %31
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %74
38: ; preds = %31
%39 = load i8*, i8** %3
%40 = load i64, i64* %4
%41 = getelementptr inbounds i8, i8* %39, i64 %40
%42 = call i64 @strcasecmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%43 = icmp eq i64 0, %42
br i1 %43, label %44, label %45
44: ; preds = %38
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %74
45: ; preds = %38
%46 = load i8*, i8** %3
%47 = load i64, i64* %4
%48 = getelementptr inbounds i8, i8* %46, i64 %47
%49 = call i64 @strcasecmp(i8* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%50 = icmp eq i64 0, %49
br i1 %50, label %51, label %52
51: ; preds = %45
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %74
52: ; preds = %45
%53 = load i8*, i8** %3
%54 = load i64, i64* %4
%55 = getelementptr inbounds i8, i8* %53, i64 %54
%56 = call i64 @strcasecmp(i8* %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%57 = icmp eq i64 0, %56
br i1 %57, label %58, label %59
58: ; preds = %52
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %74
59: ; preds = %52
%60 = load i8*, i8** %3
%61 = load i64, i64* %4
%62 = getelementptr inbounds i8, i8* %60, i64 %61
%63 = call i64 @strcasecmp(i8* %62, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%64 = icmp eq i64 0, %63
br i1 %64, label %65, label %66
65: ; preds = %59
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %74
66: ; preds = %59
%67 = load i8*, i8** %3
%68 = load i64, i64* %4
%69 = getelementptr inbounds i8, i8* %67, i64 %68
%70 = call i64 @strcasecmp(i8* %69, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%71 = icmp eq i64 0, %70
br i1 %71, label %72, label %73
72: ; preds = %66
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %74
73: ; preds = %66
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %74
74: ; preds = %73, %72, %65, %58, %51, %44, %37, %30
%75 = load i8*, i8** %2
ret i8* %75
}

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".htm\00"
@.str.3 = [5 x i8] c".css\00"
@.str.4 = [9 x i8] c"text/css\00"
@.str.5 = [4 x i8] c".js\00"
@.str.6 = [16 x i8] c"text/javascript\00"
@.str.7 = [5 x i8] c".jpg\00"
@.str.8 = [10 x i8] c"image/jpg\00"
@.str.9 = [5 x i8] c".png\00"
@.str.10 = [10 x i8] c"image/png\00"
@.str.11 = [5 x i8] c".gif\00"
@.str.12 = [10 x i8] c"image/gif\00"
@.str.13 = [25 x i8] c"application/octet-stream\00"
define i8* @get_mime_type(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, -1
%4 = sext i32 %3 to i64
br label %5
5: ; preds = %5, %1
%6 = phi i64 [ %4, %1 ], [ %10, %5 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 46
%10 = add i64 %6, -1
br i1 %9, label %11, label %5
11: ; preds = %5
%12 = getelementptr inbounds i8, i8* %0, i64 %6
%13 = tail call i64 @strcasecmp(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %34, label %15
15: ; preds = %11
%16 = tail call i64 @strcasecmp(i8* %12, 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 %34, label %18
18: ; preds = %15
%19 = tail call i64 @strcasecmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %34, label %21
21: ; preds = %18
%22 = tail call i64 @strcasecmp(i8* %12, 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 %34, label %24
24: ; preds = %21
%25 = tail call i64 @strcasecmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %34, label %27
27: ; preds = %24
%28 = tail call i64 @strcasecmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %27
%31 = tail call i64 @strcasecmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
%33 = select i1 %32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0)
br label %34
34: ; preds = %30, %27, %24, %21, %18, %15, %11
%35 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %11 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %15 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), %18 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), %21 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), %24 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), %27 ], [ %33, %30 ]
ret i8* %35
}