#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(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, long long *);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
int main() {
  setbuf(stdout, NULL);
  long long n, i;
  printf("checkpoint1\n");
  scanf("%lld", &n);
  char *arr = malloc(sizeof(char) * n);
  for (i = 0; i < n; i++) {
    arr[i] = 'a';
  }
  free(arr);
  printf("checkpoint2");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <setbuf@plt>
lea    0xe88(%rip),%rdi
call   1050 <printf@plt>
lea    0xe89(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x10(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    11d3 <main+0x83>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x61,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11a8 <main+0x58>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
lea    0xe2f(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1050 <setbuf@plt>
lea    0xe86(%rip),%rdi
call   1040 <puts@plt>
lea    0xe69(%rip),%rdi
mov    %rsp,%rsi
call   1090 <scanf@plt>
mov    (%rsp),%rbx
mov    %ebx,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
test   %rbx,%rbx
jle    11c2 <main+0x52>
mov    %r14,%rdi
mov    $0x61,%esi
mov    %rbx,%rdx
call   1070 <memset@plt>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xe34(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [13 x i8] c"checkpoint1\0A\00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [12 x i8] c"checkpoint2\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i8*
store i32 0, i32* %1
%5 = load i32, i32* @stdout
%6 = call i32 @setbuf(i32 %5, i32* null)
%7 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%9 = load i64, i64* %2
%10 = mul i64 1, %9
%11 = trunc i64 %10 to i32
%12 = call i8* @malloc(i32 %11)
store i8* %12, i8** %4
store i64 0, i64* %3
br label %13
13: ; preds = %21, %0
%14 = load i64, i64* %3
%15 = load i64, i64* %2
%16 = icmp slt i64 %14, %15
br i1 %16, label %17, label %24
17: ; preds = %13
%18 = load i8*, i8** %4
%19 = load i64, i64* %3
%20 = getelementptr inbounds i8, i8* %18, i64 %19
store i8 97, i8* %20
br label %21
21: ; preds = %17
%22 = load i64, i64* %3
%23 = add nsw i64 %22, 1
store i64 %23, i64* %3
br label %13
24: ; preds = %13
%25 = load i8*, i8** %4
%26 = call i32 @free(i8* %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [12 x i8] c"checkpoint2\00"
@str = [12 x i8] c"checkpoint1\00"
define i32 @main() {
%1 = alloca i64
%2 = load i32, i32* @stdout
%3 = tail call i32 @setbuf(i32 %2, i32* null)
%4 = bitcast i64* %1 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%7 = load i64, i64* %1
%8 = trunc i64 %7 to i32
%9 = call i8* @malloc(i32 %8)
%10 = icmp sgt i64 %7, 0
br i1 %10, label %11, label %12
11: ; preds = %0
br label %12
12: ; preds = %11, %0
%13 = call i32 @free(i8* %9)
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}