#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 /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int strcmp(char *, char *);
int strlen(char const *);
char tolower(char const);
int strcmpl(const char *s1, const char *s2) {
  int iret;
  size_t l, len1, len2;
  char *l1, *l2;
  len1 = strlen(s1) + 1;
  len2 = strlen(s2) + 1;
  l1 = (char *)malloc(sizeof(char) * len1);
  l2 = (char *)malloc(sizeof(char) * len2);
  for (l = 0; l < len1; l++)
    *(l1 + l) = tolower(*(s1 + l));
  for (l = 0; l < len2; l++)
    *(l2 + l) = tolower(*(s2 + l));
  iret = strcmp(l1, l2);
  free(l1);
  free(l2);
  return (iret);
}


x86 assembly (clang, -O0):
<strcmpl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11ef <strcmpl+0x9f>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <tolower@plt>
mov    %al,%dl
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11b2 <strcmpl+0x62>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    1234 <strcmpl+0xe4>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <tolower@plt>
mov    %al,%dl
mov    -0x40(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11f7 <strcmpl+0xa7>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1050 <strcmp@plt>
mov    %eax,-0x14(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmpl>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r12
call   1040 <strlen@plt>
mov    %eax,%r13d
lea    0x1(%r13),%ebx
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
add    $0x1,%ebp
mov    %ebx,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,0x4(%rsp)
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
inc    %r13d
je     11b7 <strcmpl+0x67>
movslq %r13d,%rbp
xor    %r13d,%r13d
nopl   (%rax)
movsbl (%r12,%r13,1),%edi
call   1060 <tolower@plt>
mov    %al,(%rbx,%r13,1)
add    $0x1,%r13
cmp    %r13,%rbp
jne    11a0 <strcmpl+0x50>
mov    %rbx,%r12
mov    0x4(%rsp),%eax
test   %eax,%eax
je     11e7 <strcmpl+0x97>
movslq %eax,%rbp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%edi
call   1060 <tolower@plt>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11d0 <strcmpl+0x80>
mov    %r12,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @strcmpl(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = add nsw i32 %12, 1
%14 = sext i32 %13 to i64
store i64 %14, i64* %7
%15 = load i8*, i8** %4
%16 = call i32 @strlen(i8* %15)
%17 = add nsw i32 %16, 1
%18 = sext i32 %17 to i64
store i64 %18, i64* %8
%19 = load i64, i64* %7
%20 = mul i64 1, %19
%21 = trunc i64 %20 to i32
%22 = call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %9
%24 = load i64, i64* %8
%25 = mul i64 1, %24
%26 = trunc i64 %25 to i32
%27 = call i64 @malloc(i32 %26)
%28 = inttoptr i64 %27 to i8*
store i8* %28, i8** %10
store i64 0, i64* %6
br label %29
29: ; preds = %42, %2
%30 = load i64, i64* %6
%31 = load i64, i64* %7
%32 = icmp ult i64 %30, %31
br i1 %32, label %33, label %45
33: ; preds = %29
%34 = load i8*, i8** %3
%35 = load i64, i64* %6
%36 = getelementptr inbounds i8, i8* %34, i64 %35
%37 = load i8, i8* %36
%38 = call signext i8 @tolower(i8 signext %37)
%39 = load i8*, i8** %9
%40 = load i64, i64* %6
%41 = getelementptr inbounds i8, i8* %39, i64 %40
store i8 %38, i8* %41
br label %42
42: ; preds = %33
%43 = load i64, i64* %6
%44 = add i64 %43, 1
store i64 %44, i64* %6
br label %29
45: ; preds = %29
store i64 0, i64* %6
br label %46
46: ; preds = %59, %45
%47 = load i64, i64* %6
%48 = load i64, i64* %8
%49 = icmp ult i64 %47, %48
br i1 %49, label %50, label %62
50: ; preds = %46
%51 = load i8*, i8** %4
%52 = load i64, i64* %6
%53 = getelementptr inbounds i8, i8* %51, i64 %52
%54 = load i8, i8* %53
%55 = call signext i8 @tolower(i8 signext %54)
%56 = load i8*, i8** %10
%57 = load i64, i64* %6
%58 = getelementptr inbounds i8, i8* %56, i64 %57
store i8 %55, i8* %58
br label %59
59: ; preds = %50
%60 = load i64, i64* %6
%61 = add i64 %60, 1
store i64 %61, i64* %6
br label %46
62: ; preds = %46
%63 = load i8*, i8** %9
%64 = load i8*, i8** %10
%65 = call i32 @strcmp(i8* %63, i8* %64)
store i32 %65, i32* %5
%66 = load i8*, i8** %9
%67 = call i32 @free(i8* %66)
%68 = load i8*, i8** %10
%69 = call i32 @free(i8* %68)
%70 = load i32, i32* %5
ret i32 %70
}

LLVM IR (-O2):
define i32 @strcmpl(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = add nsw i32 %3, 1
%5 = tail call i32 @strlen(i8* %1)
%6 = add nsw i32 %5, 1
%7 = tail call i64 @malloc(i32 %4)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i64 @malloc(i32 %6)
%10 = inttoptr i64 %9 to i8*
%11 = icmp eq i32 %4, 0
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = sext i32 %4 to i64
br label %18
14: ; preds = %18, %2
%15 = icmp eq i32 %6, 0
br i1 %15, label %34, label %16
16: ; preds = %14
%17 = sext i32 %6 to i64
br label %26
18: ; preds = %12, %18
%19 = phi i64 [ %24, %18 ], [ 0, %12 ]
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = load i8, i8* %20
%22 = tail call signext i8 @tolower(i8 signext %21)
%23 = getelementptr inbounds i8, i8* %8, i64 %19
store i8 %22, i8* %23
%24 = add nuw i64 %19, 1
%25 = icmp eq i64 %24, %13
br i1 %25, label %14, label %18
26: ; preds = %16, %26
%27 = phi i64 [ %32, %26 ], [ 0, %16 ]
%28 = getelementptr inbounds i8, i8* %1, i64 %27
%29 = load i8, i8* %28
%30 = tail call signext i8 @tolower(i8 signext %29)
%31 = getelementptr inbounds i8, i8* %10, i64 %27
store i8 %30, i8* %31
%32 = add nuw i64 %27, 1
%33 = icmp eq i64 %32, %17
br i1 %33, label %34, label %26
34: ; preds = %26, %14
%35 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(1) %10)
%36 = tail call i32 @free(i8* %8)
%37 = tail call i32 @free(i8* %10)
ret i32 %35
}