#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 *);
unsigned int strlen(char *);
char *guess_language(char *file) {
  unsigned int len;
  char *f;
  len = strlen(file);
  f = file + len;
  while ((f > file) && (*f != '.'))
    f--;
  if (*f == '.')
    f++;
  if (0 == strcmp(f, "c"))
    return "c";
  if (0 == strcmp(f, "sl"))
    return "sl";
  return "sl";
}


x86 assembly (clang, -O0):
<guess_language>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x21(%rbp)
jbe    1169 <guess_language+0x49>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1179 <guess_language+0x59>
jmp    118a <guess_language+0x6a>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    1146 <guess_language+0x26>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11a6 <guess_language+0x86>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11d4 <guess_language+0xb4>
lea    0xe35(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120d <guess_language+0xed>
mov    -0x20(%rbp),%rdi
lea    0xe23(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1202 <guess_language+0xe2>
lea    0xe09(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120d <guess_language+0xed>
lea    0xdf9(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<guess_language>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ecx
add    %rbx,%rcx
test   %eax,%eax
je     114e <guess_language+0x2e>
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x2e,(%rcx)
je     114e <guess_language+0x2e>
add    $0xffffffffffffffff,%rcx
cmp    %rbx,%rcx
ja     1140 <guess_language+0x20>
xor    %ebx,%ebx
cmpb   $0x2e,(%rcx)
sete   %bl
add    %rcx,%rbx
lea    0xea0(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1182 <guess_language+0x62>
lea    0xe8b(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"c\00"
@.str.1 = [3 x i8] c"sl\00"
define i8* @guess_language(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %4
%8 = load i8*, i8** %3
%9 = load i32, i32* %4
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
store i8* %11, i8** %5
br label %12
12: ; preds = %23, %1
%13 = load i8*, i8** %5
%14 = load i8*, i8** %3
%15 = icmp ugt i8* %13, %14
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = load i8*, i8** %5
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 46
br label %21
21: ; preds = %16, %12
%22 = phi i1 [ false, %12 ], [ %20, %16 ]
br i1 %22, label %23, label %26
23: ; preds = %21
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i32 -1
store i8* %25, i8** %5
br label %12
26: ; preds = %21
%27 = load i8*, i8** %5
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 46
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %5
br label %34
34: ; preds = %31, %26
%35 = load i8*, i8** %5
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%37 = icmp eq i64 0, %36
br i1 %37, label %38, label %39
38: ; preds = %34
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %2
br label %45
39: ; preds = %34
%40 = load i8*, i8** %5
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%42 = icmp eq i64 0, %41
br i1 %42, label %43, label %44
43: ; preds = %39
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %45
44: ; preds = %39
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %45
45: ; preds = %44, %43, %38
%46 = load i8*, i8** %2
ret i8* %46
}

LLVM IR (-O2):
@.str = [2 x i8] c"c\00"
@.str.1 = [3 x i8] c"sl\00"
define i8* @guess_language(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = zext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = icmp eq i32 %2, 0
br i1 %5, label %13, 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 ugt i8* %11, %0
br i1 %12, label %6, label %13
13: ; preds = %6, %10, %1
%14 = phi i8* [ %4, %1 ], [ %11, %10 ], [ %7, %6 ]
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 46
%17 = zext i1 %16 to i64
%18 = getelementptr i8, i8* %14, i64 %17
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %13
%22 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %13
%24 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %13 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %21 ]
ret i8* %24
}