#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__ strlen(char *);
scalar_t__ toupper(char);
int strbcmp(char *a, char *b) {
  unsigned int i = 0;
  if (strlen(a) != strlen(b))
    return 1;
  while (a[i] != '\0' && b[i] != '\0') {
    if (toupper(a[i]) != toupper(b[i]))
      return 1;
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<strbcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     1169 <strbcmp+0x49>
movl   $0x1,-0x4(%rbp)
jmp    1200 <strbcmp+0xe0>
jmp    116e <strbcmp+0x4e>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
je     119b <strbcmp+0x7b>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11ab <strbcmp+0x8b>
jmp    11f9 <strbcmp+0xd9>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
je     11eb <strbcmp+0xcb>
movl   $0x1,-0x4(%rbp)
jmp    1200 <strbcmp+0xe0>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116e <strbcmp+0x4e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strbcmp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %rax,%r12
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    $0x1,%r15d
cmp    %rax,%r12
jne    119e <strbcmp+0x7e>
mov    (%r14),%al
test   %al,%al
je     1193 <strbcmp+0x73>
mov    $0x1,%ebp
xor    %r15d,%r15d
xor    %ebx,%ebx
nopl   (%rax)
cmpb   $0x0,0x0(%r13,%rbx,1)
je     119e <strbcmp+0x7e>
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %rax,%r12
movsbl 0x0(%r13,%rbx,1),%edi
call   1030 <toupper@plt>
cmp    %rax,%r12
jne    1198 <strbcmp+0x78>
mov    %ebp,%ebx
movzbl (%r14,%rbx,1),%eax
add    $0x1,%ebp
test   %al,%al
jne    1160 <strbcmp+0x40>
jmp    119e <strbcmp+0x7e>
xor    %r15d,%r15d
jmp    119e <strbcmp+0x7e>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @strbcmp(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
store i32 0, i32* %6
%7 = load i8*, i8** %4
%8 = call i64 @strlen(i8* %7)
%9 = load i8*, i8** %5
%10 = call i64 @strlen(i8* %9)
%11 = icmp ne i64 %8, %10
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 1, i32* %3
br label %51
13: ; preds = %2
br label %14
14: ; preds = %47, %13
%15 = load i8*, i8** %4
%16 = load i32, i32* %6
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %14
%23 = load i8*, i8** %5
%24 = load i32, i32* %6
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br label %30
30: ; preds = %22, %14
%31 = phi i1 [ false, %14 ], [ %29, %22 ]
br i1 %31, label %32, label %50
32: ; preds = %30
%33 = load i8*, i8** %4
%34 = load i32, i32* %6
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = call i64 @toupper(i8 signext %37)
%39 = load i8*, i8** %5
%40 = load i32, i32* %6
%41 = zext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = call i64 @toupper(i8 signext %43)
%45 = icmp ne i64 %38, %44
br i1 %45, label %46, label %47
46: ; preds = %32
store i32 1, i32* %3
br label %51
47: ; preds = %32
%48 = load i32, i32* %6
%49 = add i32 %48, 1
store i32 %49, i32* %6
br label %14
50: ; preds = %30
store i32 0, i32* %3
br label %51
51: ; preds = %50, %46, %12
%52 = load i32, i32* %3
ret i32 %52
}

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