#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 readTagCharacter(char const **);
int toupper(int);
int taguppercmp(const char *s1, const char *s2) {
  int result;
  int c1, c2;
  do {
    c1 = *s1++;
    c2 = readTagCharacter(&s2);
    result = toupper(c1) - toupper(c2);
  } while (result == 0 && c1 != '\0' && c2 != '\0');
  return result;
}


x86 assembly (clang, -O0):
<taguppercmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <readTagCharacter@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <toupper@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x21(%rbp)
jne    1196 <taguppercmp+0x76>
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x21(%rbp)
je     1196 <taguppercmp+0x76>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1130 <taguppercmp+0x10>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<taguppercmp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %rsi,0x8(%rsp)
lea    0x8(%rsp),%r14
nopl   0x0(%rax)
movzbl (%rbx),%r12d
movsbl %r12b,%ebp
mov    %r14,%rdi
call   1040 <readTagCharacter@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
mov    %r15d,%edi
call   1030 <toupper@plt>
sub    %eax,%ebp
test   %r15d,%r15d
je     1178 <taguppercmp+0x58>
test   %ebp,%ebp
jne    1178 <taguppercmp+0x58>
add    $0x1,%rbx
test   %r12b,%r12b
jne    1140 <taguppercmp+0x20>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @taguppercmp(i8* nocapture %0, i8* %1) {
%3 = alloca i8*
store i8* %1, i8** %3
br label %4
4: ; preds = %4, %2
%5 = phi i8* [ %0, %2 ], [ %6, %4 ]
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = load i8, i8* %5
%8 = sext i8 %7 to i32
%9 = call i32 @readTagCharacter(i8** %3)
%10 = call i32 @toupper(i32 %8)
%11 = call i32 @toupper(i32 %9)
%12 = sub nsw i32 %10, %11
%13 = icmp eq i32 %12, 0
%14 = icmp ne i8 %7, 0
%15 = select i1 %13, i1 %14, i1 false
%16 = icmp ne i32 %9, 0
%17 = and i1 %16, %15
br i1 %17, label %4, label %18
18: ; preds = %4
ret i32 %12
}