#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 *);
int strlen(char *);
char *strrchr(char const *, char);
char tolower(char);
const char *lookup(const char *path) {
  char *suffixPtr = strrchr(path, '.');
  int suffixLength = strlen(suffixPtr);
  char suffix[suffixLength + 1];
  for (int i = 0; i < suffixLength; i++) {
    suffix[i] = tolower(suffixPtr[i]);
  }
  suffix[suffixLength] = '\0';
  if (strcmp(suffix, ".css") == 0)
    return "text/css";
  else if (strcmp(suffix, ".html") == 0)
    return "text/html";
  else if (strcmp(suffix, ".gif") == 0)
    return "image/gif";
  else if (strcmp(suffix, ".ico") == 0)
    return "image/x-icon";
  else if (strcmp(suffix, ".jpg") == 0)
    return "image/jpeg";
  else if (strcmp(suffix, ".js") == 0)
    return "text/javascript";
  else if (strcmp(suffix, ".php") == 0)
    return "text/x-php";
  else if (strcmp(suffix, ".png") == 0)
    return "image/png";
  else
    return NULL;
}


x86 assembly (clang, -O0):
<lookup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d2 <lookup+0x92>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <tolower@plt>
mov    %al,%dl
mov    -0x40(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    119a <lookup+0x5a>
mov    -0x40(%rbp),%rdi
movslq -0x1c(%rbp),%rax
movb   $0x0,(%rdi,%rax,1)
lea    0xe1b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    120b <lookup+0xcb>
lea    0xe0a(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    1371 <lookup+0x231>
mov    -0x40(%rbp),%rdi
lea    0xdf8(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    123c <lookup+0xfc>
lea    0xde8(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    1371 <lookup+0x231>
mov    -0x40(%rbp),%rdi
lea    0xdd7(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    126d <lookup+0x12d>
lea    0xdc6(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    1371 <lookup+0x231>
mov    -0x40(%rbp),%rdi
lea    0xdb5(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    129e <lookup+0x15e>
lea    0xda4(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    1371 <lookup+0x231>
mov    -0x40(%rbp),%rdi
lea    0xd96(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12cf <lookup+0x18f>
lea    0xd85(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    1371 <lookup+0x231>
mov    -0x40(%rbp),%rdi
lea    0xd75(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1300 <lookup+0x1c0>
lea    0xd63(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    1371 <lookup+0x231>
mov    -0x40(%rbp),%rdi
lea    0xd58(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1331 <lookup+0x1f1>
lea    0xd47(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    1371 <lookup+0x231>
mov    -0x40(%rbp),%rdi
lea    0xd37(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1362 <lookup+0x222>
lea    0xd26(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    1371 <lookup+0x231>
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookup>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1030 <strlen@plt>
mov    %eax,%r15d
lea    0x1(%r15),%eax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
test   %r15d,%r15d
jle    11a7 <lookup+0x67>
mov    %r15d,%r13d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%r12,%rbx,1),%edi
call   1060 <tolower@plt>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1190 <lookup+0x50>
movslq %r15d,%rax
movb   $0x0,(%r14,%rax,1)
lea    0xe4a(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     126b <lookup+0x12b>
lea    0xe40(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1274 <lookup+0x134>
lea    0xe38(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     127d <lookup+0x13d>
lea    0xe2f(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1286 <lookup+0x146>
lea    0xe2d(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     128f <lookup+0x14f>
lea    0xe29(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1298 <lookup+0x158>
lea    0xe29(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12a1 <lookup+0x161>
lea    0xe25(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
lea    0xe13(%rip),%rcx
cmove  %rcx,%rax
jmp    12a8 <lookup+0x168>
lea    0xd93(%rip),%rax
jmp    12a8 <lookup+0x168>
lea    0xd99(%rip),%rax
jmp    12a8 <lookup+0x168>
lea    0xd9f(%rip),%rax
jmp    12a8 <lookup+0x168>
lea    0xda5(%rip),%rax
jmp    12a8 <lookup+0x168>
lea    0xdae(%rip),%rax
jmp    12a8 <lookup+0x168>
lea    0xdb4(%rip),%rax
jmp    12a8 <lookup+0x168>
lea    0xdc0(%rip),%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c".css\00"
@.str.1 = [9 x i8] c"text/css\00"
@.str.2 = [6 x i8] c".html\00"
@.str.3 = [10 x i8] c"text/html\00"
@.str.4 = [5 x i8] c".gif\00"
@.str.5 = [10 x i8] c"image/gif\00"
@.str.6 = [5 x i8] c".ico\00"
@.str.7 = [13 x i8] c"image/x-icon\00"
@.str.8 = [5 x i8] c".jpg\00"
@.str.9 = [11 x i8] c"image/jpeg\00"
@.str.10 = [4 x i8] c".js\00"
@.str.11 = [16 x i8] c"text/javascript\00"
@.str.12 = [5 x i8] c".php\00"
@.str.13 = [11 x i8] c"text/x-php\00"
@.str.14 = [5 x i8] c".png\00"
@.str.15 = [10 x i8] c"image/png\00"
define i8* @lookup(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
%10 = load i8*, i8** %3
%11 = call i8* @strrchr(i8* %10, i8 signext 46)
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %6
%18 = alloca i8, i64 %16
store i64 %16, i64* %7
store i32 0, i32* %8
br label %19
19: ; preds = %33, %1
%20 = load i32, i32* %8
%21 = load i32, i32* %5
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %36
23: ; preds = %19
%24 = load i8*, i8** %4
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = call signext i8 @tolower(i8 signext %28)
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %18, i64 %31
store i8 %29, i8* %32
br label %33
33: ; preds = %23
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %19
36: ; preds = %19
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %18, i64 %38
store i8 0, i8* %39
%40 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %36
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %2
store i32 1, i32* %9
br label %72
43: ; preds = %36
%44 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %43
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %2
store i32 1, i32* %9
br label %72
47: ; preds = %43
%48 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %47
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8** %2
store i32 1, i32* %9
br label %72
51: ; preds = %47
%52 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %51
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8** %2
store i32 1, i32* %9
br label %72
55: ; preds = %51
%56 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %55
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8** %2
store i32 1, i32* %9
br label %72
59: ; preds = %55
%60 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %59
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8** %2
store i32 1, i32* %9
br label %72
63: ; preds = %59
%64 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %63
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), i8** %2
store i32 1, i32* %9
br label %72
67: ; preds = %63
%68 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %67
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i8** %2
store i32 1, i32* %9
br label %72
71: ; preds = %67
store i8* null, i8** %2
store i32 1, i32* %9
br label %72
72: ; preds = %71, %70, %66, %62, %58, %54, %50, %46, %42
%73 = load i8*, i8** %6
%74 = load i8*, i8** %2
ret i8* %74
}

LLVM IR (-O2):
@.str = [5 x i8] c".css\00"
@.str.1 = [9 x i8] c"text/css\00"
@.str.2 = [6 x i8] c".html\00"
@.str.3 = [10 x i8] c"text/html\00"
@.str.4 = [5 x i8] c".gif\00"
@.str.5 = [10 x i8] c"image/gif\00"
@.str.6 = [5 x i8] c".ico\00"
@.str.7 = [13 x i8] c"image/x-icon\00"
@.str.8 = [5 x i8] c".jpg\00"
@.str.9 = [11 x i8] c"image/jpeg\00"
@.str.10 = [4 x i8] c".js\00"
@.str.11 = [16 x i8] c"text/javascript\00"
@.str.12 = [5 x i8] c".php\00"
@.str.13 = [11 x i8] c"text/x-php\00"
@.str.14 = [5 x i8] c".png\00"
@.str.15 = [10 x i8] c"image/png\00"
define i8* @lookup(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%3 = tail call i32 @strlen(i8* %2)
%4 = add nsw i32 %3, 1
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = icmp sgt i32 %3, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = zext i32 %3 to i64
br label %15
10: ; preds = %15, %1
%11 = sext i32 %3 to i64
%12 = getelementptr inbounds i8, i8* %6, i64 %11
store i8 0, i8* %12
%13 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %45, label %23
15: ; preds = %8, %15
%16 = phi i64 [ 0, %8 ], [ %21, %15 ]
%17 = getelementptr inbounds i8, i8* %2, i64 %16
%18 = load i8, i8* %17
%19 = tail call signext i8 @tolower(i8 signext %18)
%20 = getelementptr inbounds i8, i8* %6, i64 %16
store i8 %19, i8* %20
%21 = add nuw nsw i64 %16, 1
%22 = icmp eq i64 %21, %9
br i1 %22, label %10, label %15
23: ; preds = %10
%24 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %45, label %26
26: ; preds = %23
%27 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %45, label %29
29: ; preds = %26
%30 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %45, label %32
32: ; preds = %29
%33 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %45, label %35
35: ; preds = %32
%36 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %45, label %38
38: ; preds = %35
%39 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %45, label %41
41: ; preds = %38
%42 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
%44 = select i1 %43, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i8* null
br label %45
45: ; preds = %41, %38, %35, %32, %29, %26, %23, %10
%46 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %10 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %23 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), %26 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), %29 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), %32 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), %35 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), %38 ], [ %44, %41 ]
ret i8* %46
}