#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__ toupper(char);
int reg_case_equal(char *s1, char *s2) {
  while (1) {
    if (toupper(*s1) != toupper(*s2))
      return 0;
    if (*s1 == '\0' || *s2 == '\0')
      return 1;
    s1++;
    s2++;
  }
}


x86 assembly (clang, -O0):
<reg_case_equal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     1158 <reg_case_equal+0x48>
movl   $0x0,-0x4(%rbp)
jmp    11a1 <reg_case_equal+0x91>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1178 <reg_case_equal+0x68>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1184 <reg_case_equal+0x74>
movl   $0x1,-0x4(%rbp)
jmp    11a1 <reg_case_equal+0x91>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <reg_case_equal+0x10>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reg_case_equal>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
movsbl (%rdi),%edi
call   1030 <toupper@plt>
mov    %rax,%r15
movsbl (%r14),%edi
call   1030 <toupper@plt>
cmp    %rax,%r15
jne    1175 <reg_case_equal+0x65>
mov    $0x1,%ebx
nopl   0x0(%rax)
mov    $0x1,%eax
cmpb   $0x0,-0x1(%r12,%rbx,1)
je     1177 <reg_case_equal+0x67>
cmpb   $0x0,-0x1(%r14,%rbx,1)
je     1177 <reg_case_equal+0x67>
movsbl (%r12,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %rax,%r15
movsbl (%r14,%rbx,1),%edi
call   1030 <toupper@plt>
add    $0x1,%rbx
cmp    %rax,%r15
je     1140 <reg_case_equal+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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