#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 */
int /*<<< orphan*/ strcasecmp(char *, char *);
int strlen(char *);
char *type_fichier(char *chemin) {
  int len = strlen(chemin);
  if (!strcasecmp(chemin + len - 5, ".html") ||
      !strcasecmp(chemin + len - 4, ".htm"))
    return "text/html";
  if (!strcasecmp(chemin + len - 4, ".css"))
    return "text/css";
  if (!strcasecmp(chemin + len - 4, ".png"))
    return "image/png";
  if (!strcasecmp(chemin + len - 4, ".gif"))
    return "image/gif";
  if (!strcasecmp(chemin + len - 5, ".jpeg") ||
      !strcasecmp(chemin + len - 4, ".jpg"))
    return "image/jpeg";
  return "text/ascii";
}


x86 assembly (clang, -O0):
<type_fichier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffb,%rdi
lea    0xeb2(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     1180 <type_fichier+0x60>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe94(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1190 <type_fichier+0x70>
lea    0xe84(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128f <type_fichier+0x16f>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe6f(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11c4 <type_fichier+0xa4>
lea    0xe5f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128f <type_fichier+0x16f>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe49(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11f8 <type_fichier+0xd8>
lea    0xe39(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128f <type_fichier+0x16f>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe24(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    122c <type_fichier+0x10c>
lea    0xe14(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128f <type_fichier+0x16f>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffb,%rdi
lea    0xdff(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     1274 <type_fichier+0x154>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xde1(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1284 <type_fichier+0x164>
lea    0xdd1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128f <type_fichier+0x16f>
lea    0xdcc(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<type_fichier>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <strlen@plt>
movslq %eax,%r12
lea    (%rbx,%r12,1),%r14
add    $0xfffffffffffffffb,%r14
lea    0xebe(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcasecmp@plt>
lea    0xeba(%rip),%r15
test   %eax,%eax
je     120a <type_fichier+0xea>
add    %r12,%rbx
add    $0xfffffffffffffffc,%rbx
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     120a <type_fichier+0xea>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11e8 <type_fichier+0xc8>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11f1 <type_fichier+0xd1>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11fa <type_fichier+0xda>
lea    0xe8a(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1203 <type_fichier+0xe3>
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
lea    0xe71(%rip),%rax
lea    0xe75(%rip),%r15
cmove  %rax,%r15
jmp    120a <type_fichier+0xea>
lea    0xe2b(%rip),%r15
jmp    120a <type_fichier+0xea>
lea    0xe30(%rip),%r15
jmp    120a <type_fichier+0xea>
lea    0xe36(%rip),%r15
jmp    120a <type_fichier+0xea>
lea    0xe42(%rip),%r15
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c".html\00"
@.str.1 = [5 x i8] c".htm\00"
@.str.2 = [10 x i8] c"text/html\00"
@.str.3 = [5 x i8] c".css\00"
@.str.4 = [9 x i8] c"text/css\00"
@.str.5 = [5 x i8] c".png\00"
@.str.6 = [10 x i8] c"image/png\00"
@.str.7 = [5 x i8] c".gif\00"
@.str.8 = [10 x i8] c"image/gif\00"
@.str.9 = [6 x i8] c".jpeg\00"
@.str.10 = [5 x i8] c".jpg\00"
@.str.11 = [11 x i8] c"image/jpeg\00"
@.str.12 = [11 x i8] c"text/ascii\00"
define i8* @type_fichier(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = getelementptr inbounds i8, i8* %4, i64 -5
%6 = tail call i32 @strcasecmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %28, label %8
8: ; preds = %1
%9 = getelementptr inbounds i8, i8* %4, i64 -4
%10 = tail call i32 @strcasecmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %28, label %12
12: ; preds = %8
%13 = tail call i32 @strcasecmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %28, label %15
15: ; preds = %12
%16 = tail call i32 @strcasecmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %28, label %18
18: ; preds = %15
%19 = tail call i32 @strcasecmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %28, label %21
21: ; preds = %18
%22 = tail call i32 @strcasecmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %21
%25 = tail call i32 @strcasecmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
%27 = select i1 %26, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0)
br label %28
28: ; preds = %24, %21, %18, %15, %12, %1, %8
%29 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %8 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %1 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), %12 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), %15 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), %18 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), %21 ], [ %27, %24 ]
ret i8* %29
}