#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__ toupper(int /*<<< orphan*/);
bool test_extension(const char *file_name, const char *extension) {
  while (*file_name)
    file_name++;
  while (*extension)
    extension++;
  while (*file_name != '.')
    if (toupper(*file_name--) != toupper(*extension--))
      return false;
  return true;
}


x86 assembly (clang, -O0):
<test_extension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     113e <test_extension+0x2e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1120 <test_extension+0x10>
jmp    1143 <test_extension+0x33>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1161 <test_extension+0x51>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1143 <test_extension+0x33>
jmp    1166 <test_extension+0x56>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     11c9 <test_extension+0xb9>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     11c4 <test_extension+0xb4>
movl   $0x0,-0x4(%rbp)
jmp    11d0 <test_extension+0xc0>
jmp    1166 <test_extension+0x56>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_extension>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
xchg   %ax,%ax
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1120 <test_extension+0x10>
nopl   0x0(%rax)
cmpb   $0x0,(%r14)
lea    0x1(%r14),%r14
jne    1130 <test_extension+0x20>
mov    $0xffffffffffffffff,%rbp
xor    %r15d,%r15d
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %rax,%r12
movsbl (%r14,%rbp,1),%edi
call   1030 <toupper@plt>
cmp    %rax,%r12
jne    117d <test_extension+0x6d>
movzbl -0x1(%rbx,%rbp,1),%eax
add    $0xffffffffffffffff,%rbp
cmp    $0x2e,%al
jne    1150 <test_extension+0x40>
mov    $0x1,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @test_extension(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
br label %6
6: ; preds = %10, %2
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %4
br label %6
13: ; preds = %6
br label %14
14: ; preds = %18, %13
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %5
br label %14
21: ; preds = %14
br label %22
22: ; preds = %40, %21
%23 = load i8*, i8** %4
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 46
br i1 %26, label %27, label %41
27: ; preds = %22
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i32 -1
store i8* %29, i8** %4
%30 = load i8, i8* %28
%31 = sext i8 %30 to i32
%32 = call i64 @toupper(i32 %31)
%33 = load i8*, i8** %5
%34 = getelementptr inbounds i8, i8* %33, i32 -1
store i8* %34, i8** %5
%35 = load i8, i8* %33
%36 = sext i8 %35 to i32
%37 = call i64 @toupper(i32 %36)
%38 = icmp ne i64 %32, %37
br i1 %38, label %39, label %40
39: ; preds = %27
store i32 0, i32* %3
br label %42
40: ; preds = %27
br label %22
41: ; preds = %22
store i32 1, i32* %3
br label %42
42: ; preds = %41, %39
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
define i32 @test_extension(i8* nocapture %0, i8* nocapture %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i8* [ %0, %2 ], [ %7, %3 ]
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
%7 = getelementptr inbounds i8, i8* %4, i64 1
br i1 %6, label %8, label %3
8: ; preds = %3, %8
%9 = phi i8* [ %12, %8 ], [ %1, %3 ]
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
%12 = getelementptr inbounds i8, i8* %9, i64 1
br i1 %11, label %13, label %8
13: ; preds = %8, %24
%14 = phi i8* [ %25, %24 ], [ %9, %8 ]
%15 = phi i8* [ %18, %24 ], [ %4, %8 ]
%16 = phi i8 [ %26, %24 ], [ 0, %8 ]
%17 = sext i8 %16 to i32
%18 = getelementptr inbounds i8, i8* %15, i64 -1
%19 = tail call i64 @toupper(i32 %17)
%20 = load i8, i8* %14
%21 = sext i8 %20 to i32
%22 = tail call i64 @toupper(i32 %21)
%23 = icmp eq i64 %19, %22
br i1 %23, label %24, label %28
24: ; preds = %13
%25 = getelementptr inbounds i8, i8* %14, i64 -1
%26 = load i8, i8* %18
%27 = icmp eq i8 %26, 46
br i1 %27, label %28, label %13
28: ; preds = %24, %13
%29 = phi i32 [ 0, %13 ], [ 1, %24 ]
ret i32 %29
}