#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 const *);
int strlen(char const *);
int file_type(const char *fname) {
  int len = strlen(fname);
  if (!strcasecmp(".vcf.gz", fname + len - 7))
    return 2;
  if (!strcasecmp(".vcf", fname + len - 4))
    return 1;
  if (!strcasecmp(".bcf", fname + len - 4))
    return 4;
  return 0;
}


x86 assembly (clang, -O0):
<file_type>:
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),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
add    $0xfffffffffffffff9,%rsi
lea    0xeb2(%rip),%rdi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1168 <file_type+0x48>
movl   $0x2,-0x4(%rbp)
jmp    11cf <file_type+0xaf>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
add    $0xfffffffffffffffc,%rsi
lea    0xe8a(%rip),%rdi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1198 <file_type+0x78>
movl   $0x1,-0x4(%rbp)
jmp    11cf <file_type+0xaf>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
add    $0xfffffffffffffffc,%rsi
lea    0xe5f(%rip),%rdi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11c8 <file_type+0xa8>
movl   $0x4,-0x4(%rbp)
jmp    11cf <file_type+0xaf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_type>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <strlen@plt>
movslq %eax,%r14
lea    (%rbx,%r14,1),%rsi
add    $0xfffffffffffffff9,%rsi
lea    0xec2(%rip),%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     117e <file_type+0x5e>
add    %r14,%rbx
add    $0xfffffffffffffffc,%rbx
lea    0xeb3(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1185 <file_type+0x65>
lea    0xea5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
shl    $0x2,%eax
jmp    118a <file_type+0x6a>
mov    $0x2,%eax
jmp    118a <file_type+0x6a>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c".vcf.gz\00"
@.str.1 = [5 x i8] c".vcf\00"
@.str.2 = [5 x i8] c".bcf\00"
define i32 @file_type(i8* %0) {
%2 = alloca i32
%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 -7
%12 = call i32 @strcasecmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %1
store i32 2, i32* %2
br label %34
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = getelementptr inbounds i8, i8* %19, i64 -4
%21 = call i32 @strcasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %15
store i32 1, i32* %2
br label %34
24: ; preds = %15
%25 = load i8*, i8** %3
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = getelementptr inbounds i8, i8* %28, i64 -4
%30 = call i32 @strcasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %24
store i32 4, i32* %2
br label %34
33: ; preds = %24
store i32 0, i32* %2
br label %34
34: ; preds = %33, %32, %23, %14
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [8 x i8] c".vcf.gz\00"
@.str.1 = [5 x i8] c".vcf\00"
@.str.2 = [5 x i8] c".bcf\00"
define i32 @file_type(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 -7
%6 = tail call i32 @strcasecmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %1
%9 = getelementptr inbounds i8, i8* %4, i64 -4
%10 = tail call i32 @strcasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = tail call i32 @strcasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i32 4, i32 0
br label %16
16: ; preds = %12, %8, %1
%17 = phi i32 [ 2, %1 ], [ 1, %8 ], [ %15, %12 ]
ret i32 %17
}