#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 */
char SDL_toupper(char const);
int SDL_strcasecmp(const char *str1, const char *str2) {
  char a = 0;
  char b = 0;
  while (*str1 && *str2) {
    a = SDL_toupper((unsigned char)*str1);
    b = SDL_toupper((unsigned char)*str2);
    if (a != b)
      break;
    ++str1;
    ++str2;
  }
  a = SDL_toupper(*str1);
  b = SDL_toupper(*str2);
  return (int)((unsigned char)a - (unsigned char)b);
}


x86 assembly (clang, -O0):
<SDL_strcasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movb   $0x0,-0x12(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x13(%rbp)
je     114d <SDL_strcasecmp+0x3d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x13(%rbp)
mov    -0x13(%rbp),%al
test   $0x1,%al
jne    115d <SDL_strcasecmp+0x4d>
jmp    11ad <SDL_strcasecmp+0x9d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <SDL_toupper@plt>
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <SDL_toupper@plt>
mov    %al,-0x12(%rbp)
movsbl -0x11(%rbp),%eax
movsbl -0x12(%rbp),%ecx
cmp    %ecx,%eax
je     1190 <SDL_strcasecmp+0x80>
jmp    11ad <SDL_strcasecmp+0x9d>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1128 <SDL_strcasecmp+0x18>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <SDL_toupper@plt>
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <SDL_toupper@plt>
mov    %al,-0x12(%rbp)
movzbl -0x11(%rbp),%eax
movzbl -0x12(%rbp),%ecx
sub    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SDL_strcasecmp>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    (%rdi),%al
test   %al,%al
je     115d <SDL_strcasecmp+0x4d>
mov    %rdi,%rbx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x0,(%r14)
je     1164 <SDL_strcasecmp+0x54>
movsbl %al,%edi
call   1030 <SDL_toupper@plt>
mov    %eax,%ebp
movsbl (%r14),%edi
call   1030 <SDL_toupper@plt>
cmp    %al,%bpl
jne    1161 <SDL_strcasecmp+0x51>
add    $0x1,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <SDL_strcasecmp+0x20>
xor    %eax,%eax
jmp    1164 <SDL_strcasecmp+0x54>
mov    -0x1(%rbx),%al
movsbl %al,%edi
call   1030 <SDL_toupper@plt>
mov    %eax,%ebx
movsbl (%r14),%edi
call   1030 <SDL_toupper@plt>
movzbl %bl,%ecx
movzbl %al,%eax
sub    %eax,%ecx
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @SDL_strcasecmp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8 0, i8* %5
store i8 0, i8* %6
br label %7
7: ; preds = %32, %2
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br label %17
17: ; preds = %12, %7
%18 = phi i1 [ false, %7 ], [ %16, %12 ]
br i1 %18, label %19, label %37
19: ; preds = %17
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = call signext i8 @SDL_toupper(i8 signext %21)
store i8 %22, i8* %5
%23 = load i8*, i8** %4
%24 = load i8, i8* %23
%25 = call signext i8 @SDL_toupper(i8 signext %24)
store i8 %25, i8* %6
%26 = load i8, i8* %5
%27 = sext i8 %26 to i32
%28 = load i8, i8* %6
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %27, %29
br i1 %30, label %31, label %32
31: ; preds = %19
br label %37
32: ; preds = %19
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %4
br label %7
37: ; preds = %31, %17
%38 = load i8*, i8** %3
%39 = load i8, i8* %38
%40 = call signext i8 @SDL_toupper(i8 signext %39)
store i8 %40, i8* %5
%41 = load i8*, i8** %4
%42 = load i8, i8* %41
%43 = call signext i8 @SDL_toupper(i8 signext %42)
store i8 %43, i8* %6
%44 = load i8, i8* %5
%45 = zext i8 %44 to i32
%46 = load i8, i8* %6
%47 = zext i8 %46 to i32
%48 = sub nsw i32 %45, %47
ret i32 %48
}

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