#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 strlen(char const *);
scalar_t__ toupper(char const);
int strcasecmp(const char *s1, const char *s2) {
  int i;
  if (strlen(s1) != strlen(s1))
    return 1;
  for (i = 0; i < strlen(s1); i++)
    if (toupper(s1[i]) != toupper(s2[i]))
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<strcasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
je     115e <strcasecmp+0x3e>
movl   $0x1,-0x4(%rbp)
jmp    11dd <strcasecmp+0xbd>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    11d6 <strcasecmp+0xb6>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
je     11c3 <strcasecmp+0xa3>
movl   $0x1,-0x4(%rbp)
jmp    11dd <strcasecmp+0xbd>
jmp    11c8 <strcasecmp+0xa8>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1165 <strcasecmp+0x45>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcasecmp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r13
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    $0x1,%r14d
cmp    %eax,%r15d
jne    1193 <strcasecmp+0x73>
mov    %r13,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1190 <strcasecmp+0x70>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movsbl 0x0(%r13,%rbp,1),%edi
call   1030 <toupper@plt>
mov    %rax,%rbx
movsbl (%r12,%rbp,1),%edi
call   1030 <toupper@plt>
cmp    %rax,%rbx
jne    1193 <strcasecmp+0x73>
add    $0x1,%rbp
mov    %r13,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1160 <strcasecmp+0x40>
xor    %r14d,%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 @strcasecmp(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
%7 = load i8*, i8** %4
%8 = call i32 @strlen(i8* %7)
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = icmp ne i32 %8, %10
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 1, i32* %3
br label %39
13: ; preds = %2
store i32 0, i32* %6
br label %14
14: ; preds = %35, %13
%15 = load i32, i32* %6
%16 = load i8*, i8** %4
%17 = call i32 @strlen(i8* %16)
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %38
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = call i64 @toupper(i8 signext %24)
%26 = load i8*, i8** %5
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = call i64 @toupper(i8 signext %30)
%32 = icmp ne i64 %25, %31
br i1 %32, label %33, label %34
33: ; preds = %19
store i32 1, i32* %3
br label %39
34: ; preds = %19
br label %35
35: ; preds = %34
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %14
38: ; preds = %14
store i32 0, i32* %3
br label %39
39: ; preds = %38, %33, %12
%40 = load i32, i32* %3
ret i32 %40
}

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