#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 */
char *secGetStringPart(char const *, int, int);
scalar_t__ strlen(char const *);
scalar_t__ strncasecmp(char *, char const *, scalar_t__);
char *parseExtension(const char *cp_filename) {
  char *cp_extension = NULL;
  const char *ccp_file_type[] = {"png", "html", "txt", "css", NULL};
  char *cp_content_type[] = {"image/png", "text/html", "text/plain", "text/css",
                             "application/octet-stream"};
  int i_str_end = strlen(cp_filename) - 1;
  int i_str_beginn = strlen(cp_filename) - 1;
  int i = 0;
  for (; i_str_beginn > 0 && cp_filename[i_str_beginn] != '.'; i_str_beginn--)
    ;
  cp_extension = secGetStringPart(cp_filename, i_str_beginn + 1, i_str_end);
  for (; i < 4; i++)
    if (strlen(cp_extension) == strlen(ccp_file_type[i]))
      if (strncasecmp(cp_extension, ccp_file_type[i],
                      strlen(ccp_file_type[i])) == 0)
        return cp_content_type[i];
  return cp_content_type[4];
}


x86 assembly (clang, -O0):
<parseExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
lea    0xe9c(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe7c(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe99(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
lea    0xe5a(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xe59(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xe58(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xe58(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xe56(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%rax
mov    %eax,-0x74(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%rax
mov    %eax,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x78(%rbp)
mov    %al,-0x7d(%rbp)
jle    1225 <parseExtension+0xe5>
mov    -0x10(%rbp),%rax
movslq -0x78(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
setne  %al
mov    %al,-0x7d(%rbp)
mov    -0x7d(%rbp),%al
test   $0x1,%al
jne    1235 <parseExtension+0xf5>
jmp    1248 <parseExtension+0x108>
jmp    123a <parseExtension+0xfa>
mov    -0x78(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x78(%rbp)
jmp    1201 <parseExtension+0xc1>
mov    -0x10(%rbp),%rdi
mov    -0x78(%rbp),%esi
add    $0x1,%esi
mov    -0x74(%rbp),%edx
call   1040 <secGetStringPart@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x4,-0x7c(%rbp)
jge    130c <parseExtension+0x1cc>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x88(%rbp)
movslq -0x7c(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x88(%rbp),%rax
cmp    %rcx,%rax
jne    12f9 <parseExtension+0x1b9>
mov    -0x18(%rbp),%rax
mov    %rax,-0x98(%rbp)
movslq -0x7c(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rax
mov    %rax,-0x90(%rbp)
movslq -0x7c(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1030 <strlen@plt>
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    %rax,%rdx
call   1060 <strncasecmp@plt>
cmp    $0x0,%rax
jne    12f4 <parseExtension+0x1b4>
movslq -0x7c(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rax
mov    %rax,-0x8(%rbp)
jmp    1314 <parseExtension+0x1d4>
jmp    12f9 <parseExtension+0x1b9>
jmp    12fe <parseExtension+0x1be>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    125e <parseExtension+0x11e>
mov    -0x50(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseExtension>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
lea    0xec1(%rip),%rax
mov    %rax,(%rsp)
lea    0xec0(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xebe(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xebd(%rip),%rax
mov    %rax,0x18(%rsp)
call   1030 <strlen@plt>
lea    -0x1(%rax),%edx
mov    %edx,%esi
test   %edx,%edx
jle    1199 <parseExtension+0x69>
nopl   0x0(%rax)
lea    -0x1(%rax),%ecx
cmpb   $0x2e,(%rbx,%rcx,1)
je     1194 <parseExtension+0x64>
mov    %ecx,%eax
cmp    $0x1,%ecx
jg     1180 <parseExtension+0x50>
xor    %esi,%esi
jmp    1199 <parseExtension+0x69>
add    $0xffffffff,%eax
mov    %eax,%esi
add    $0x1,%esi
mov    %rbx,%rdi
call   1040 <secGetStringPart@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1030 <strlen@plt>
mov    %rax,%rbx
lea    0xe73(%rip),%r14
cmp    $0x4,%rax
je     1211 <parseExtension+0xe1>
cmp    $0x3,%rbx
jne    123c <parseExtension+0x10c>
lea    0xe3e(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     122f <parseExtension+0xff>
lea    0xe1d(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     1233 <parseExtension+0x103>
lea    0xe2e(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
call   1050 <strncasecmp@plt>
test   %rax,%rax
jne    123c <parseExtension+0x10c>
mov    $0x3,%eax
jmp    1238 <parseExtension+0x108>
lea    0xdfb(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
call   1050 <strncasecmp@plt>
test   %rax,%rax
jne    123c <parseExtension+0x10c>
mov    $0x1,%eax
jmp    1238 <parseExtension+0x108>
xor    %eax,%eax
jmp    1238 <parseExtension+0x108>
mov    $0x2,%eax
mov    (%rsp,%rax,8),%r14
mov    %r14,%rax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"png\00"
@.str.1 = [5 x i8] c"html\00"
@.str.2 = [4 x i8] c"txt\00"
@.str.3 = [4 x i8] c"css\00"
@.str.4 = [10 x i8] c"image/png\00"
@.str.5 = [10 x i8] c"text/html\00"
@.str.6 = [11 x i8] c"text/plain\00"
@.str.7 = [9 x i8] c"text/css\00"
@.str.8 = [25 x i8] c"application/octet-stream\00"
define i8* @parseExtension(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [5 x i8*]
%6 = alloca [5 x i8*]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store i8* null, i8** %4
%10 = bitcast [5 x i8*]* %5 to i8*
%11 = bitcast i8* %10 to [5 x i8*]*
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8** %14
%15 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8** %15
%16 = bitcast [5 x i8*]* %6 to i8*
%17 = bitcast i8* %16 to [5 x i8*]*
%18 = getelementptr inbounds [5 x i8*], [5 x i8*]* %17, i32 0, i32 0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i32 0, i32 0), i8** %18
%19 = getelementptr inbounds [5 x i8*], [5 x i8*]* %17, i32 0, i32 1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8** %19
%20 = getelementptr inbounds [5 x i8*], [5 x i8*]* %17, i32 0, i32 2
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i32 0, i32 0), i8** %20
%21 = getelementptr inbounds [5 x i8*], [5 x i8*]* %17, i32 0, i32 3
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i32 0, i32 0), i8** %21
%22 = getelementptr inbounds [5 x i8*], [5 x i8*]* %17, i32 0, i32 4
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i32 0, i32 0), i8** %22
%23 = load i8*, i8** %3
%24 = call i64 @strlen(i8* %23)
%25 = sub nsw i64 %24, 1
%26 = trunc i64 %25 to i32
store i32 %26, i32* %7
%27 = load i8*, i8** %3
%28 = call i64 @strlen(i8* %27)
%29 = sub nsw i64 %28, 1
%30 = trunc i64 %29 to i32
store i32 %30, i32* %8
store i32 0, i32* %9
br label %31
31: ; preds = %45, %1
%32 = load i32, i32* %8
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %42
34: ; preds = %31
%35 = load i8*, i8** %3
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 46
br label %42
42: ; preds = %34, %31
%43 = phi i1 [ false, %31 ], [ %41, %34 ]
br i1 %43, label %44, label %48
44: ; preds = %42
br label %45
45: ; preds = %44
%46 = load i32, i32* %8
%47 = add nsw i32 %46, -1
store i32 %47, i32* %8
br label %31
48: ; preds = %42
%49 = load i8*, i8** %3
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
%52 = load i32, i32* %7
%53 = call i8* @secGetStringPart(i8* %49, i32 %51, i32 %52)
store i8* %53, i8** %4
br label %54
54: ; preds = %86, %48
%55 = load i32, i32* %9
%56 = icmp slt i32 %55, 4
br i1 %56, label %57, label %89
57: ; preds = %54
%58 = load i8*, i8** %4
%59 = call i64 @strlen(i8* %58)
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 %61
%63 = load i8*, i8** %62
%64 = call i64 @strlen(i8* %63)
%65 = icmp eq i64 %59, %64
br i1 %65, label %66, label %85
66: ; preds = %57
%67 = load i8*, i8** %4
%68 = load i32, i32* %9
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 %69
%71 = load i8*, i8** %70
%72 = load i32, i32* %9
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 %73
%75 = load i8*, i8** %74
%76 = call i64 @strlen(i8* %75)
%77 = call i64 @strncasecmp(i8* %67, i8* %71, i64 %76)
%78 = icmp eq i64 %77, 0
br i1 %78, label %79, label %84
79: ; preds = %66
%80 = load i32, i32* %9
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [5 x i8*], [5 x i8*]* %6, i64 0, i64 %81
%83 = load i8*, i8** %82
store i8* %83, i8** %2
br label %92
84: ; preds = %66
br label %85
85: ; preds = %84, %57
br label %86
86: ; preds = %85
%87 = load i32, i32* %9
%88 = add nsw i32 %87, 1
store i32 %88, i32* %9
br label %54
89: ; preds = %54
%90 = getelementptr inbounds [5 x i8*], [5 x i8*]* %6, i64 0, i64 4
%91 = load i8*, i8** %90
store i8* %91, i8** %2
br label %92
92: ; preds = %89, %79
%93 = load i8*, i8** %2
ret i8* %93
}

LLVM IR (-O2):
@.str = [4 x i8] c"png\00"
@.str.1 = [5 x i8] c"html\00"
@.str.2 = [4 x i8] c"txt\00"
@.str.3 = [4 x i8] c"css\00"
@.str.4 = [10 x i8] c"image/png\00"
@.str.5 = [10 x i8] c"text/html\00"
@.str.6 = [11 x i8] c"text/plain\00"
@.str.7 = [9 x i8] c"text/css\00"
@.str.8 = [25 x i8] c"application/octet-stream\00"
define i8* @parseExtension(i8* %0) {
%2 = alloca [5 x i8*]
%3 = bitcast [5 x i8*]* %2 to i8*
%4 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 2
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 3
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8** %7
%8 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%9 = trunc i64 %8 to i32
%10 = add i32 %9, -1
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %1, %18
%13 = phi i32 [ %19, %18 ], [ %10, %1 ]
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 46
br i1 %17, label %21, label %18
18: ; preds = %12
%19 = add nsw i32 %13, -1
%20 = icmp sgt i32 %13, 1
br i1 %20, label %12, label %21
21: ; preds = %12, %18, %1
%22 = phi i32 [ %10, %1 ], [ 0, %18 ], [ %13, %12 ]
%23 = add nsw i32 %22, 1
%24 = tail call i8* @secGetStringPart(i8* %0, i32 %23, i32 %10)
%25 = tail call i64 @strlen(i8* dereferenceable(1) %24)
switch i64 %25, label %42 [
i64 3, label %26
i64 4, label %33
]
26: ; preds = %21
%27 = tail call i64 @strncasecmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %25)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %39, %36, %33, %26
%30 = phi i64 [ 0, %26 ], [ 1, %33 ], [ 2, %36 ], [ 3, %39 ]
%31 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 %30
%32 = load i8*, i8** %31
br label %42
33: ; preds = %21
%34 = tail call i64 @strncasecmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %25)
%35 = icmp eq i64 %34, 0
br i1 %35, label %29, label %42
36: ; preds = %26
%37 = tail call i64 @strncasecmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %25)
%38 = icmp eq i64 %37, 0
br i1 %38, label %29, label %39
39: ; preds = %36
%40 = tail call i64 @strncasecmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %25)
%41 = icmp eq i64 %40, 0
br i1 %41, label %29, label %42
42: ; preds = %21, %39, %33, %29
%43 = phi i8* [ %32, %29 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), %33 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), %39 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), %21 ]
ret i8* %43
}