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


x86 assembly (clang, -O0):
<lookup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     135a <lookup+0x20a>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
je     1355 <lookup+0x205>
mov    -0x18(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    11dd <lookup+0x8d>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <tolower@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a5 <lookup+0x55>
mov    -0x20(%rbp),%rdi
lea    0xe18(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1207 <lookup+0xb7>
lea    0xe07(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1362 <lookup+0x212>
mov    -0x20(%rbp),%rdi
lea    0xdfc(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1231 <lookup+0xe1>
lea    0xdec(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1362 <lookup+0x212>
mov    -0x20(%rbp),%rdi
lea    0xde2(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    125b <lookup+0x10b>
lea    0xdd1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1362 <lookup+0x212>
mov    -0x20(%rbp),%rdi
lea    0xdc7(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1285 <lookup+0x135>
lea    0xdb6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1362 <lookup+0x212>
mov    -0x20(%rbp),%rdi
lea    0xdaf(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12af <lookup+0x15f>
lea    0xd9e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1362 <lookup+0x212>
mov    -0x20(%rbp),%rdi
lea    0xd95(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12d9 <lookup+0x189>
lea    0xd83(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1362 <lookup+0x212>
mov    -0x20(%rbp),%rdi
lea    0xd7f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1303 <lookup+0x1b3>
lea    0xd6e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1362 <lookup+0x212>
mov    -0x20(%rbp),%rdi
lea    0xd65(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    132d <lookup+0x1dd>
lea    0xd54(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1362 <lookup+0x212>
jmp    1332 <lookup+0x1e2>
jmp    1337 <lookup+0x1e7>
jmp    133c <lookup+0x1ec>
jmp    1341 <lookup+0x1f1>
jmp    1346 <lookup+0x1f6>
jmp    134b <lookup+0x1fb>
jmp    1350 <lookup+0x200>
jmp    1355 <lookup+0x205>
jmp    135a <lookup+0x20a>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookup>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     1263 <lookup+0x113>
mov    $0x2e,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     1263 <lookup+0x113>
mov    %rax,%r15
mov    %rax,%rdi
call   1070 <strdup@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     11b7 <lookup+0x67>
mov    %eax,%r12d
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%edi
call   1060 <tolower@plt>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11a0 <lookup+0x50>
lea    0xe42(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1271 <lookup+0x121>
lea    0xe38(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     127a <lookup+0x12a>
lea    0xe30(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1283 <lookup+0x133>
lea    0xe27(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     128c <lookup+0x13c>
lea    0xe25(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1295 <lookup+0x145>
lea    0xe21(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     129e <lookup+0x14e>
lea    0xe21(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12a7 <lookup+0x157>
lea    0xe1d(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12b0 <lookup+0x160>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xd8d(%rip),%rax
jmp    1265 <lookup+0x115>
lea    0xd93(%rip),%rax
jmp    1265 <lookup+0x115>
lea    0xd99(%rip),%rax
jmp    1265 <lookup+0x115>
lea    0xd9f(%rip),%rax
jmp    1265 <lookup+0x115>
lea    0xda8(%rip),%rax
jmp    1265 <lookup+0x115>
lea    0xdae(%rip),%rax
jmp    1265 <lookup+0x115>
lea    0xdba(%rip),%rax
jmp    1265 <lookup+0x115>
lea    0xdc1(%rip),%rax
jmp    1265 <lookup+0x115>

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 i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %87
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i8* @strrchr(i8* %11, i8 signext 46)
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = icmp ne i8* null, %13
br i1 %14, label %15, label %86
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = call i8* @strdup(i8* %16)
store i8* %17, i8** %5
store i32 1, i32* %6
%18 = load i8*, i8** %5
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %7
br label %20
20: ; preds = %35, %15
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %38
24: ; preds = %20
%25 = load i8*, i8** %4
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = call signext i8 @tolower(i8 signext %29)
%31 = load i8*, i8** %5
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 %30, i8* %34
br label %35
35: ; preds = %24
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %20
38: ; preds = %20
%39 = load i8*, i8** %5
%40 = call i64 @strcmp(i8* %39, 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 = %38
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %88
43: ; preds = %38
%44 = load i8*, i8** %5
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, 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.3, i64 0, i64 0), i8** %2
br label %88
48: ; preds = %43
%49 = load i8*, i8** %5
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %48
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %88
53: ; preds = %48
%54 = load i8*, i8** %5
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %53
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %88
58: ; preds = %53
%59 = load i8*, i8** %5
%60 = call i64 @strcmp(i8* %59, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %58
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %88
63: ; preds = %58
%64 = load i8*, i8** %5
%65 = call i64 @strcmp(i8* %64, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %63
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %88
68: ; preds = %63
%69 = load i8*, i8** %5
%70 = call i64 @strcmp(i8* %69, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %73
72: ; preds = %68
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %88
73: ; preds = %68
%74 = load i8*, i8** %5
%75 = call i64 @strcmp(i8* %74, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %78
77: ; preds = %73
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i8** %2
br label %88
78: ; preds = %73
br label %79
79: ; preds = %78
br label %80
80: ; preds = %79
br label %81
81: ; preds = %80
br label %82
82: ; preds = %81
br label %83
83: ; preds = %82
br label %84
84: ; preds = %83
br label %85
85: ; preds = %84
br label %86
86: ; preds = %85, %10
br label %87
87: ; preds = %86, %1
store i8* null, i8** %2
br label %88
88: ; preds = %87, %77, %72, %67, %62, %57, %52, %47, %42
%89 = load i8*, i8** %2
ret i8* %89
}

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 = icmp eq i8* %0, null
br i1 %2, label %46, label %3
3: ; preds = %1
%4 = tail call i8* @strrchr(i8* %0, i8 signext 46)
%5 = icmp eq i8* %4, null
br i1 %5, label %46, label %6
6: ; preds = %3
%7 = tail call i8* @strdup(i8* %4)
%8 = tail call i32 @strlen(i8* %7)
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = zext i32 %8 to i64
br label %15
12: ; preds = %15, %6
%13 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %44, label %23
15: ; preds = %10, %15
%16 = phi i64 [ 1, %10 ], [ %21, %15 ]
%17 = getelementptr inbounds i8, i8* %4, i64 %16
%18 = load i8, i8* %17
%19 = tail call signext i8 @tolower(i8 signext %18)
%20 = getelementptr inbounds i8, i8* %7, i64 %16
store i8 %19, i8* %20
%21 = add nuw nsw i64 %16, 1
%22 = icmp eq i64 %21, %11
br i1 %22, label %12, label %15
23: ; preds = %12
%24 = tail call i64 @strcmp(i8* %7, 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 %44, label %26
26: ; preds = %23
%27 = tail call i64 @strcmp(i8* %7, 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 %44, label %29
29: ; preds = %26
%30 = tail call i64 @strcmp(i8* %7, 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 %44, label %32
32: ; preds = %29
%33 = tail call i64 @strcmp(i8* %7, 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 %44, label %35
35: ; preds = %32
%36 = tail call i64 @strcmp(i8* %7, 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 %44, label %38
38: ; preds = %35
%39 = tail call i64 @strcmp(i8* %7, 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 %44, label %41
41: ; preds = %38
%42 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %41, %12, %23, %26, %29, %32, %35, %38
%45 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), %41 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), %38 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), %35 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), %32 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), %29 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), %26 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %23 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %12 ]
br label %46
46: ; preds = %1, %3, %41, %44
%47 = phi i8* [ %45, %44 ], [ null, %41 ], [ null, %3 ], [ null, %1 ]
ret i8* %47
}