#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(char);
int _strcmp(char *src, char *dst) {
  int ret;
  while (!(ret = tolower(*src) - tolower(*dst)) && *dst) {
    ++src, ++dst;
  }
  if (ret < 0) {
    ret = -1;
  } else if (ret > 0) {
    ret = 1;
  }
  return ret;
}


x86 assembly (clang, -O0):
<_strcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    -0x1c(%rbp),%ecx
sub    %eax,%ecx
mov    %ecx,-0x14(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x15(%rbp)
jne    1161 <_strcmp+0x51>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1171 <_strcmp+0x61>
jmp    118e <_strcmp+0x7e>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1120 <_strcmp+0x10>
cmpl   $0x0,-0x14(%rbp)
jge    11a4 <_strcmp+0x94>
movl   $0xffffffff,-0x14(%rbp)
jmp    11ba <_strcmp+0xaa>
cmpl   $0x0,-0x14(%rbp)
jle    11b5 <_strcmp+0xa5>
movl   $0x1,-0x14(%rbp)
jmp    11ba <_strcmp+0xaa>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_strcmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
movsbl (%rdi),%edi
call   1030 <tolower@plt>
mov    %eax,%ebp
movsbl (%r15),%edi
call   1030 <tolower@plt>
sub    %eax,%ebp
jne    1166 <_strcmp+0x56>
mov    $0x1,%ebx
nopl   0x0(%rax)
cmpb   $0x0,-0x1(%r15,%rbx,1)
je     1176 <_strcmp+0x66>
movsbl (%r14,%rbx,1),%edi
call   1030 <tolower@plt>
mov    %eax,%ebp
movsbl (%r15,%rbx,1),%edi
call   1030 <tolower@plt>
add    $0x1,%rbx
sub    %eax,%ebp
je     1140 <_strcmp+0x30>
mov    $0x1,%eax
test   %ebp,%ebp
jns    1178 <_strcmp+0x68>
mov    $0xffffffff,%eax
jmp    1178 <_strcmp+0x68>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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