#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 charupper(int /*<<< orphan*/);
int strcmpi(char *str1, char *str2) {
  for (;;) {
    char c1 = charupper(*(str1++));
    char c2 = charupper(*(str2++));
    if (!c1 || c1 != c2)
      return c1 - c2;
  }
}


x86 assembly (clang, -O0):
<strcmpi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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),%edi
call   1030 <charupper@plt>
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <charupper@plt>
mov    %al,-0x12(%rbp)
cmpb   $0x0,-0x11(%rbp)
je     116e <strcmpi+0x5e>
movsbl -0x11(%rbp),%eax
movsbl -0x12(%rbp),%ecx
cmp    %ecx,%eax
je     117e <strcmpi+0x6e>
movsbl -0x11(%rbp),%eax
movsbl -0x12(%rbp),%ecx
sub    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret
jmp    1120 <strcmpi+0x10>

x86 assembly (clang, -O2):
<strcmpi>:
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 <charupper@plt>
mov    %eax,%ebp
movsbl (%r14,%rbx,1),%edi
call   1030 <charupper@plt>
test   %bpl,%bpl
je     1144 <strcmpi+0x34>
add    $0x1,%rbx
cmp    %al,%bpl
je     1120 <strcmpi+0x10>
movsbl %bpl,%ecx
movsbl %al,%eax
sub    %eax,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @strcmpi(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
br label %7
7: ; preds = %32, %2
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %3
%10 = load i8, i8* %8
%11 = sext i8 %10 to i32
%12 = call signext i8 @charupper(i32 %11)
store i8 %12, i8* %5
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %4
%15 = load i8, i8* %13
%16 = sext i8 %15 to i32
%17 = call signext i8 @charupper(i32 %16)
store i8 %17, i8* %6
%18 = load i8, i8* %5
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %7
%21 = load i8, i8* %5
%22 = sext i8 %21 to i32
%23 = load i8, i8* %6
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %22, %24
br i1 %25, label %26, label %32
26: ; preds = %20, %7
%27 = load i8, i8* %5
%28 = sext i8 %27 to i32
%29 = load i8, i8* %6
%30 = sext i8 %29 to i32
%31 = sub nsw i32 %28, %30
ret i32 %31
32: ; preds = %20
br label %7
}

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