#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 *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
void main(void) {
  int arr[] = {-1, -12, -123, -1234};
  int *p = (int *)&arr, *r;
  int n, m;
  for (n = 0; n < 4; p++, n++)
    printf("%d ", *p);
  printf("\n");
  p = 0;
  p = (int *)malloc(4 * sizeof(int));
  for (n = 0, m = -1; n < 4; n++, m = (m * 10 - (n + 1)))
    p[n] = m;
  r = (int *)p;
  for (n = 0; n < 4; p++, n++)
    printf("%d ", *p);
  free(r);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xec1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    1195 <main+0x65>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115d <main+0x2d>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x18(%rbp)
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0xffffffff,-0x28(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    11fc <main+0xcc>
mov    -0x28(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
imul   $0xa,-0x28(%rbp),%eax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,-0x28(%rbp)
jmp    11c7 <main+0x97>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    1243 <main+0x113>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    120b <main+0xdb>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%r14
mov    %r14,%rdi
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xfffffff4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xffffff85,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xfffffb2e,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
movaps 0xe5b(%rip),%xmm0
movups %xmm0,(%rax)
mov    %r14,%rdi
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

LLVM IR (-O0):
@__const.main.arr = [4 x i32] [i32 -1, i32 -12, i32 -123, i32 -1234]
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @main() {
%1 = alloca [4 x i32]
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = bitcast [4 x i32]* %1 to i8*
%7 = bitcast [4 x i32]* %1 to i32*
store i32* %7, i32** %2
store i32 0, i32* %4
br label %8
8: ; preds = %15, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = load i32*, i32** %2
%13 = load i32, i32* %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %11
%16 = load i32*, i32** %2
%17 = getelementptr inbounds i32, i32* %16, i32 1
store i32* %17, i32** %2
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %8
20: ; preds = %8
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* null, i32** %2
%22 = call i64 @malloc(i32 16)
%23 = inttoptr i64 %22 to i32*
store i32* %23, i32** %2
store i32 0, i32* %4
store i32 -1, i32* %5
br label %24
24: ; preds = %33, %20
%25 = load i32, i32* %4
%26 = icmp slt i32 %25, 4
br i1 %26, label %27, label %41
27: ; preds = %24
%28 = load i32, i32* %5
%29 = load i32*, i32** %2
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
store i32 %28, i32* %32
br label %33
33: ; preds = %27
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
%36 = load i32, i32* %5
%37 = mul nsw i32 %36, 10
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
%40 = sub nsw i32 %37, %39
store i32 %40, i32* %5
br label %24
41: ; preds = %24
%42 = load i32*, i32** %2
store i32* %42, i32** %3
store i32 0, i32* %4
br label %43
43: ; preds = %50, %41
%44 = load i32, i32* %4
%45 = icmp slt i32 %44, 4
br i1 %45, label %46, label %55
46: ; preds = %43
%47 = load i32*, i32** %2
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %46
%51 = load i32*, i32** %2
%52 = getelementptr inbounds i32, i32* %51, i32 1
store i32* %52, i32** %2
%53 = load i32, i32* %4
%54 = add nsw i32 %53, 1
store i32 %54, i32* %4
br label %43
55: ; preds = %43
%56 = load i32*, i32** %3
%57 = call i32 @free(i32* %56)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 -1)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 -12)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 -123)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 -1234)
%5 = tail call i32 @putchar(i32 10)
%6 = tail call i64 @malloc(i32 16)
%7 = inttoptr i64 %6 to i32*
%8 = getelementptr inbounds i32, i32* %7, i64 1
%9 = inttoptr i64 %6 to <4 x i32>*
store <4 x i32> <i32 -1, i32 -12, i32 -123, i32 -1234>, <4 x i32>* %9
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 -1)
%11 = load i32, i32* %8
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds i32, i32* %7, i64 2
%14 = load i32, i32* %13
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds i32, i32* %7, i64 3
%17 = load i32, i32* %16
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = tail call i32 @free(i32* %7)
ret void
}