#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 *, char *);
int strlen(char *);
int checkfile(char *file) {
  int i, l1, l2, l3, l4;
  char *ext1 = ".f";
  char *ext2 = ".F";
  char *ext3 = ".c";
  char *ext4 = ".h";
  l1 = strlen(file) - strlen(ext1);
  l2 = strlen(file) - strlen(ext2);
  l3 = strlen(file) - strlen(ext3);
  l4 = strlen(file) - strlen(ext4);
  if (strcmp(file + l1, ext1) == 0)
    return (1);
  if (strcmp(file + l2, ext2) == 0)
    return (1);
  if (strcmp(file + l3, ext3) == 0)
    return (2);
  if (strcmp(file + l4, ext4) == 0)
    return (2);
  return (0);
}


x86 assembly (clang, -O0):
<checkfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xecd(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xec5(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xebd(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xeb5(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x58(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x54(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x50(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
mov    -0x30(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11fe <checkfile+0xde>
movl   $0x1,-0x4(%rbp)
jmp    1283 <checkfile+0x163>
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    -0x38(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1228 <checkfile+0x108>
movl   $0x1,-0x4(%rbp)
jmp    1283 <checkfile+0x163>
mov    -0x10(%rbp),%rdi
movslq -0x20(%rbp),%rax
add    %rax,%rdi
mov    -0x40(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1252 <checkfile+0x132>
movl   $0x2,-0x4(%rbp)
jmp    1283 <checkfile+0x163>
mov    -0x10(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
mov    -0x48(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    127c <checkfile+0x15c>
movl   $0x2,-0x4(%rbp)
jmp    1283 <checkfile+0x163>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkfile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%r15d
lea    0xec0(%rip),%rbp
mov    %rbp,%rdi
call   1030 <strlen@plt>
sub    %eax,%r15d
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%r14d
lea    0xea6(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%r13d
lea    0xe8f(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,0x14(%rsp)
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,0x10(%rsp)
lea    0xe76(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,0xc(%rsp)
movslq %r15d,%rdi
add    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <strcmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     1218 <checkfile+0xf8>
sub    %r12d,%r14d
movslq %r14d,%rdi
add    %rbx,%rdi
lea    0xe3f(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1218 <checkfile+0xf8>
sub    0x14(%rsp),%r13d
movslq %r13d,%rdi
add    %rbx,%rdi
lea    0xe26(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1213 <checkfile+0xf3>
mov    0x10(%rsp),%eax
sub    0xc(%rsp),%eax
cltq
add    %rax,%rbx
lea    0xe0b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
add    %ebp,%ebp
jmp    1218 <checkfile+0xf8>
mov    $0x2,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c".f\00"
@.str.1 = [3 x i8] c".F\00"
@.str.2 = [3 x i8] c".c\00"
@.str.3 = [3 x i8] c".h\00"
define i32 @checkfile(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = sub nsw i32 %2, %3
%5 = tail call i32 @strlen(i8* %0)
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @strlen(i8* %0)
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%9 = sub nsw i32 %7, %8
%10 = tail call i32 @strlen(i8* %0)
%11 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%12 = sub nsw i32 %10, %11
%13 = sext i32 %4 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %34, label %17
17: ; preds = %1
%18 = sub nsw i32 %5, %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = tail call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %34, label %23
23: ; preds = %17
%24 = sext i32 %9 to i64
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = tail call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %34, label %28
28: ; preds = %23
%29 = sext i32 %12 to i64
%30 = getelementptr inbounds i8, i8* %0, i64 %29
%31 = tail call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
%33 = select i1 %32, i32 2, i32 0
br label %34
34: ; preds = %28, %23, %17, %1
%35 = phi i32 [ 1, %1 ], [ 1, %17 ], [ 2, %23 ], [ %33, %28 ]
ret i32 %35
}