#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 const *, char *);
char *strrchr(char const *, char);
const char *application_type(const char *url) {
  const char *dot = strrchr(url, '.');
  if (!dot || dot == url)
    return "";
  if (strcmp(dot + 1, "html") == 0) {
    return "text/html";
  } else if (strcmp(dot + 1, "xml") == 0) {
    return "application/xml";
  } else if (strcmp(dot + 1, "js") == 0) {
    return "application/javascript";
  } else if (strcmp(dot + 1, "css") == 0) {
    return "text/css";
  } else if (strcmp(dot + 1, "jpg") == 0) {
    return "image/jpeg";
  } else if (strcmp(dot + 1, "png") == 0) {
    return "image/png";
  }
  return "text";
}


x86 assembly (clang, -O0):
<application_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1157 <application_type+0x37>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    1167 <application_type+0x47>
lea    0xeed(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    129f <application_type+0x17f>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
lea    0xe8f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1195 <application_type+0x75>
lea    0xe74(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    129f <application_type+0x17f>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
lea    0xe72(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c3 <application_type+0xa3>
lea    0xe50(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    129f <application_type+0x17f>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
lea    0xe48(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f1 <application_type+0xd1>
lea    0xe35(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    129f <application_type+0x17f>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
lea    0xe39(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    121f <application_type+0xff>
lea    0xe1e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    129f <application_type+0x17f>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
lea    0xe0f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    124d <application_type+0x12d>
lea    0xdfd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    129f <application_type+0x17f>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
lea    0xdf6(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    127b <application_type+0x15b>
lea    0xdda(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    129f <application_type+0x17f>
jmp    1280 <application_type+0x160>
jmp    1285 <application_type+0x165>
jmp    128a <application_type+0x16a>
jmp    128f <application_type+0x16f>
jmp    1294 <application_type+0x174>
lea    0xdbb(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<application_type>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,%r14
lea    0xf10(%rip),%rax
test   %r14,%r14
je     1206 <application_type+0xe6>
cmp    %rbx,%r14
je     1206 <application_type+0xe6>
add    $0x1,%r14
lea    0xead(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11db <application_type+0xbb>
lea    0xeaa(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e4 <application_type+0xc4>
lea    0xe9a(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ed <application_type+0xcd>
lea    0xea5(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11f6 <application_type+0xd6>
lea    0xe95(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ff <application_type+0xdf>
lea    0xe96(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
lea    0xe7e(%rip),%rcx
lea    0xe81(%rip),%rax
cmove  %rcx,%rax
jmp    1206 <application_type+0xe6>
lea    0xe1e(%rip),%rax
jmp    1206 <application_type+0xe6>
lea    0xe1f(%rip),%rax
jmp    1206 <application_type+0xe6>
lea    0xe29(%rip),%rax
jmp    1206 <application_type+0xe6>
lea    0xe37(%rip),%rax
jmp    1206 <application_type+0xe6>
lea    0xe3b(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"html\00"
@.str.2 = [10 x i8] c"text/html\00"
@.str.3 = [4 x i8] c"xml\00"
@.str.4 = [16 x i8] c"application/xml\00"
@.str.5 = [3 x i8] c"js\00"
@.str.6 = [23 x i8] c"application/javascript\00"
@.str.7 = [4 x i8] c"css\00"
@.str.8 = [9 x i8] c"text/css\00"
@.str.9 = [4 x i8] c"jpg\00"
@.str.10 = [11 x i8] c"image/jpeg\00"
@.str.11 = [4 x i8] c"png\00"
@.str.12 = [10 x i8] c"image/png\00"
@.str.13 = [5 x i8] c"text\00"
define i8* @application_type(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i8* @strrchr(i8* %5, i8 signext 46)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i8*, i8** %4
%11 = load i8*, i8** %3
%12 = icmp eq i8* %10, %11
br i1 %12, label %13, label %14
13: ; preds = %9, %1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %2
br label %56
14: ; preds = %9
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %56
20: ; preds = %14
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %56
26: ; preds = %20
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %26
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %56
32: ; preds = %26
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %32
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %56
38: ; preds = %32
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i64 1
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %38
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %56
44: ; preds = %38
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i64 1
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %44
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %56
50: ; preds = %44
br label %51
51: ; preds = %50
br label %52
52: ; preds = %51
br label %53
53: ; preds = %52
br label %54
54: ; preds = %53
br label %55
55: ; preds = %54
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %56
56: ; preds = %55, %49, %43, %37, %31, %25, %19, %13
%57 = load i8*, i8** %2
ret i8* %57
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"html\00"
@.str.2 = [10 x i8] c"text/html\00"
@.str.3 = [4 x i8] c"xml\00"
@.str.4 = [16 x i8] c"application/xml\00"
@.str.5 = [3 x i8] c"js\00"
@.str.6 = [23 x i8] c"application/javascript\00"
@.str.7 = [4 x i8] c"css\00"
@.str.8 = [9 x i8] c"text/css\00"
@.str.9 = [4 x i8] c"jpg\00"
@.str.10 = [11 x i8] c"image/jpeg\00"
@.str.11 = [4 x i8] c"png\00"
@.str.12 = [10 x i8] c"image/png\00"
@.str.13 = [5 x i8] c"text\00"
define i8* @application_type(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%3 = icmp eq i8* %2, null
%4 = icmp eq i8* %2, %0
%5 = or i1 %3, %4
br i1 %5, label %26, label %6
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %2, i64 1
%8 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %26, label %10
10: ; preds = %6
%11 = tail call i64 @strcmp(i8* %7, 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 %26, label %13
13: ; preds = %10
%14 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %26, label %16
16: ; preds = %13
%17 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %16
%20 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
%25 = select i1 %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0)
br label %26
26: ; preds = %22, %19, %16, %13, %10, %6, %1
%27 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), %10 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), %13 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), %16 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), %19 ], [ %25, %22 ]
ret i8* %27
}