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


x86 assembly (clang, -O0):
<struppercmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x19(%rbp)
jne    118f <struppercmp+0x7f>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     118f <struppercmp+0x7f>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1120 <struppercmp+0x10>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<struppercmp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%r15,%rbx,1),%r12d
movsbl %r12b,%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
movzbl (%r14,%rbx,1),%r13d
movsbl %r13b,%edi
call   1030 <toupper@plt>
sub    %eax,%ebp
jne    1160 <struppercmp+0x50>
test   %r12b,%r12b
je     1160 <struppercmp+0x50>
add    $0x1,%rbx
test   %r13b,%r13b
jne    1130 <struppercmp+0x20>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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