#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 strlen(char *);
scalar_t__ tolower(char);
int Flncmp(char *f1, char *f2) {
  int i;
  if (strlen(f1) != strlen(f2))
    return -1;
  else {
    i = strlen(f1);
    while (--i >= 0)
      if (tolower(f1[i]) != tolower(f2[i]))
        return -1;
    return 0;
  }
}


x86 assembly (clang, -O0):
<Flncmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
je     115e <Flncmp+0x3e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ca <Flncmp+0xaa>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jl     11c3 <Flncmp+0xa3>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     11be <Flncmp+0x9e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ca <Flncmp+0xaa>
jmp    116a <Flncmp+0x4a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Flncmp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    $0xffffffff,%r15d
cmp    %eax,%ebp
jne    118b <Flncmp+0x6b>
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %ebx,%ebx
jle    1188 <Flncmp+0x68>
movsbl -0x1(%r12,%rbx,1),%edi
call   1040 <tolower@plt>
mov    %rax,%rbp
movsbl -0x1(%r14,%rbx,1),%edi
call   1040 <tolower@plt>
add    $0xffffffffffffffff,%rbx
cmp    %rax,%rbp
je     1160 <Flncmp+0x40>
jmp    118b <Flncmp+0x6b>
xor    %r15d,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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