#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 toupper(unsigned char);
int mycmp(char *s1, char *s2) {
  register unsigned char *str1 = (unsigned char *)s1;
  register unsigned char *str2 = (unsigned char *)s2;
  register int res;
  while ((res = toupper(*str1) - toupper(*str2)) == 0) {
    if (*str1 == '\0')
      return 0;
    str1++;
    str2++;
    if (((*str1 == '\n') || (*str1 == '\r')) && (*str2 == '\0'))
      return 0;
  }
  return (res);
}


x86 assembly (clang, -O0):
<mycmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movzbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jne    11d3 <mycmp+0xc3>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    117a <mycmp+0x6a>
movl   $0x0,-0x4(%rbp)
jmp    11d9 <mycmp+0xc9>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xa,%eax
je     11b2 <mycmp+0xa2>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xd,%eax
jne    11ce <mycmp+0xbe>
mov    -0x28(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    11ce <mycmp+0xbe>
movl   $0x0,-0x4(%rbp)
jmp    11d9 <mycmp+0xc9>
jmp    1130 <mycmp+0x20>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mycmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
movzbl (%rdi),%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
movzbl (%r14),%edi
call   1030 <toupper@plt>
sub    %eax,%ebp
je     1141 <mycmp+0x31>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebx
jmp    1173 <mycmp+0x63>
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,(%r14,%rbx,1)
je     1134 <mycmp+0x24>
movzbl %al,%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
movzbl (%r14,%rbx,1),%edi
call   1030 <toupper@plt>
add    $0x1,%rbx
sub    %eax,%ebp
jne    1134 <mycmp+0x24>
xor    %ebp,%ebp
cmpb   $0x0,-0x1(%r15,%rbx,1)
je     1134 <mycmp+0x24>
movzbl (%r15,%rbx,1),%eax
cmp    $0xd,%al
je     1150 <mycmp+0x40>
cmp    $0xa,%al
je     1150 <mycmp+0x40>
jmp    1157 <mycmp+0x47>

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

LLVM IR (-O2):
define i32 @mycmp(i8* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %0
%4 = tail call i32 @toupper(i8 zeroext %3)
%5 = load i8, i8* %1
%6 = tail call i32 @toupper(i8 zeroext %5)
%7 = sub nsw i32 %4, %6
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %27
9: ; preds = %2, %21
%10 = phi i8* [ %16, %21 ], [ %1, %2 ]
%11 = phi i8* [ %15, %21 ], [ %0, %2 ]
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %27, 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
switch i8 %17, label %21 [
i8 10, label %18
i8 13, label %18
]
18: ; preds = %14, %14
%19 = load i8, i8* %16
%20 = icmp eq i8 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %14, %18
%22 = tail call i32 @toupper(i8 zeroext %17)
%23 = load i8, i8* %16
%24 = tail call i32 @toupper(i8 zeroext %23)
%25 = sub nsw i32 %22, %24
%26 = icmp eq i32 %25, 0
br i1 %26, label %9, label %27
27: ; preds = %9, %18, %21, %2
%28 = phi i32 [ %7, %2 ], [ %25, %21 ], [ 0, %18 ], [ 0, %9 ]
ret i32 %28
}