#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 language_type(char *fname) {
  char *p = fname + strlen(fname);
  for (; p != fname && *p != '.'; --p)
    ;
  if (strlen(fname) >= 8 &&
          strcmp(fname + strlen(fname) - 8, "makefile") == 0 ||
      strcmp(fname + strlen(fname) - 8, "Makefile") == 0)
    return 5;
  else if (p == fname)
    return 0;
  else if (strcmp(p, ".m") == 0)
    return 1;
  else if (strcmp(p, ".f") == 0 || strcmp(p, ".F") == 0)
    return 3;
  else if (strcmp(p, ".lua") == 0)
    return 4;
  else if (strcmp(p, ".sh") == 0 || strcmp(p, ".csh") == 0)
    return 5;
  else if (strcmp(p, ".l") == 0 || strcmp(p, ".scm") == 0)
    return 6;
  else
    return 0;
}


x86 assembly (clang, -O0):
<language_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x21(%rbp)
je     1170 <language_type+0x50>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1180 <language_type+0x60>
jmp    1196 <language_type+0x76>
jmp    1185 <language_type+0x65>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    114d <language_type+0x2d>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x8,%eax
jl     11dc <language_type+0xbc>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0xfffffffffffffff8,%rdi
lea    0xe33(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1210 <language_type+0xf0>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0xfffffffffffffff8,%rdi
lea    0xe08(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    121c <language_type+0xfc>
movl   $0x5,-0x4(%rbp)
jmp    1349 <language_type+0x229>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    1236 <language_type+0x116>
movl   $0x0,-0x4(%rbp)
jmp    1349 <language_type+0x229>
mov    -0x18(%rbp),%rdi
lea    0xdd1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    125c <language_type+0x13c>
movl   $0x1,-0x4(%rbp)
jmp    1349 <language_type+0x229>
mov    -0x18(%rbp),%rdi
lea    0xdae(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1290 <language_type+0x170>
mov    -0x18(%rbp),%rdi
lea    0xd97(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    129c <language_type+0x17c>
movl   $0x3,-0x4(%rbp)
jmp    1349 <language_type+0x229>
mov    -0x18(%rbp),%rdi
lea    0xd74(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12c2 <language_type+0x1a2>
movl   $0x4,-0x4(%rbp)
jmp    1349 <language_type+0x229>
mov    -0x18(%rbp),%rdi
lea    0xd53(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     12f6 <language_type+0x1d6>
mov    -0x18(%rbp),%rdi
lea    0xd3d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1302 <language_type+0x1e2>
movl   $0x5,-0x4(%rbp)
jmp    1349 <language_type+0x229>
mov    -0x18(%rbp),%rdi
lea    0xd1c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1336 <language_type+0x216>
mov    -0x18(%rbp),%rdi
lea    0xd05(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1342 <language_type+0x222>
movl   $0x6,-0x4(%rbp)
jmp    1349 <language_type+0x229>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<language_type>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
movslq %eax,%rbx
test   %ebx,%ebx
je     1154 <language_type+0x34>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%r14,%rbx,1),%eax
cmp    $0x2e,%al
je     115c <language_type+0x3c>
add    $0xffffffffffffffff,%rbx
jne    1140 <language_type+0x20>
mov    %r14,%rbx
jmp    115f <language_type+0x3f>
add    %r14,%rbx
mov    $0x1,%bpl
jmp    1165 <language_type+0x45>
add    %r14,%rbx
cmp    $0x2e,%al
setne  %bpl
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0x8,%eax
jl     1199 <language_type+0x79>
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
lea    (%r14,%rax,1),%rdi
add    $0xfffffffffffffff8,%rdi
lea    0xe75(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     128a <language_type+0x16a>
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
lea    (%r14,%rax,1),%rdi
add    $0xfffffffffffffff8,%rdi
lea    0xe57(%rip),%rsi
call   1040 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %al
or     %al,%bpl
je     11ce <language_type+0xae>
mov    %al,%cl
lea    (%rcx,%rcx,4),%ebp
jmp    1296 <language_type+0x176>
lea    0xe3d(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1291 <language_type+0x171>
lea    0xe28(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    $0x3,%ebp
test   %rax,%rax
je     1296 <language_type+0x176>
lea    0xe0e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1296 <language_type+0x176>
lea    0xdfd(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     129d <language_type+0x17d>
lea    0xdee(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    $0x5,%ebp
test   %rax,%rax
je     1296 <language_type+0x176>
lea    0xdd9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1296 <language_type+0x176>
lea    0xdca(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     12a4 <language_type+0x184>
lea    0xdb9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
mov    $0x6,%ebp
cmovne %ecx,%ebp
jmp    1296 <language_type+0x176>
mov    $0x5,%ebp
jmp    1296 <language_type+0x176>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x4,%ebp
jmp    1296 <language_type+0x176>
mov    $0x6,%ebp
jmp    1296 <language_type+0x176>

LLVM IR (-O0):
@.str = [9 x i8] c"makefile\00"
@.str.1 = [9 x i8] c"Makefile\00"
@.str.2 = [3 x i8] c".m\00"
@.str.3 = [3 x i8] c".f\00"
@.str.4 = [3 x i8] c".F\00"
@.str.5 = [5 x i8] c".lua\00"
@.str.6 = [4 x i8] c".sh\00"
@.str.7 = [5 x i8] c".csh\00"
@.str.8 = [3 x i8] c".l\00"
@.str.9 = [5 x i8] c".scm\00"
define i32 @language_type(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %5, i64 %8
store i8* %9, i8** %4
br label %10
10: ; preds = %22, %1
%11 = load i8*, i8** %4
%12 = load i8*, i8** %3
%13 = icmp ne i8* %11, %12
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 46
br label %19
19: ; preds = %14, %10
%20 = phi i1 [ false, %10 ], [ %18, %14 ]
br i1 %20, label %21, label %25
21: ; preds = %19
br label %22
22: ; preds = %21
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 -1
store i8* %24, i8** %4
br label %10
25: ; preds = %19
%26 = load i8*, i8** %3
%27 = call i32 @strlen(i8* %26)
%28 = icmp sge i32 %27, 8
br i1 %28, label %29, label %38
29: ; preds = %25
%30 = load i8*, i8** %3
%31 = load i8*, i8** %3
%32 = call i32 @strlen(i8* %31)
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %30, i64 %33
%35 = getelementptr inbounds i8, i8* %34, i64 -8
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %47, label %38
38: ; preds = %29, %25
%39 = load i8*, i8** %3
%40 = load i8*, i8** %3
%41 = call i32 @strlen(i8* %40)
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %39, i64 %42
%44 = getelementptr inbounds i8, i8* %43, i64 -8
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %38, %29
store i32 5, i32* %2
br label %91
48: ; preds = %38
%49 = load i8*, i8** %4
%50 = load i8*, i8** %3
%51 = icmp eq i8* %49, %50
br i1 %51, label %52, label %53
52: ; preds = %48
store i32 0, i32* %2
br label %91
53: ; preds = %48
%54 = load i8*, i8** %4
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %53
store i32 1, i32* %2
br label %91
58: ; preds = %53
%59 = load i8*, i8** %4
%60 = call i64 @strcmp(i8* %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %66, label %62
62: ; preds = %58
%63 = load i8*, i8** %4
%64 = call i64 @strcmp(i8* %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %62, %58
store i32 3, i32* %2
br label %91
67: ; preds = %62
%68 = load i8*, i8** %4
%69 = call i64 @strcmp(i8* %68, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %72
71: ; preds = %67
store i32 4, i32* %2
br label %91
72: ; preds = %67
%73 = load i8*, i8** %4
%74 = call i64 @strcmp(i8* %73, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%75 = icmp eq i64 %74, 0
br i1 %75, label %80, label %76
76: ; preds = %72
%77 = load i8*, i8** %4
%78 = call i64 @strcmp(i8* %77, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %81
80: ; preds = %76, %72
store i32 5, i32* %2
br label %91
81: ; preds = %76
%82 = load i8*, i8** %4
%83 = call i64 @strcmp(i8* %82, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%84 = icmp eq i64 %83, 0
br i1 %84, label %89, label %85
85: ; preds = %81
%86 = load i8*, i8** %4
%87 = call i64 @strcmp(i8* %86, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%88 = icmp eq i64 %87, 0
br i1 %88, label %89, label %90
89: ; preds = %85, %81
store i32 6, i32* %2
br label %91
90: ; preds = %85
store i32 0, i32* %2
br label %91
91: ; preds = %90, %89, %80, %71, %66, %57, %52, %47
%92 = load i32, i32* %2
ret i32 %92
}

LLVM IR (-O2):
@.str = [9 x i8] c"makefile\00"
@.str.1 = [9 x i8] c"Makefile\00"
@.str.2 = [3 x i8] c".m\00"
@.str.3 = [3 x i8] c".f\00"
@.str.4 = [3 x i8] c".F\00"
@.str.5 = [5 x i8] c".lua\00"
@.str.6 = [4 x i8] c".sh\00"
@.str.7 = [5 x i8] c".csh\00"
@.str.8 = [3 x i8] c".l\00"
@.str.9 = [5 x i8] c".scm\00"
define i32 @language_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 = icmp eq i32 %2, 0
br i1 %5, label %16, label %6
6: ; preds = %1, %10
%7 = phi i8* [ %11, %10 ], [ %4, %1 ]
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 46
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %7, i64 -1
%12 = icmp eq i8* %11, %0
br i1 %12, label %13, label %6
13: ; preds = %10, %6
%14 = phi i8* [ %7, %6 ], [ %0, %10 ]
%15 = xor i1 %9, true
br label %16
16: ; preds = %13, %1
%17 = phi i8* [ %4, %1 ], [ %14, %13 ]
%18 = phi i1 [ true, %1 ], [ %15, %13 ]
%19 = tail call i32 @strlen(i8* %0)
%20 = icmp sgt i32 %19, 7
br i1 %20, label %21, label %28
21: ; preds = %16
%22 = tail call i32 @strlen(i8* %0)
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = getelementptr inbounds i8, i8* %24, i64 -8
%26 = tail call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %62, label %28
28: ; preds = %21, %16
%29 = tail call i32 @strlen(i8* %0)
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %0, i64 %30
%32 = getelementptr inbounds i8, i8* %31, i64 -8
%33 = tail call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
%35 = select i1 %34, i1 true, i1 %18
%36 = select i1 %34, i32 5, i32 0
br i1 %35, label %62, label %37
37: ; preds = %28
%38 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %62, label %40
40: ; preds = %37
%41 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %62, label %43
43: ; preds = %40
%44 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %62, label %46
46: ; preds = %43
%47 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %62, label %49
49: ; preds = %46
%50 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %62, label %52
52: ; preds = %49
%53 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %62, label %55
55: ; preds = %52
%56 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %62, label %58
58: ; preds = %55
%59 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
%61 = select i1 %60, i32 6, i32 0
br label %62
62: ; preds = %28, %58, %55, %49, %52, %46, %40, %43, %37, %21
%63 = phi i32 [ %36, %28 ], [ 5, %21 ], [ 1, %37 ], [ 3, %43 ], [ 3, %40 ], [ 4, %46 ], [ 5, %52 ], [ 5, %49 ], [ 6, %55 ], [ %61, %58 ]
ret i32 %63
}