#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*/ memcpy(char *, char const *, int);
int strlen(char const *);
int strncmp(char *, char *, int);
char tolower(char);
int check_input_file_path(const char *input_path) {
  int len = strlen(input_path);
  int i;
  char ext[4];
  memcpy(ext, &input_path[len - 4], 4);
  for (i = 0; i < 4; ++i) {
    ext[i] = tolower(ext[i]);
  }
  return strncmp(ext, ".bin", 4);
}


x86 assembly (clang, -O0):
<check_input_file_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xc(%rbp)
lea    -0x14(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
cltq
add    %rax,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    11ac <check_input_file_path+0x6c>
movslq -0x10(%rbp),%rax
movsbl -0x14(%rbp,%rax,1),%edi
call   1060 <tolower@plt>
mov    %al,%cl
movslq -0x10(%rbp),%rax
mov    %cl,-0x14(%rbp,%rax,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117c <check_input_file_path+0x3c>
lea    -0x14(%rbp),%rdi
lea    0xe49(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_input_file_path>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1040 <strlen@plt>
cltq
lea    (%rax,%rbx,1),%rsi
add    $0xfffffffffffffffc,%rsi
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x4,%edx
call   1050 <memcpy@plt>
movsbl 0xc(%rsp),%edi
call   1060 <tolower@plt>
mov    %al,0xc(%rsp)
movsbl 0xd(%rsp),%edi
call   1060 <tolower@plt>
mov    %al,0xd(%rsp)
movsbl 0xe(%rsp),%edi
call   1060 <tolower@plt>
mov    %al,0xe(%rsp)
movsbl 0xf(%rsp),%edi
call   1060 <tolower@plt>
mov    %al,0xf(%rsp)
lea    0xe58(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c".bin\00"
define i32 @check_input_file_path(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4 x i8]
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %3
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%9 = load i8*, i8** %2
%10 = load i32, i32* %3
%11 = sub nsw i32 %10, 4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %9, i64 %12
%14 = call i32 @memcpy(i8* %8, i8* %13, i32 4)
store i32 0, i32* %4
br label %15
15: ; preds = %27, %1
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %30
18: ; preds = %15
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = call signext i8 @tolower(i8 signext %22)
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 %25
store i8 %23, i8* %26
br label %27
27: ; preds = %18
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %15
30: ; preds = %15
%31 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%32 = call i32 @strncmp(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
ret i32 %32
}

LLVM IR (-O2):
@.str = [5 x i8] c".bin\00"
define i32 @check_input_file_path(i8* %0) {
%2 = alloca [4 x i8]
%3 = tail call i32 @strlen(i8* %0)
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%5 = add nsw i32 %3, -4
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = call i32 @memcpy(i8* %4, i8* %7, i32 4)
%9 = load i8, i8* %4
%10 = call signext i8 @tolower(i8 signext %9)
store i8 %10, i8* %4
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 1
%12 = load i8, i8* %11
%13 = call signext i8 @tolower(i8 signext %12)
store i8 %13, i8* %11
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 2
%15 = load i8, i8* %14
%16 = call signext i8 @tolower(i8 signext %15)
store i8 %16, i8* %14
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 3
%18 = load i8, i8* %17
%19 = call signext i8 @tolower(i8 signext %18)
store i8 %19, i8* %17
%20 = call i32 @strncmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
ret i32 %20
}