#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(char);
extern int stricmp(char *s1, char *s2) {
  for (; *s1 != 0; s1++, s2++) {
    if (toupper(*s1) != toupper(*s2))
      break;
  }
  return (toupper(*s1) - toupper(*s2));
}


x86 assembly (clang, -O0):
<stricmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     117f <stricmp+0x6f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
je     115d <stricmp+0x4d>
jmp    117f <stricmp+0x6f>
jmp    1162 <stricmp+0x52>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1120 <stricmp+0x10>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
sub    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stricmp>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    (%rdi),%al
test   %al,%al
je     1156 <stricmp+0x46>
mov    %rdi,%rbx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
movsbl (%r14),%edi
call   1030 <toupper@plt>
cmp    %eax,%ebp
jne    115a <stricmp+0x4a>
add    $0x1,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <stricmp+0x20>
xor    %eax,%eax
jmp    115d <stricmp+0x4d>
mov    -0x1(%rbx),%al
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %eax,%ebx
movsbl (%r14),%edi
call   1030 <toupper@plt>
sub    %eax,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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