#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 tolower(unsigned char);
int lstrcmpiA(const char *s1, const char *s2) {
  register int c1, c2;
  for (;;) {
    c1 = tolower((unsigned char)*s1++);
    c2 = tolower((unsigned char)*s2++);
    if (!c1 || c1 != c2)
      return (c1 - c2);
  }
}


x86 assembly (clang, -O0):
<lstrcmpiA>:
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)
movzbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     116a <lstrcmpiA+0x5a>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1176 <lstrcmpiA+0x66>
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret
jmp    1120 <lstrcmpiA+0x10>

x86 assembly (clang, -O2):
<lstrcmpiA>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nop
movzbl (%r15,%rbx,1),%edi
call   1030 <tolower@plt>
mov    %eax,%ebp
movzbl (%r14,%rbx,1),%edi
call   1030 <tolower@plt>
test   %ebp,%ebp
je     1142 <lstrcmpiA+0x32>
add    $0x1,%rbx
cmp    %eax,%ebp
je     1120 <lstrcmpiA+0x10>
sub    %eax,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @lstrcmpiA(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %7
7: ; preds = %26, %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 = call i32 @tolower(i8 zeroext %10)
store i32 %11, i32* %5
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %4
%14 = load i8, i8* %12
%15 = call i32 @tolower(i8 zeroext %14)
store i32 %15, i32* %6
%16 = load i32, i32* %5
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %7
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %26
22: ; preds = %18, %7
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = sub nsw i32 %23, %24
ret i32 %25
26: ; preds = %18
br label %7
}

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