#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 *calloc(int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(int *);
int *get_mymax();
int *malloc(int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ print_mymax();
int *realloc(int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int *p1 = calloc(sizeof(int), 100);
  if (p1 == NULL) {
    exit(0);
  }
  p1[2] = 8;
  int *p2 = realloc(p1, sizeof(int) * 200);
  memset(p2 + 100, 0, sizeof(int) * 100);
  int *set = malloc(sizeof(int) * 100000);
  int i = 0;
  scanf("%d", &i);
  int *array = malloc(sizeof(int) * i);
  free(array);
  return 0;
  int *p = get_mymax();
  *p = 300;
  print_mymax();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4,%edi
mov    $0x64,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a4 <main+0x34>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
movl   $0x8,0x8(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x320,%esi
call   1070 <realloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x190,%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
mov    $0x61a80,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xe0c(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1080 <scanf@plt>
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x4,%edi
mov    $0x64,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     11e7 <main+0x77>
movl   $0x8,0x8(%rax)
mov    %rax,%rdi
mov    $0x320,%esi
call   1070 <realloc@plt>
lea    0x190(%rax),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
mov    $0x61a80,%edi
call   1060 <malloc@plt>
movl   $0x0,0x4(%rsp)
lea    0xe3b(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rcx
ret
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
store i32 0, i32* %1
%8 = call i32* @calloc(i32 4, i32 100)
store i32* %8, i32** %2
%9 = load i32*, i32** %2
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @exit(i32 0)
unreachable
13: ; preds = %0
%14 = load i32*, i32** %2
%15 = getelementptr inbounds i32, i32* %14, i64 2
store i32 8, i32* %15
%16 = load i32*, i32** %2
%17 = call i32* @realloc(i32* %16, i32 800)
store i32* %17, i32** %3
%18 = load i32*, i32** %3
%19 = getelementptr inbounds i32, i32* %18, i64 100
%20 = call i32 @memset(i32* %19, i32 0, i32 400)
%21 = call i32* @malloc(i32 400000)
store i32* %21, i32** %4
store i32 0, i32* %5
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = mul i64 4, %24
%26 = trunc i64 %25 to i32
%27 = call i32* @malloc(i32 %26)
store i32* %27, i32** %6
%28 = load i32*, i32** %6
%29 = call i32 @free(i32* %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32* @calloc(i32 4, i32 100)
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @exit(i32 0)
unreachable
6: ; preds = %0
%7 = getelementptr inbounds i32, i32* %2, i64 2
store i32 8, i32* %7
%8 = tail call i32* @realloc(i32* %2, i32 800)
%9 = getelementptr inbounds i32, i32* %8, i64 100
%10 = tail call i32 @memset(i32* %9, i32 0, i32 400)
%11 = tail call i32* @malloc(i32 400000)
%12 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
%15 = shl i32 %14, 2
%16 = call i32* @malloc(i32 %15)
%17 = call i32 @free(i32* %16)
ret i32 0
}