#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(int *);
int /*<<< orphan*/ hp_free(int *);
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");
  free(t);
  hp_free(st);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xc,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0xc,%edi
call   1070 <hp_malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11cc <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    1192 <main+0x32>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%eax
jne    11f8 <main+0x98>
lea    0xe12(%rip),%rdi
call   1040 <printf@plt>
jmp    1204 <main+0xa4>
lea    0xe09(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1080 <hp_free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0xc,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0xc,%edi
call   1070 <hp_malloc@plt>
mov    %rax,%rbx
movl   $0x1,(%r14)
movl   $0x1,(%rax)
movl   $0x2,0x4(%r14)
movl   $0x2,0x4(%rax)
movl   $0x3,0x8(%r14)
movl   $0x3,0x8(%rax)
mov    %r14,%rdi
mov    %rax,%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %eax,%eax
lea    0xe3e(%rip),%rax
lea    0xe3e(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1080 <hp_free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
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
%36 = load i32*, i32** %3
%37 = call i32 @free(i32* %36)
%38 = load i32*, i32** %4
%39 = call i32 @hp_free(i32* %38)
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)
%11 = tail call i32 @free(i32* %1)
%12 = tail call i32 @hp_free(i32* %2)
ret i32 0
}