#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__ toupper(char);
int symbol_compare(char *symbol1, char *symbol2, int symbol_length) {
  int i;
  int rc;
  rc = 1;
  for (i = 0; (i < symbol_length) && rc; i++) {
    if (toupper(symbol1[i]) != toupper(symbol2[i]))
      rc = 0;
  }
  return rc;
}


x86 assembly (clang, -O0):
<symbol_compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x1d(%rbp)
jge    114c <symbol_compare+0x3c>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    115c <symbol_compare+0x4c>
jmp    11ac <symbol_compare+0x9c>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     1199 <symbol_compare+0x89>
movl   $0x0,-0x1c(%rbp)
jmp    119e <symbol_compare+0x8e>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1131 <symbol_compare+0x21>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<symbol_compare>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
jle    1161 <symbol_compare+0x51>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%r12d
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
movsbl -0x1(%r15,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %rax,%r13
movsbl -0x1(%r14,%rbx,1),%edi
call   1030 <toupper@plt>
cmp    %r12,%rbx
jae    1157 <symbol_compare+0x47>
add    $0x1,%rbx
cmp    %rax,%r13
je     1130 <symbol_compare+0x20>
xor    %ecx,%ecx
cmp    %rax,%r13
sete   %cl
jmp    1166 <symbol_compare+0x56>
mov    $0x1,%ecx
mov    %ecx,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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