#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 const);
int striequal(const char *s0, const char *s1) {
  int c;
  do {
    c = *s0;
    if (tolower(c) != tolower(*s1))
      return 0;
    ++s0;
    ++s1;
  } while (c != '\0');
  return 1;
}


x86 assembly (clang, -O0):
<striequal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
movsbl %al,%edi
call   1030 <tolower@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     1161 <striequal+0x51>
movl   $0x0,-0x4(%rbp)
jmp    118a <striequal+0x7a>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1120 <striequal+0x10>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<striequal>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r12
xor    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movzbl (%r12,%rbx,1),%ebp
movsbl %bpl,%edi
call   1030 <tolower@plt>
mov    %rax,%r13
movsbl (%r15,%rbx,1),%edi
call   1030 <tolower@plt>
cmp    %rax,%r13
jne    115f <striequal+0x4f>
add    $0x1,%rbx
test   %bpl,%bpl
jne    1130 <striequal+0x20>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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