#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int toupper(int /*<<< orphan*/ const);
int strcasecmp(const char *first, const char *second) {
  const uint8_t *first_bytes = ((const uint8_t *)first);
  const uint8_t *second_bytes = ((const uint8_t *)second);
  int diff;
  for (;; first_bytes++, second_bytes++) {
    diff = (toupper(*second_bytes) - toupper(*first_bytes));
    if (diff)
      return diff;
    if (!*first_bytes)
      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),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     1168 <strcasecmp+0x58>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a3 <strcasecmp+0x93>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1181 <strcasecmp+0x71>
movl   $0x0,-0x4(%rbp)
jmp    11a3 <strcasecmp+0x93>
jmp    1186 <strcasecmp+0x76>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
jmp    1130 <strcasecmp+0x20>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcasecmp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
mov    (%rsi),%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
mov    (%r12),%r15d
mov    %r15d,%edi
call   1030 <toupper@plt>
sub    %eax,%ebp
test   %r15d,%r15d
je     1176 <strcasecmp+0x66>
test   %ebp,%ebp
jne    1176 <strcasecmp+0x66>
mov    $0x4,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
mov    (%r12,%rbx,1),%r15d
mov    %r15d,%edi
call   1030 <toupper@plt>
sub    %eax,%ebp
test   %r15d,%r15d
je     1176 <strcasecmp+0x66>
add    $0x4,%rbx
test   %ebp,%ebp
je     1150 <strcasecmp+0x40>
mov    %ebp,%eax
pop    %rbx
pop    %r12
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*
%7 = alloca i32*
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = bitcast i8* %9 to i32*
store i32* %10, i32** %6
%11 = load i8*, i8** %5
%12 = bitcast i8* %11 to i32*
store i32* %12, i32** %7
br label %13
13: ; preds = %31, %2
%14 = load i32*, i32** %7
%15 = load i32, i32* %14
%16 = call i32 @toupper(i32 %15)
%17 = load i32*, i32** %6
%18 = load i32, i32* %17
%19 = call i32 @toupper(i32 %18)
%20 = sub nsw i32 %16, %19
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %13
%24 = load i32, i32* %8
store i32 %24, i32* %3
br label %36
25: ; preds = %13
%26 = load i32*, i32** %6
%27 = load i32, i32* %26
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %25
store i32 0, i32* %3
br label %36
30: ; preds = %25
br label %31
31: ; preds = %30
%32 = load i32*, i32** %6
%33 = getelementptr inbounds i32, i32* %32, i32 1
store i32* %33, i32** %6
%34 = load i32*, i32** %7
%35 = getelementptr inbounds i32, i32* %34, i32 1
store i32* %35, i32** %7
br label %13
36: ; preds = %29, %23
%37 = load i32, i32* %3
ret i32 %37
}

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