#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 */
char *strrchr(char const *, char);
scalar_t__ toupper(char const);
int equal_filename(const char *zipfile, const char *file) {
  const char *s1 = file;
  const char *s2 = strrchr(zipfile, '/');
  if (s2)
    ++s2;
  else
    s2 = zipfile;
  while (*s1 && toupper(*s1) == toupper(*s2)) {
    ++s1;
    ++s2;
  }
  return !*s1 && !*s2;
}


x86 assembly (clang, -O0):
<equal_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1166 <equal_filename+0x46>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    116e <equal_filename+0x4e>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1173 <equal_filename+0x53>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     11b4 <equal_filename+0x94>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11c4 <equal_filename+0xa4>
jmp    11e1 <equal_filename+0xc1>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1173 <equal_filename+0x53>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmpb   $0x0,(%rcx)
mov    %al,-0x31(%rbp)
jne    1202 <equal_filename+0xe2>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
setne  %al
xor    $0xff,%al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<equal_filename>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0x2f,%esi
call   1040 <strrchr@plt>
lea    0x1(%rax),%r15
test   %rax,%rax
cmove  %r14,%r15
mov    (%rbx),%al
test   %al,%al
je     1182 <equal_filename+0x62>
add    $0x1,%rbx
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %rax,%r14
movsbl (%r15),%edi
call   1030 <toupper@plt>
cmp    %rax,%r14
jne    117a <equal_filename+0x5a>
add    $0x1,%r15
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <equal_filename+0x30>
jmp    1182 <equal_filename+0x62>
xor    %eax,%eax
cmpb   $0x0,-0x1(%rbx)
jne    118b <equal_filename+0x6b>
xor    %eax,%eax
cmpb   $0x0,(%r15)
sete   %al
pop    %rbx
pop    %r14
pop    %r15
ret

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

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