#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*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
int main() {
  int *a;
  int x;
  a = (int *)malloc(sizeof(int) * 10);
  if (a == NULL) {
    fprintf(stderr, "Memory allocation error\n");
    exit(1);
  }
  for (x = 0; x < 10; x++) {
    *a = x * 20;
    a++;
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1177 <main+0x47>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11ac <main+0x7c>
imul   $0x14,-0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117e <main+0x4e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x28,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     1167 <main+0x37>
movaps 0xeb9(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xebf(%rip),%xmm0
movups %xmm0,0x10(%rax)
movabs $0xb4000000a0,%rcx
mov    %rcx,0x20(%rax)
xor    %eax,%eax
pop    %rcx
ret
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xea9(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"Memory allocation error\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i64 @malloc(i32 40)
%5 = inttoptr i64 %4 to i32*
store i32* %5, i32** %2
%6 = load i32*, i32** %2
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
store i32 0, i32* %3
br label %13
13: ; preds = %22, %12
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 10
br i1 %15, label %16, label %25
16: ; preds = %13
%17 = load i32, i32* %3
%18 = mul nsw i32 %17, 20
%19 = load i32*, i32** %2
store i32 %18, i32* %19
%20 = load i32*, i32** %2
%21 = getelementptr inbounds i32, i32* %20, i32 1
store i32* %21, i32** %2
br label %22
22: ; preds = %16
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %13
25: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Memory allocation error\0A\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 40)
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = inttoptr i64 %1 to i32*
%9 = inttoptr i64 %1 to <4 x i32>*
store <4 x i32> <i32 0, i32 20, i32 40, i32 60>, <4 x i32>* %9
%10 = getelementptr inbounds i32, i32* %8, i64 4
%11 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> <i32 80, i32 100, i32 120, i32 140>, <4 x i32>* %11
%12 = getelementptr inbounds i32, i32* %8, i64 8
store i32 160, i32* %12
%13 = getelementptr inbounds i32, i32* %8, i64 9
store i32 180, i32* %13
ret i32 0
}