#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 */
scalar_t__ tolower(char);
long dsscasecmp(char *s1, char *s2) {
  for (; tolower(*s1) == tolower(*s2); ++s1, ++s2)
    if (*s1 == '\0')
      return (0);
  return ((tolower(*s1) < tolower(*s2)) ? -1 : 1);
}


x86 assembly (clang, -O0):
<dsscasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jne    118b <dsscasecmp+0x7b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1169 <dsscasecmp+0x59>
movq   $0x0,-0x8(%rbp)
jmp    11c4 <dsscasecmp+0xb4>
jmp    116e <dsscasecmp+0x5e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <dsscasecmp+0x10>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    -0x28(%rbp),%rdx
mov    %rax,%rsi
mov    $0x1,%eax
mov    $0xffffffff,%ecx
cmp    %rsi,%rdx
cmovl  %ecx,%eax
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dsscasecmp>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1030 <tolower@plt>
mov    %rax,%r15
movsbl (%r14),%edi
call   1030 <tolower@plt>
cmp    %rax,%r15
jne    116d <dsscasecmp+0x5d>
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,(%rbx)
je     1195 <dsscasecmp+0x85>
lea    0x1(%r14),%r13
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <tolower@plt>
mov    %rax,%r12
movsbl 0x1(%r14),%edi
call   1030 <tolower@plt>
mov    %r13,%r14
cmp    %rax,%r12
je     1140 <dsscasecmp+0x30>
jmp    1170 <dsscasecmp+0x60>
mov    %r14,%r13
movsbl (%rbx),%edi
call   1030 <tolower@plt>
mov    %rax,%rbx
movsbl 0x0(%r13),%edi
call   1030 <tolower@plt>
xor    %ecx,%ecx
cmp    %rax,%rbx
setge  %cl
lea    (%rcx,%rcx,1),%r15
add    $0xffffffffffffffff,%r15
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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