#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 jam_toupper(char);
int jam_stricmp(char *left, char *right) {
  int result = 0;
  char l, r;
  do {
    l = jam_toupper(*left);
    r = jam_toupper(*right);
    result = l - r;
    ++left;
    ++right;
  } while ((result == 0) && (l != '\0') && (r != '\0'));
  return (result);
}


x86 assembly (clang, -O0):
<jam_stricmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <jam_toupper@plt>
mov    %al,-0x15(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <jam_toupper@plt>
mov    %al,-0x16(%rbp)
movsbl -0x15(%rbp),%eax
movsbl -0x16(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x17(%rbp)
jne    1198 <jam_stricmp+0x88>
movsbl -0x15(%rbp),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x17(%rbp)
je     1198 <jam_stricmp+0x88>
movsbl -0x16(%rbp),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x17(%rbp)
mov    -0x17(%rbp),%al
test   $0x1,%al
jne    1127 <jam_stricmp+0x17>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jam_stricmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nop
movsbl (%r15,%rbx,1),%edi
call   1030 <jam_toupper@plt>
mov    %eax,%ebp
movsbl (%r14,%rbx,1),%edi
call   1030 <jam_toupper@plt>
mov    %eax,%ecx
movsbl %bpl,%eax
movsbl %cl,%edx
sub    %edx,%eax
jne    1150 <jam_stricmp+0x40>
test   %bpl,%bpl
je     1150 <jam_stricmp+0x40>
add    $0x1,%rbx
test   %cl,%cl
jne    1120 <jam_stricmp+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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