#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 *, char *);
char *strrchr(char const *, char const);
const char *lookup(const char *path) {
  const int SIZE = 8;
  const char dot = '.';
  char *getExtension = strrchr(path, dot);
  char *extensions[8] = {".css", ".html", ".gif", ".ico",
                         ".jpg", ".js",   ".php", ".png"};
  char *texts[8] = {"text/css",     "text/html",  "image/gif",
                    "image/x-icon", "image/jpeg", "text/javascript",
                    "text/x-php",   "image/png"};
  for (int i = 0; i < SIZE; i++) {
    if (strcasecmp(getExtension, extensions[i]) == 0) {
      return texts[i];
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<lookup>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x8,-0x14(%rbp)
movb   $0x2e,-0x15(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
lea    -0x60(%rbp),%rdi
lea    0x2c39(%rip),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
lea    -0xa0(%rbp),%rdi
lea    0x2c61(%rip),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0xa4(%rbp)
cmpl   $0x8,-0xa4(%rbp)
jge    11f0 <lookup+0xc0>
mov    -0x20(%rbp),%rdi
movslq -0xa4(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11d7 <lookup+0xa7>
movslq -0xa4(%rbp),%rax
mov    -0xa0(%rbp,%rax,8),%rax
ff
mov    %rax,-0x8(%rbp)
jmp    11f8 <lookup+0xc8>
jmp    11dc <lookup+0xac>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    1193 <lookup+0x63>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookup>:
push   %rbx
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,%rbx
lea    0xecb(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11da <lookup+0xba>
lea    0xeb8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11de <lookup+0xbe>
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11e5 <lookup+0xc5>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11ec <lookup+0xcc>
lea    0xe88(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11f3 <lookup+0xd3>
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11fa <lookup+0xda>
lea    0xe69(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1201 <lookup+0xe1>
lea    0xe5a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1208 <lookup+0xe8>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
jmp    120d <lookup+0xed>
mov    $0x1,%eax
jmp    120d <lookup+0xed>
mov    $0x2,%eax
jmp    120d <lookup+0xed>
mov    $0x3,%eax
jmp    120d <lookup+0xed>
mov    $0x4,%eax
jmp    120d <lookup+0xed>
mov    $0x5,%eax
jmp    120d <lookup+0xed>
mov    $0x6,%eax
jmp    120d <lookup+0xed>
mov    $0x7,%eax
lea    0xe70(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c".css\00"
@.str.1 = [6 x i8] c".html\00"
@.str.2 = [5 x i8] c".gif\00"
@.str.3 = [5 x i8] c".ico\00"
@.str.4 = [5 x i8] c".jpg\00"
@.str.5 = [4 x i8] c".js\00"
@.str.6 = [5 x i8] c".php\00"
@.str.7 = [5 x i8] c".png\00"
@__const.lookup.extensions = [8 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0)]
@.str.8 = [9 x i8] c"text/css\00"
@.str.9 = [10 x i8] c"text/html\00"
@.str.10 = [10 x i8] c"image/gif\00"
@.str.11 = [13 x i8] c"image/x-icon\00"
@.str.12 = [11 x i8] c"image/jpeg\00"
@.str.13 = [16 x i8] c"text/javascript\00"
@.str.14 = [11 x i8] c"text/x-php\00"
@.str.15 = [10 x i8] c"image/png\00"
@__const.lookup.texts = [8 x i8*] [i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i32 0, i32 0)]
define i8* @lookup(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8*
%7 = alloca [8 x i8*]
%8 = alloca [8 x i8*]
%9 = alloca i32
store i8* %0, i8** %3
store i32 8, i32* %4
store i8 46, i8* %5
%10 = load i8*, i8** %3
%11 = call i8* @strrchr(i8* %10, i8 signext 46)
store i8* %11, i8** %6
%12 = bitcast [8 x i8*]* %7 to i8*
%13 = bitcast [8 x i8*]* %8 to i8*
store i32 0, i32* %9
br label %14
14: ; preds = %31, %1
%15 = load i32, i32* %9
%16 = icmp slt i32 %15, 8
br i1 %16, label %17, label %34
17: ; preds = %14
%18 = load i8*, i8** %6
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [8 x i8*], [8 x i8*]* %7, i64 0, i64 %20
%22 = load i8*, i8** %21
%23 = call i64 @strcasecmp(i8* %18, i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %17
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [8 x i8*], [8 x i8*]* %8, i64 0, i64 %27
%29 = load i8*, i8** %28
store i8* %29, i8** %2
br label %35
30: ; preds = %17
br label %31
31: ; preds = %30
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
store i32 %33, i32* %9
br label %14
34: ; preds = %14
store i8* null, i8** %2
br label %35
35: ; preds = %34, %25
%36 = load i8*, i8** %2
ret i8* %36
}

LLVM IR (-O2):
@.str = [5 x i8] c".css\00"
@.str.1 = [6 x i8] c".html\00"
@.str.2 = [5 x i8] c".gif\00"
@.str.3 = [5 x i8] c".ico\00"
@.str.4 = [5 x i8] c".jpg\00"
@.str.5 = [4 x i8] c".js\00"
@.str.6 = [5 x i8] c".php\00"
@.str.7 = [5 x i8] c".png\00"
@.str.8 = [9 x i8] c"text/css\00"
@.str.9 = [10 x i8] c"text/html\00"
@.str.10 = [10 x i8] c"image/gif\00"
@.str.11 = [13 x i8] c"image/x-icon\00"
@.str.12 = [11 x i8] c"image/jpeg\00"
@.str.13 = [16 x i8] c"text/javascript\00"
@.str.14 = [11 x i8] c"text/x-php\00"
@.str.15 = [10 x i8] c"image/png\00"
@reltable.lookup = [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.8 to i64), i64 ptrtoint ([8 x i32]* @reltable.lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.9 to i64), i64 ptrtoint ([8 x i32]* @reltable.lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.10 to i64), i64 ptrtoint ([8 x i32]* @reltable.lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.11 to i64), i64 ptrtoint ([8 x i32]* @reltable.lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.12 to i64), i64 ptrtoint ([8 x i32]* @reltable.lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.13 to i64), i64 ptrtoint ([8 x i32]* @reltable.lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.14 to i64), i64 ptrtoint ([8 x i32]* @reltable.lookup to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.15 to i64), i64 ptrtoint ([8 x i32]* @reltable.lookup to i64)) to i32)]
define i8* @lookup(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%3 = tail call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %27, %24, %21, %18, %15, %12, %9, %1
%6 = phi i64 [ 0, %1 ], [ 1, %9 ], [ 2, %12 ], [ 3, %15 ], [ 4, %18 ], [ 5, %21 ], [ 6, %24 ], [ 7, %27 ]
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.lookup to i8*), i64 %7)
br label %30
9: ; preds = %1
%10 = tail call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %5, label %12
12: ; preds = %9
%13 = tail call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %5, label %15
15: ; preds = %12
%16 = tail call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %5, label %18
18: ; preds = %15
%19 = tail call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %5, label %21
21: ; preds = %18
%22 = tail call i64 @strcasecmp(i8* %2, 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 %5, label %24
24: ; preds = %21
%25 = tail call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %5, label %27
27: ; preds = %24
%28 = tail call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %5, label %30
30: ; preds = %27, %5
%31 = phi i8* [ %8, %5 ], [ null, %27 ]
ret i8* %31
}