#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 toupper(int);
int MatchName(char *str1, char *str2) {
  for (; toupper((int)*str1) == toupper((int)*str2); str1++, str2++)
    if (*str1 == '\0')
      return (0);
  return (toupper((int)*str1) - toupper((int)*str2));
}


x86 assembly (clang, -O0):
<MatchName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jne    1186 <MatchName+0x76>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1164 <MatchName+0x54>
movl   $0x0,-0x4(%rbp)
jmp    11ab <MatchName+0x9b>
jmp    1169 <MatchName+0x59>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <MatchName+0x10>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MatchName>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdi),%bl
movsbl %bl,%edi
call   1030 <toupper@plt>
mov    %eax,%r12d
movsbl (%r14),%edi
call   1030 <toupper@plt>
cmp    %eax,%r12d
jne    1167 <MatchName+0x57>
mov    $0x1,%ebp
xchg   %ax,%ax
test   %bl,%bl
je     116c <MatchName+0x5c>
movzbl (%r15,%rbp,1),%ebx
movsbl %bl,%edi
call   1030 <toupper@plt>
mov    %eax,%r12d
movsbl (%r14,%rbp,1),%edi
call   1030 <toupper@plt>
add    $0x1,%rbp
cmp    %eax,%r12d
je     1140 <MatchName+0x30>
sub    %eax,%r12d
jmp    116f <MatchName+0x5f>
xor    %r12d,%r12d
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @MatchName(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 = %23, %2
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = call i32 @toupper(i32 %9)
%11 = load i8*, i8** %5
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = call i32 @toupper(i32 %13)
%15 = icmp eq i32 %10, %14
br i1 %15, label %16, label %28
16: ; preds = %6
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
store i32 0, i32* %3
br label %38
22: ; preds = %16
br label %23
23: ; preds = %22
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %4
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %5
br label %6
28: ; preds = %6
%29 = load i8*, i8** %4
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = call i32 @toupper(i32 %31)
%33 = load i8*, i8** %5
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = call i32 @toupper(i32 %35)
%37 = sub nsw i32 %32, %36
store i32 %37, i32* %3
br label %38
38: ; preds = %28, %21
%39 = load i32, i32* %3
ret i32 %39
}

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