#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 *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char tolower(char);
int isXls(char *name) {
  if (!name)
    return 0;
  int len = strlen(name) - 4;
  if (len < 1)
    return 0;
  char buffer[5];
  strcpy(buffer, &name[len]);
  int i = 0;
  while (++i < 4)
    buffer[i] = tolower(buffer[i]);
  return !strcmp(buffer, ".xls");
}


x86 assembly (clang, -O0):
<isXls>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1163 <isXls+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11f2 <isXls+0xb2>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x4,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jge    1188 <isXls+0x48>
movl   $0x0,-0x4(%rbp)
jmp    11f2 <isXls+0xb2>
lea    -0x19(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmp    $0x4,%eax
jge    11d2 <isXls+0x92>
movslq -0x20(%rbp),%rax
movsbl -0x19(%rbp,%rax,1),%edi
call   1060 <tolower@plt>
mov    %al,%cl
movslq -0x20(%rbp),%rax
mov    %cl,-0x19(%rbp,%rax,1)
jmp    11a3 <isXls+0x63>
lea    -0x19(%rbp),%rdi
lea    0xe23(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isXls>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     119a <isXls+0x6a>
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmp    $0x5,%eax
jl     119a <isXls+0x6a>
add    $0xfffffffc,%eax
add    %rax,%rbx
lea    0x3(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
movsbl 0x4(%rsp),%edi
call   1050 <tolower@plt>
mov    %al,0x4(%rsp)
movsbl 0x5(%rsp),%edi
call   1050 <tolower@plt>
mov    %al,0x5(%rsp)
movsbl 0x6(%rsp),%edi
call   1050 <tolower@plt>
mov    %al,0x6(%rsp)
mov    $0x736c782e,%eax
xor    0x3(%rsp),%eax
movzbl 0x7(%rsp),%ecx
xor    %ebp,%ebp
or     %eax,%ecx
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c".xls\00"
define i32 @isXls(i8* %0) {
%2 = alloca [5 x i8]
%3 = icmp eq i8* %0, null
br i1 %3, label %25, label %4
4: ; preds = %1
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp slt i32 %5, 5
br i1 %6, label %25, label %7
7: ; preds = %4
%8 = add nsw i32 %5, -4
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%10 = zext i32 %8 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = call i32 @strcpy(i8* %9, i8* %11)
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 1
%14 = load i8, i8* %13
%15 = call signext i8 @tolower(i8 signext %14)
store i8 %15, i8* %13
%16 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 2
%17 = load i8, i8* %16
%18 = call signext i8 @tolower(i8 signext %17)
store i8 %18, i8* %16
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 3
%20 = load i8, i8* %19
%21 = call signext i8 @tolower(i8 signext %20)
store i8 %21, i8* %19
%22 = call i32 @bcmp(i8* dereferenceable(5) %9, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 5)
%23 = icmp eq i32 %22, 0
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %7, %4, %1
%26 = phi i32 [ 0, %1 ], [ %24, %7 ], [ 0, %4 ]
ret i32 %26
}