#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 /*<<< orphan*/ strcpy(char *, char *);
char *strrchr(char *, char);
char tolower(char);
int testExt(char *path, char *ext) {
  char *ptr = strrchr(path, '.');
  if (!ptr)
    return 0;
  char buf[255];
  strcpy(buf, ptr + 1);
  ptr = buf;
  while (*ptr) {
    *ptr = tolower(*ptr);
    ptr++;
  }
  if (strcmp(ext, buf))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<testExt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    117c <testExt+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    11fa <testExt+0xba>
lea    -0x120(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
lea    -0x120(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     11cd <testExt+0x8d>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1060 <tolower@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    119b <testExt+0x5b>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11f3 <testExt+0xb3>
movl   $0x0,-0x4(%rbp)
jmp    11fa <testExt+0xba>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testExt>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%r14
mov    $0x2e,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     11ae <testExt+0x6e>
add    $0x1,%rax
mov    %rsp,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    (%rsp),%al
test   %al,%al
je     1196 <testExt+0x56>
lea    0x1(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1060 <tolower@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1180 <testExt+0x40>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
jmp    11b0 <testExt+0x70>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @testExt(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [255 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i8* @strrchr(i8* %8, i8 signext 46)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %2
store i32 0, i32* %3
br label %37
13: ; preds = %2
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%15 = load i8*, i8** %6
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = call i32 @strcpy(i8* %14, i8* %16)
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
store i8* %18, i8** %6
br label %19
19: ; preds = %23, %13
%20 = load i8*, i8** %6
%21 = load i8, i8* %20
%22 = icmp ne i8 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %19
%24 = load i8*, i8** %6
%25 = load i8, i8* %24
%26 = call signext i8 @tolower(i8 signext %25)
%27 = load i8*, i8** %6
store i8 %26, i8* %27
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %6
br label %19
30: ; preds = %19
%31 = load i8*, i8** %5
%32 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%33 = call i64 @strcmp(i8* %31, i8* %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %30
store i32 0, i32* %3
br label %37
36: ; preds = %30
store i32 1, i32* %3
br label %37
37: ; preds = %36, %35, %12
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
define i32 @testExt(i8* %0, i8* %1) {
%3 = alloca [255 x i8]
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%5 = icmp eq i8* %4, null
br i1 %5, label %23, label %6
6: ; preds = %2
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds i8, i8* %4, i64 1
%9 = call i32 @strcpy(i8* %7, i8* %8)
%10 = load i8, i8* %7
%11 = icmp eq i8 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %6, %12
%13 = phi i8 [ %17, %12 ], [ %10, %6 ]
%14 = phi i8* [ %16, %12 ], [ %7, %6 ]
%15 = call signext i8 @tolower(i8 signext %13)
store i8 %15, i8* %14
%16 = getelementptr inbounds i8, i8* %14, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %12
19: ; preds = %12, %6
%20 = call i64 @strcmp(i8* %1, i8* %7)
%21 = icmp eq i64 %20, 0
%22 = zext i1 %21 to i32
br label %23
23: ; preds = %2, %19
%24 = phi i32 [ %22, %19 ], [ 0, %2 ]
ret i32 %24
}