#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int *malloc(int);
int /*<<< orphan*/ printArray(int *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int *a = malloc(sizeof(int) * 3);
  a[0] = 42;
  a[1] = 43;
  a[2] = 44;
  fprintf(stderr, "Sulong: a[0] = %i\n", a[0]);
  fprintf(stderr, "Sulong: a[1] = %i\n", a[1]);
  fprintf(stderr, "Sulong: a[2] = %i\n", a[2]);
  fprintf(stderr, "Sulong: a = %p\n", a);
  printArray(a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x2a,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x2b,0x4(%rax)
mov    -0x18(%rbp),%rax
movl   $0x2c,0x8(%rax)
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe6b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edx
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe58(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <printArray@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   1040 <malloc@plt>
mov    %rax,%rbx
movabs $0x2b0000002a,%rax
mov    %rax,(%rbx)
movl   $0x2c,0x8(%rbx)
mov    0x2e84(%rip),%r14
mov    (%r14),%edi
lea    0xe9a(%rip),%rsi
mov    $0x2a,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
lea    0xe97(%rip),%rsi
mov    $0x2b,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
lea    0xe94(%rip),%rsi
mov    $0x2c,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
lea    0xe91(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <printArray@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"Sulong: a[0] = %i\0A\00"
@.str.1 = [19 x i8] c"Sulong: a[1] = %i\0A\00"
@.str.2 = [19 x i8] c"Sulong: a[2] = %i\0A\00"
@.str.3 = [16 x i8] c"Sulong: a = %p\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32* @malloc(i32 12)
store i32* %7, i32** %6
%8 = load i32*, i32** %6
%9 = getelementptr inbounds i32, i32* %8, i64 0
store i32 42, i32* %9
%10 = load i32*, i32** %6
%11 = getelementptr inbounds i32, i32* %10, i64 1
store i32 43, i32* %11
%12 = load i32*, i32** %6
%13 = getelementptr inbounds i32, i32* %12, i64 2
store i32 44, i32* %13
%14 = load i32, i32* @stderr
%15 = load i32*, i32** %6
%16 = getelementptr inbounds i32, i32* %15, i64 0
%17 = load i32, i32* %16
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* @stderr
%20 = load i32*, i32** %6
%21 = getelementptr inbounds i32, i32* %20, i64 1
%22 = load i32, i32* %21
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i32, i32* @stderr
%25 = load i32*, i32** %6
%26 = getelementptr inbounds i32, i32* %25, i64 2
%27 = load i32, i32* %26
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = load i32, i32* @stderr
%30 = load i32*, i32** %6
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32* %30)
%32 = load i32*, i32** %6
%33 = call i32 @printArray(i32* %32)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [19 x i8] c"Sulong: a[0] = %i\0A\00"
@.str.1 = [19 x i8] c"Sulong: a[1] = %i\0A\00"
@.str.2 = [19 x i8] c"Sulong: a[2] = %i\0A\00"
@.str.3 = [16 x i8] c"Sulong: a = %p\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @malloc(i32 12)
store i32 42, i32* %3
%4 = getelementptr inbounds i32, i32* %3, i64 1
store i32 43, i32* %4
%5 = getelementptr inbounds i32, i32* %3, i64 2
store i32 44, i32* %5
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 42)
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 43)
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 44)
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%14 = tail call i32 @printArray(i32* %3)
ret i32 0
}