#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 */
scalar_t__ Calloc(int, int);
int /*<<< orphan*/ Free(int *);
scalar_t__ Malloc(int);
int main(int argc, char *argv[]) {
  int r = 36;
  int *p = (int *)Malloc(sizeof(int));
  *p = 36;
  if (r != *p)
    return 1;
  Free(p);
  int *arr = (int *)Calloc(10, sizeof(int));
  int i;
  for (i = 0; i < 10; i++)
    arr[i] = i + 1;
  return ((arr[0] == 1) && (arr[9] == 10)) ? 0 : 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x24,-0x14(%rbp)
mov    $0x4,%edi
call   1030 <Malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x24,(%rax)
mov    -0x14(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
je     1180 <main+0x50>
movl   $0x1,-0x4(%rbp)
jmp    11ff <main+0xcf>
mov    -0x20(%rbp),%rdi
call   1040 <Free@plt>
mov    $0xa,%edi
mov    $0x4,%esi
call   1050 <Calloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0xa,-0x2c(%rbp)
jge    11cc <main+0x9c>
mov    -0x2c(%rbp),%edx
add    $0x1,%edx
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11a3 <main+0x73>
mov    -0x28(%rbp),%rcx
xor    %eax,%eax
cmpl   $0x1,(%rcx)
mov    %al,-0x2d(%rbp)
jne    11ec <main+0xbc>
mov    -0x28(%rbp),%rax
cmpl   $0xa,0x24(%rax)
sete   %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%dl
mov    $0x1,%eax
xor    %ecx,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x4,%edi
call   1030 <Malloc@plt>
movl   $0x24,(%rax)
mov    %rax,%rdi
call   1040 <Free@plt>
mov    $0xa,%edi
mov    $0x4,%esi
call   1050 <Calloc@plt>
movaps 0xea1(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xea7(%rip),%xmm0
movups %xmm0,0x10(%rax)
movabs $0xa00000009,%rcx
mov    %rcx,0x20(%rax)
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 36, i32* %6
%10 = call i64 @Malloc(i32 4)
%11 = inttoptr i64 %10 to i32*
store i32* %11, i32** %7
%12 = load i32*, i32** %7
store i32 36, i32* %12
%13 = load i32, i32* %6
%14 = load i32*, i32** %7
%15 = load i32, i32* %14
%16 = icmp ne i32 %13, %15
br i1 %16, label %17, label %18
17: ; preds = %2
store i32 1, i32* %3
br label %50
18: ; preds = %2
%19 = load i32*, i32** %7
%20 = call i32 @Free(i32* %19)
%21 = call i64 @Calloc(i32 10, i32 4)
%22 = inttoptr i64 %21 to i32*
store i32* %22, i32** %8
store i32 0, i32* %9
br label %23
23: ; preds = %33, %18
%24 = load i32, i32* %9
%25 = icmp slt i32 %24, 10
br i1 %25, label %26, label %36
26: ; preds = %23
%27 = load i32, i32* %9
%28 = add nsw i32 %27, 1
%29 = load i32*, i32** %8
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
store i32 %28, i32* %32
br label %33
33: ; preds = %26
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
br label %23
36: ; preds = %23
%37 = load i32*, i32** %8
%38 = getelementptr inbounds i32, i32* %37, i64 0
%39 = load i32, i32* %38
%40 = icmp eq i32 %39, 1
br i1 %40, label %41, label %46
41: ; preds = %36
%42 = load i32*, i32** %8
%43 = getelementptr inbounds i32, i32* %42, i64 9
%44 = load i32, i32* %43
%45 = icmp eq i32 %44, 10
br label %46
46: ; preds = %41, %36
%47 = phi i1 [ false, %36 ], [ %45, %41 ]
%48 = zext i1 %47 to i64
%49 = select i1 %47, i32 0, i32 1
store i32 %49, i32* %3
br label %50
50: ; preds = %46, %17
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @Malloc(i32 4)
%4 = inttoptr i64 %3 to i32*
store i32 36, i32* %4
%5 = tail call i32 @Free(i32* %4)
%6 = tail call i64 @Calloc(i32 10, i32 4)
%7 = inttoptr i64 %6 to i32*
%8 = inttoptr i64 %6 to <4 x i32>*
store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %8
%9 = getelementptr inbounds i32, i32* %7, i64 4
%10 = bitcast i32* %9 to <4 x i32>*
store <4 x i32> <i32 5, i32 6, i32 7, i32 8>, <4 x i32>* %10
%11 = getelementptr inbounds i32, i32* %7, i64 8
store i32 9, i32* %11
%12 = getelementptr inbounds i32, i32* %7, i64 9
store i32 10, i32* %12
ret i32 0
}