#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__ memcmp(char const *, char const *, int);
int read_int32(char const *);
int lstring_eq(const char *string1, const char *string2) {
  int len;
  len = read_int32(string1);
  if (read_int32(string2) != len) {
    return 0;
  }
  string1 += 4;
  string2 += 4;
  return memcmp(string1, string2, len) == 0;
}


x86 assembly (clang, -O0):
<lstring_eq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <read_int32@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <read_int32@plt>
cmp    -0x1c(%rbp),%eax
je     115a <lstring_eq+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    1191 <lstring_eq+0x71>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lstring_eq>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <read_int32@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <read_int32@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ebp,%ecx
jne    1161 <lstring_eq+0x41>
add    $0x4,%rbx
add    $0x4,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <memcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @lstring_eq(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 @read_int32(i8* %7)
store i32 %8, i32* %6
%9 = load i8*, i8** %5
%10 = call i32 @read_int32(i8* %9)
%11 = load i32, i32* %6
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 0, i32* %3
br label %25
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 4
store i8* %16, i8** %4
%17 = load i8*, i8** %5
%18 = getelementptr inbounds i8, i8* %17, i64 4
store i8* %18, i8** %5
%19 = load i8*, i8** %4
%20 = load i8*, i8** %5
%21 = load i32, i32* %6
%22 = call i64 @memcmp(i8* %19, i8* %20, i32 %21)
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
store i32 %24, i32* %3
br label %25
25: ; preds = %14, %13
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
define i32 @lstring_eq(i8* %0, i8* %1) {
%3 = tail call i32 @read_int32(i8* %0)
%4 = tail call i32 @read_int32(i8* %1)
%5 = icmp eq i32 %4, %3
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %0, i64 4
%8 = getelementptr inbounds i8, i8* %1, i64 4
%9 = tail call i64 @memcmp(i8* %7, i8* %8, i32 %3)
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %2, %6
%13 = phi i32 [ %11, %6 ], [ 0, %2 ]
ret i32 %13
}