#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__ strlen(char const *);
char tolower(char const);
int does_extension_match(const char *ext, const char *test) {
  char c1, c2;
  if ((!ext) || (!test))
    return 0;
  if (strlen(ext) != strlen(test))
    return 0;
  while (*ext && *test) {
    c1 = tolower(*ext);
    c2 = tolower(*test);
    if (c1 > c2)
      return 0;
    if (c1 < c2)
      return 0;
    ext++;
    test++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<does_extension_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1146 <does_extension_match+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1152 <does_extension_match+0x32>
movl   $0x0,-0x4(%rbp)
jmp    1238 <does_extension_match+0x118>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     1184 <does_extension_match+0x64>
movl   $0x0,-0x4(%rbp)
jmp    1238 <does_extension_match+0x118>
jmp    1189 <does_extension_match+0x69>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
je     11ae <does_extension_match+0x8e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11be <does_extension_match+0x9e>
jmp    1231 <does_extension_match+0x111>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %al,-0x1a(%rbp)
movsbl -0x19(%rbp),%eax
movsbl -0x1a(%rbp),%ecx
cmp    %ecx,%eax
jle    11f8 <does_extension_match+0xd8>
movl   $0x0,-0x4(%rbp)
jmp    1238 <does_extension_match+0x118>
movsbl -0x19(%rbp),%eax
movsbl -0x1a(%rbp),%ecx
cmp    %ecx,%eax
jge    1214 <does_extension_match+0xf4>
movl   $0x0,-0x4(%rbp)
jmp    1238 <does_extension_match+0x118>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1189 <does_extension_match+0x69>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<does_extension_match>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r14d,%r14d
test   %rdi,%rdi
je     11a4 <does_extension_match+0x84>
mov    %rsi,%r13
test   %rsi,%rsi
je     11a4 <does_extension_match+0x84>
mov    %rdi,%r12
call   1030 <strlen@plt>
mov    %rax,%r15
mov    %r13,%rdi
call   1030 <strlen@plt>
cmp    %rax,%r15
jne    11a4 <does_extension_match+0x84>
mov    (%r12),%al
mov    $0x1,%r14d
test   %al,%al
je     11a4 <does_extension_match+0x84>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpb   $0x0,0x0(%r13,%rbp,1)
je     11a4 <does_extension_match+0x84>
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %eax,%ebx
movsbl 0x0(%r13,%rbp,1),%edi
call   1040 <tolower@plt>
cmp    %al,%bl
jne    11a1 <does_extension_match+0x81>
movzbl 0x1(%r12,%rbp,1),%eax
add    $0x1,%rbp
test   %al,%al
jne    1170 <does_extension_match+0x50>
jmp    11a4 <does_extension_match+0x84>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @does_extension_match(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %10, %2
store i32 0, i32* %3
br label %60
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = call i64 @strlen(i8* %15)
%17 = load i8*, i8** %5
%18 = call i64 @strlen(i8* %17)
%19 = icmp ne i64 %16, %18
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 0, i32* %3
br label %60
21: ; preds = %14
br label %22
22: ; preds = %54, %21
%23 = load i8*, i8** %4
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %22
%28 = load i8*, i8** %5
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 0
br label %32
32: ; preds = %27, %22
%33 = phi i1 [ false, %22 ], [ %31, %27 ]
br i1 %33, label %34, label %59
34: ; preds = %32
%35 = load i8*, i8** %4
%36 = load i8, i8* %35
%37 = call signext i8 @tolower(i8 signext %36)
store i8 %37, i8* %6
%38 = load i8*, i8** %5
%39 = load i8, i8* %38
%40 = call signext i8 @tolower(i8 signext %39)
store i8 %40, i8* %7
%41 = load i8, i8* %6
%42 = sext i8 %41 to i32
%43 = load i8, i8* %7
%44 = sext i8 %43 to i32
%45 = icmp sgt i32 %42, %44
br i1 %45, label %46, label %47
46: ; preds = %34
store i32 0, i32* %3
br label %60
47: ; preds = %34
%48 = load i8, i8* %6
%49 = sext i8 %48 to i32
%50 = load i8, i8* %7
%51 = sext i8 %50 to i32
%52 = icmp slt i32 %49, %51
br i1 %52, label %53, label %54
53: ; preds = %47
store i32 0, i32* %3
br label %60
54: ; preds = %47
%55 = load i8*, i8** %4
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %4
%57 = load i8*, i8** %5
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %5
br label %22
59: ; preds = %32
store i32 1, i32* %3
br label %60
60: ; preds = %59, %53, %46, %20, %13
%61 = load i32, i32* %3
ret i32 %61
}

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