#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 strcmp(char *, char *);
char tolower(char);
int strcmp_lower(char *word1, char *word2) {
  int i = 0;
  char word1_lower[80];
  while (word1[i] != '\0') {
    word1_lower[i] = tolower(word1[i]);
    i++;
  }
  word1_lower[i] = '\0';
  return strcmp(word1_lower, word2);
}


x86 assembly (clang, -O0):
<strcmp_lower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1175 <strcmp_lower+0x55>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <strcmp_lower+0x17>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcmp@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmp_lower>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rsi,%r14
mov    (%rdi),%al
test   %al,%al
je     115d <strcmp_lower+0x3d>
mov    %rdi,%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %al,(%rsp,%rbx,1)
movzbl 0x1(%r15,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <strcmp_lower+0x20>
mov    %ebx,%eax
jmp    115f <strcmp_lower+0x3f>
xor    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @strcmp_lower(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %18, label %7
7: ; preds = %2, %7
%8 = phi i64 [ %12, %7 ], [ 0, %2 ]
%9 = phi i8 [ %14, %7 ], [ %5, %2 ]
%10 = tail call signext i8 @tolower(i8 signext %9)
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %8
store i8 %10, i8* %11
%12 = add nuw i64 %8, 1
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %7
16: ; preds = %7
%17 = and i64 %12, 4294967295
br label %18
18: ; preds = %16, %2
%19 = phi i64 [ 0, %2 ], [ %17, %16 ]
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %19
store i8 0, i8* %20
%21 = call i32 @strcmp(i8* %4, i8* dereferenceable(1) %1)
ret i32 %21
}