#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*/ exit(int);
int /*<<< orphan*/ free(int *);
int *malloc(int const);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int main(void) {
  const int num = 50;
  int *p;
  int i;
  p = malloc(num * sizeof(int));
  if (!p) {
    printf("Allocating error!\n");
    exit(1);
  }
  for (i = 0; i < num; i++)
    p[i] = i + 1;
  for (i = 0; i < num; i++)
    printf("%d ", p[i]);
  putchar('\n');
  free(p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x32,-0x8(%rbp)
mov    $0xc8,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1197 <main+0x47>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x32,-0x14(%rbp)
jge    11c7 <main+0x77>
mov    -0x14(%rbp),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119e <main+0x4e>
movl   $0x0,-0x14(%rbp)
cmpl   $0x32,-0x14(%rbp)
jge    11ff <main+0xaf>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ce <main+0x7e>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0xc8,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     1262 <main+0x102>
mov    %rax,%r15
movaps 0xe7e(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe84(%rip),%xmm0
movups %xmm0,0x10(%rax)
movaps 0xe89(%rip),%xmm0
movups %xmm0,0x20(%rax)
movaps 0xe8e(%rip),%xmm0
movups %xmm0,0x30(%rax)
movaps 0xe93(%rip),%xmm0
movups %xmm0,0x40(%rax)
movaps 0xe98(%rip),%xmm0
movups %xmm0,0x50(%rax)
movaps 0xe9d(%rip),%xmm0
movups %xmm0,0x60(%rax)
movaps 0xea2(%rip),%xmm0
movups %xmm0,0x70(%rax)
movaps 0xea7(%rip),%xmm0
movups %xmm0,0x80(%rax)
movaps 0xea9(%rip),%xmm0
movups %xmm0,0x90(%rax)
movaps 0xeab(%rip),%xmm0
movups %xmm0,0xa0(%rax)
movaps 0xead(%rip),%xmm0
movups %xmm0,0xb0(%rax)
movabs $0x3200000031,%rax
mov    %rax,0xc0(%r15)
lea    0xe9e(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    $0x32,%rbx
jne    1230 <main+0xd0>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe5b(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"Allocating error!\0A\00"
@.str.1 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
store i32 50, i32* %2
%5 = call i32* @malloc(i32 200)
store i32* %5, i32** %3
%6 = load i32*, i32** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
store i32 0, i32* %4
br label %12
12: ; preds = %22, %11
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 50
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
%18 = load i32*, i32** %3
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
store i32 %17, i32* %21
br label %22
22: ; preds = %15
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %12
25: ; preds = %12
store i32 0, i32* %4
br label %26
26: ; preds = %36, %25
%27 = load i32, i32* %4
%28 = icmp slt i32 %27, 50
br i1 %28, label %29, label %39
29: ; preds = %26
%30 = load i32*, i32** %3
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %29
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %26
39: ; preds = %26
%40 = call i32 @putchar(i8 signext 10)
%41 = load i32*, i32** %3
%42 = call i32 @free(i32* %41)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d \00"
@str = [18 x i8] c"Allocating error!\00"
define i32 @main() {
%1 = tail call i32* @malloc(i32 200)
%2 = icmp eq i32* %1, null
br i1 %2, label %29, label %3
3: ; preds = %0
%4 = bitcast i32* %1 to <4 x i32>*
store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %4
%5 = getelementptr inbounds i32, i32* %1, i64 4
%6 = bitcast i32* %5 to <4 x i32>*
store <4 x i32> <i32 5, i32 6, i32 7, i32 8>, <4 x i32>* %6
%7 = getelementptr inbounds i32, i32* %1, i64 8
%8 = bitcast i32* %7 to <4 x i32>*
store <4 x i32> <i32 9, i32 10, i32 11, i32 12>, <4 x i32>* %8
%9 = getelementptr inbounds i32, i32* %1, i64 12
%10 = bitcast i32* %9 to <4 x i32>*
store <4 x i32> <i32 13, i32 14, i32 15, i32 16>, <4 x i32>* %10
%11 = getelementptr inbounds i32, i32* %1, i64 16
%12 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> <i32 17, i32 18, i32 19, i32 20>, <4 x i32>* %12
%13 = getelementptr inbounds i32, i32* %1, i64 20
%14 = bitcast i32* %13 to <4 x i32>*
store <4 x i32> <i32 21, i32 22, i32 23, i32 24>, <4 x i32>* %14
%15 = getelementptr inbounds i32, i32* %1, i64 24
%16 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> <i32 25, i32 26, i32 27, i32 28>, <4 x i32>* %16
%17 = getelementptr inbounds i32, i32* %1, i64 28
%18 = bitcast i32* %17 to <4 x i32>*
store <4 x i32> <i32 29, i32 30, i32 31, i32 32>, <4 x i32>* %18
%19 = getelementptr inbounds i32, i32* %1, i64 32
%20 = bitcast i32* %19 to <4 x i32>*
store <4 x i32> <i32 33, i32 34, i32 35, i32 36>, <4 x i32>* %20
%21 = getelementptr inbounds i32, i32* %1, i64 36
%22 = bitcast i32* %21 to <4 x i32>*
store <4 x i32> <i32 37, i32 38, i32 39, i32 40>, <4 x i32>* %22
%23 = getelementptr inbounds i32, i32* %1, i64 40
%24 = bitcast i32* %23 to <4 x i32>*
store <4 x i32> <i32 41, i32 42, i32 43, i32 44>, <4 x i32>* %24
%25 = getelementptr inbounds i32, i32* %1, i64 44
%26 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> <i32 45, i32 46, i32 47, i32 48>, <4 x i32>* %26
%27 = getelementptr inbounds i32, i32* %1, i64 48
store i32 49, i32* %27
%28 = getelementptr inbounds i32, i32* %1, i64 49
store i32 50, i32* %28
br label %32
29: ; preds = %0
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %3, %32
%33 = phi i64 [ %37, %32 ], [ 0, %3 ]
%34 = getelementptr inbounds i32, i32* %1, i64 %33
%35 = load i32, i32* %34
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = add nuw nsw i64 %33, 1
%38 = icmp eq i64 %37, 50
br i1 %38, label %39, label %32
39: ; preds = %32
%40 = tail call i32 @putchar(i8 signext 10)
%41 = tail call i32 @free(i32* %1)
ret i32 0
}