#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*/ strcmp(char *, char *);
char *strrchr(char *, char);
const char *get_type(char *res) {
  char *rid = strrchr(res, '.');
  if (rid++) {
    if (!strcmp(rid, "html")) {
      return "text/html";
    } else if (!strcmp(rid, "ico")) {
      return "image/vnd.microsoft.icon";
    }
  }
  return "application/octet-stream";
}


x86 assembly (clang, -O0):
<get_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)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
je     11b3 <get_type+0x93>
mov    -0x18(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1180 <get_type+0x60>
lea    0xe89(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11be <get_type+0x9e>
mov    -0x18(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11a9 <get_type+0x89>
lea    0xe6e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11be <get_type+0x9e>
jmp    11ae <get_type+0x8e>
jmp    11b3 <get_type+0x93>
lea    0xe6d(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_type>:
push   %rbx
mov    $0x2e,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     115d <get_type+0x3d>
mov    %rax,%rbx
add    $0x1,%rbx
lea    0xec7(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1166 <get_type+0x46>
lea    0xeb9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     116f <get_type+0x4f>
lea    0xec3(%rip),%rax
pop    %rbx
ret
lea    0xe93(%rip),%rax
pop    %rbx
ret
lea    0xe98(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"html\00"
@.str.1 = [10 x i8] c"text/html\00"
@.str.2 = [4 x i8] c"ico\00"
@.str.3 = [25 x i8] c"image/vnd.microsoft.icon\00"
@.str.4 = [25 x i8] c"application/octet-stream\00"
define i8* @get_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 = getelementptr inbounds i8, i8* %7, i32 1
store i8* %8, i8** %4
%9 = icmp ne i8* %7, null
br i1 %9, label %10, label %22
10: ; preds = %1
%11 = load i8*, i8** %4
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %10
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %23
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %15
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %23
20: ; preds = %15
br label %21
21: ; preds = %20
br label %22
22: ; preds = %21, %1
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %23
23: ; preds = %22, %19, %14
%24 = load i8*, i8** %2
ret i8* %24
}

LLVM IR (-O2):
@.str = [5 x i8] c"html\00"
@.str.1 = [10 x i8] c"text/html\00"
@.str.2 = [4 x i8] c"ico\00"
@.str.3 = [25 x i8] c"image/vnd.microsoft.icon\00"
@.str.4 = [25 x i8] c"application/octet-stream\00"
define i8* @get_type(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%3 = getelementptr inbounds i8, i8* %2, i64 1
%4 = icmp eq i8* %2, null
br i1 %4, label %11, label %5
5: ; preds = %1
%6 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %8, %1
br label %12
12: ; preds = %8, %5, %11
%13 = phi i8* [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), %11 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), %8 ]
ret i8* %13
}