#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(unsigned char);
int strccmp(unsigned char *s1, unsigned char *s2) {
  int res;
  while (*s1 || *s2) {
    if ((res = toupper(*s1) - toupper(*s2)))
      return res;
    s1++;
    s2++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<strccmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
jne    1145 <strccmp+0x35>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1155 <strccmp+0x45>
jmp    11ab <strccmp+0x9b>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
je     118e <strccmp+0x7e>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b2 <strccmp+0xa2>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <strccmp+0x10>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strccmp>:
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 <strccmp+0x20>
cmpb   $0x0,(%r15,%rbx,1)
je     114e <strccmp+0x3e>
movzbl %al,%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
movzbl (%r15,%rbx,1),%edi
call   1030 <toupper@plt>
sub    %eax,%ebp
jne    1150 <strccmp+0x40>
add    $0x1,%rbx
jmp    1120 <strccmp+0x10>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @strccmp(i8* nocapture %0, i8* nocapture %1) {
br label %3
3: ; preds = %17, %2
%4 = phi i8* [ %0, %2 ], [ %18, %17 ]
%5 = phi i8* [ %1, %2 ], [ %19, %17 ]
%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 %20, label %11
11: ; preds = %3, %8
%12 = tail call i32 @toupper(i8 zeroext %6)
%13 = load i8, i8* %5
%14 = tail call i32 @toupper(i8 zeroext %13)
%15 = sub nsw i32 %12, %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = getelementptr inbounds i8, i8* %4, i64 1
%19 = getelementptr inbounds i8, i8* %5, i64 1
br label %3
20: ; preds = %8, %11
%21 = phi i32 [ %15, %11 ], [ 0, %8 ]
ret i32 %21
}