#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(char const);
int UtilStrCaseCmp(const char *A, const char *B) {
  for (; *A || *B; A++, B++) {
    if (toupper(*A) != toupper(*B))
      return (toupper(*A) - toupper(*B));
  }
  return 0;
}


x86 assembly (clang, -O0):
<UtilStrCaseCmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
jne    1145 <UtilStrCaseCmp+0x35>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1155 <UtilStrCaseCmp+0x45>
jmp    11c9 <UtilStrCaseCmp+0xb9>
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
cmp    %ecx,%eax
je     11a7 <UtilStrCaseCmp+0x97>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11d0 <UtilStrCaseCmp+0xc0>
jmp    11ac <UtilStrCaseCmp+0x9c>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <UtilStrCaseCmp+0x10>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UtilStrCaseCmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
nop
movzbl (%r14,%rbx,1),%eax
test   %al,%al
jne    1130 <UtilStrCaseCmp+0x20>
cmpb   $0x0,(%r15,%rbx,1)
je     1168 <UtilStrCaseCmp+0x58>
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
movsbl (%r15,%rbx,1),%edi
call   1030 <toupper@plt>
cmp    %eax,%ebp
jne    114e <UtilStrCaseCmp+0x3e>
add    $0x1,%rbx
jmp    1120 <UtilStrCaseCmp+0x10>
movsbl (%r14,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
movsbl (%r15,%rbx,1),%edi
call   1030 <toupper@plt>
sub    %eax,%ebp
jmp    116a <UtilStrCaseCmp+0x5a>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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