#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 const);
int istrcmp(const char *s1, const char *s2) {
  int d;
  for (;;) {
    d = tolower(*s1) - tolower(*s2);
    if (d != 0 || *s1 == '\0' || *s2 == '\0')
      return d;
    s1++;
    s2++;
  }
}


x86 assembly (clang, -O0):
<istrcmp>:
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,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    116f <istrcmp+0x5f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     116f <istrcmp+0x5f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1178 <istrcmp+0x68>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1120 <istrcmp+0x10>

x86 assembly (clang, -O2):
<istrcmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
movsbl (%rdi),%edi
call   1030 <tolower@plt>
mov    %eax,%ebp
movsbl (%r14),%edi
call   1030 <tolower@plt>
sub    %eax,%ebp
je     1141 <istrcmp+0x31>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %ebp,%ebp
cmpb   $0x0,-0x1(%r15,%rbx,1)
je     1134 <istrcmp+0x24>
cmpb   $0x0,-0x1(%r14,%rbx,1)
je     1134 <istrcmp+0x24>
movsbl (%r15,%rbx,1),%edi
call   1030 <tolower@plt>
mov    %eax,%ebp
movsbl (%r14,%rbx,1),%edi
call   1030 <tolower@plt>
add    $0x1,%rbx
sub    %eax,%ebp
je     1150 <istrcmp+0x40>
jmp    1134 <istrcmp+0x24>

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

LLVM IR (-O2):
define i32 @istrcmp(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 %17
9: ; preds = %2, %19
%10 = phi i8* [ %20, %19 ], [ %0, %2 ]
%11 = phi i8* [ %21, %19 ], [ %1, %2 ]
%12 = load i8, i8* %10
%13 = icmp eq i8 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = load i8, i8* %11
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %19, %9, %14, %2
%18 = phi i32 [ %7, %2 ], [ 0, %14 ], [ 0, %9 ], [ %26, %19 ]
ret i32 %18
19: ; preds = %14
%20 = getelementptr inbounds i8, i8* %10, i64 1
%21 = getelementptr inbounds i8, i8* %11, i64 1
%22 = load i8, i8* %20
%23 = tail call i32 @tolower(i8 signext %22)
%24 = load i8, i8* %21
%25 = tail call i32 @tolower(i8 signext %24)
%26 = sub nsw i32 %23, %25
%27 = icmp eq i32 %26, 0
br i1 %27, label %9, label %17
}