#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 toupper(int /*<<< orphan*/);
int cistrcmp(char *s1, char *s2) {
  char ch1;
  char ch2;
  do {
    ch1 = toupper(*s1++);
    ch2 = toupper(*s2++);
    if ((ch1 == ch2) && (ch1 == 0))
      return 0;
  } while (ch1 == ch2);
  return ((ch1 < ch2) ? -1 : 1);
}


x86 assembly (clang, -O0):
<cistrcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,-0x1a(%rbp)
movsbl -0x19(%rbp),%eax
movsbl -0x1a(%rbp),%ecx
cmp    %ecx,%eax
jne    117d <cistrcmp+0x6d>
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
jne    117d <cistrcmp+0x6d>
movl   $0x0,-0x4(%rbp)
jmp    11ac <cistrcmp+0x9c>
jmp    1182 <cistrcmp+0x72>
movsbl -0x19(%rbp),%eax
movsbl -0x1a(%rbp),%ecx
cmp    %ecx,%eax
je     1120 <cistrcmp+0x10>
movsbl -0x19(%rbp),%edx
movsbl -0x1a(%rbp),%esi
mov    $0x1,%eax
mov    $0xffffffff,%ecx
cmp    %esi,%edx
cmovl  %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cistrcmp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r12
xor    %r14d,%r14d
xor    %ebx,%ebx
jmp    1139 <cistrcmp+0x29>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
cmp    %al,%bpl
jne    115b <cistrcmp+0x4b>
movsbl (%r12,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
movsbl (%r15,%rbx,1),%edi
call   1030 <toupper@plt>
test   %bpl,%bpl
jne    1130 <cistrcmp+0x20>
cmp    %al,%bpl
jne    1130 <cistrcmp+0x20>
jmp    1169 <cistrcmp+0x59>
setge  %al
movzbl %al,%eax
lea    (%rax,%rax,1),%r14d
add    $0xffffffff,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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