#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 *hp_malloc(int);
int *malloc(int);
int /*<<< orphan*/ memcmp(int *, int *, int);
int /*<<< orphan*/ printf(char *);
int main() {
  int i;
  int *t = malloc(3 * sizeof(int));
  int *st = hp_malloc(3 * sizeof(int));
  for (i = 0; i < 3; i++) {
    t[i] = i + 1;
    st[i] = i + 1;
  }
  if (!memcmp(t, st, 3))
    printf("succes\n");
  else
    printf("failure\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xc,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0xc,%edi
call   1060 <hp_malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11ac <main+0x6c>
mov    -0x8(%rbp),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%edx
add    $0x1,%edx
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1172 <main+0x32>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x3,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%eax
jne    11d8 <main+0x98>
lea    0xe32(%rip),%rdi
call   1030 <printf@plt>
jmp    11e4 <main+0xa4>
lea    0xe29(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xc,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    $0xc,%edi
call   1060 <hp_malloc@plt>
movl   $0x1,(%rbx)
movl   $0x1,(%rax)
movl   $0x2,0x4(%rbx)
movl   $0x2,0x4(%rax)
movl   $0x3,0x8(%rbx)
movl   $0x3,0x8(%rax)
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x3,%edx
call   1040 <memcmp@plt>
test   %eax,%eax
lea    0xe67(%rip),%rax
lea    0xe67(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"succes\0A\00"
@.str.1 = [9 x i8] c"failure\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
store i32 0, i32* %1
%5 = call i32* @malloc(i32 12)
store i32* %5, i32** %3
%6 = call i32* @hp_malloc(i32 12)
store i32* %6, i32** %4
store i32 0, i32* %2
br label %7
7: ; preds = %23, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = load i32, i32* %2
%12 = add nsw i32 %11, 1
%13 = load i32*, i32** %3
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
store i32 %12, i32* %16
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
%19 = load i32*, i32** %4
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
store i32 %18, i32* %22
br label %23
23: ; preds = %10
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %7
26: ; preds = %7
%27 = load i32*, i32** %3
%28 = load i32*, i32** %4
%29 = call i32 @memcmp(i32* %27, i32* %28, i32 3)
%30 = icmp ne i32 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %26
%32 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %35
33: ; preds = %26
%34 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %35
35: ; preds = %33, %31
ret i32 0
}

LLVM IR (-O2):
@str = [7 x i8] c"succes\00"
@str.2 = [8 x i8] c"failure\00"
define i32 @main() {
%1 = tail call i32* @malloc(i32 12)
%2 = tail call i32* @hp_malloc(i32 12)
store i32 1, i32* %1
store i32 1, i32* %2
%3 = getelementptr inbounds i32, i32* %1, i64 1
store i32 2, i32* %3
%4 = getelementptr inbounds i32, i32* %2, i64 1
store i32 2, i32* %4
%5 = getelementptr inbounds i32, i32* %1, i64 2
store i32 3, i32* %5
%6 = getelementptr inbounds i32, i32* %2, i64 2
store i32 3, i32* %6
%7 = tail call i32 @memcmp(i32* %1, i32* %2, i32 3)
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.2, i64 0, i64 0)
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
ret i32 0
}