#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 *);
const char *lookup(const char *extension) {
  int result = 7;
  char *exts[7] = {"css", "gif", "html", "ico", "jpg", "js", "png"};
  for (int ii = 0; ii < 7; ++ii) {
    if (strcasecmp(extension, exts[ii]) == 0) {
      result = ii;
      break;
    }
  }
  switch (result) {
  case 0:
    return ("text/css");
    break;
  case 1:
    return ("image/gif");
    break;
  case 2:
    return ("text/html");
    break;
  case 3:
    return ("image/x-icon");
    break;
  case 4:
    return ("image/jpeg");
    break;
  case 5:
    return ("text/javascript");
    break;
  case 6:
    return ("image/png");
    break;
  default:
    return (NULL);
    break;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<lookup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x7,-0x14(%rbp)
lea    -0x50(%rbp),%rdi
lea    0x2ca2(%rip),%rsi
mov    $0x38,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x7,-0x54(%rbp)
jge    1193 <lookup+0x73>
mov    -0x10(%rbp),%rdi
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1180 <lookup+0x60>
mov    -0x54(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1193 <lookup+0x73>
jmp    1185 <lookup+0x65>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    114f <lookup+0x2f>
mov    -0x14(%rbp),%eax
mov    %rax,-0x60(%rbp)
sub    $0x6,%rax
ja     1228 <lookup+0x108>
mov    -0x60(%rbp),%rax
lea    0xe51(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe68(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1230 <lookup+0x110>
lea    0xe61(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1230 <lookup+0x110>
lea    0xe5b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1230 <lookup+0x110>
lea    0xe55(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1230 <lookup+0x110>
lea    0xe52(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1230 <lookup+0x110>
lea    0xe4d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1230 <lookup+0x110>
lea    0xe4d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1230 <lookup+0x110>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookup>:
push   %rbx
mov    %rdi,%rbx
lea    0xef5(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11b1 <lookup+0xa1>
lea    0xeea(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11ba <lookup+0xaa>
lea    0xedf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11c3 <lookup+0xb3>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11cc <lookup+0xbc>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11d5 <lookup+0xc5>
lea    0xe88(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11de <lookup+0xce>
lea    0xec2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
lea    0xea5(%rip),%rcx
cmove  %rcx,%rax
pop    %rbx
ret
lea    0xe53(%rip),%rax
pop    %rbx
ret
lea    0xe53(%rip),%rax
pop    %rbx
ret
lea    0xe54(%rip),%rax
pop    %rbx
ret
lea    0xe55(%rip),%rax
pop    %rbx
ret
lea    0xe59(%rip),%rax
pop    %rbx
ret
lea    0xe5b(%rip),%rax
pop    %rbx
ret

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

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