#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_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ M_PERTURB;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
scalar_t__ mallopt(int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int malloc_init_value = (1 << 3) & 0xff;
  if (0 == mallopt(M_PERTURB, 0xff)) {
    perror("mallopt");
    exit(EXIT_FAILURE);
  }
  int mall_size = 1024;
  int *ptr = (int *)malloc(mall_size * sizeof(int));
  if (ptr == NULL) {
    perror("malloc");
    exit(EXIT_FAILURE);
  }
  for (int i = 0; i < mall_size; i++) {
    printf("%d", ptr[i]);
    if (i % 101 == 100) {
      printf("\n");
    }
  }
  printf("\n");
  free(ptr);
  exit(EXIT_SUCCESS);
}


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   $0x8,-0x14(%rbp)
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
mov    $0xff,%esi
call   1040 <mallopt@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11b8 <main+0x58>
lea    0xe5b(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
movl   $0x400,-0x18(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11f7 <main+0x97>
lea    0xe24(%rip),%rdi
call   1070 <perror@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1258 <main+0xf8>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
mov    $0x65,%ecx
cltd
idiv   %ecx
cmp    $0x64,%edx
jne    1245 <main+0xe5>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    124a <main+0xea>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11fe <main+0x9e>
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
mov    $0xff,%esi
call   1050 <mallopt@plt>
test   %rax,%rax
jne    1199 <main+0x29>
lea    0xe69(%rip),%rdi
jmp    11af <main+0x3f>
mov    $0x1000,%edi
call   1070 <malloc@plt>
test   %rax,%rax
jne    11c2 <main+0x52>
lea    0xe59(%rip),%rdi
call   1080 <perror@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    %rax,%r15
mov    $0x64,%bp
lea    0xe3f(%rip),%r14
xor    %ebx,%ebx
jmp    11f0 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
add    $0xffffffff,%ebp
cmp    $0x400,%rbx
je     1220 <main+0xb0>
movzwl %bx,%eax
imul   $0x1447,%eax,%eax
shr    $0x13,%eax
imul   $0x65,%eax,%r12d
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    %bp,%r12w
jne    11e0 <main+0x70>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    11e0 <main+0x70>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@M_PERTURB = global i32 0
@.str = [8 x i8] c"mallopt\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [7 x i8] c"malloc\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
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 8, i32* %6
%10 = load i32, i32* @M_PERTURB
%11 = call i64 @mallopt(i32 %10, i32 255)
%12 = icmp eq i64 0, %11
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
store i32 1024, i32* %7
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = mul i64 %19, 4
%21 = trunc i64 %20 to i32
%22 = call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i32*
store i32* %23, i32** %8
%24 = load i32*, i32** %8
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %30
26: ; preds = %17
%27 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %17
store i32 0, i32* %9
br label %31
31: ; preds = %48, %30
%32 = load i32, i32* %9
%33 = load i32, i32* %7
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %51
35: ; preds = %31
%36 = load i32*, i32** %8
%37 = load i32, i32* %9
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %9
%43 = srem i32 %42, 101
%44 = icmp eq i32 %43, 100
br i1 %44, label %45, label %47
45: ; preds = %35
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %47
47: ; preds = %45, %35
br label %48
48: ; preds = %47
%49 = load i32, i32* %9
%50 = add nsw i32 %49, 1
store i32 %50, i32* %9
br label %31
51: ; preds = %31
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%53 = load i32*, i32** %8
%54 = call i32 @free(i32* %53)
%55 = load i32, i32* @EXIT_SUCCESS
%56 = call i32 @exit(i32 %55)
unreachable
}

LLVM IR (-O2):
@M_PERTURB = global i32 0
@.str = [8 x i8] c"mallopt\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [7 x i8] c"malloc\00"
@.str.2 = [3 x i8] c"%d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @M_PERTURB
%4 = tail call i64 @mallopt(i32 %3, i32 255)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = tail call i64 @malloc(i32 4096)
%12 = inttoptr i64 %11 to i32*
%13 = icmp eq i64 %11, 0
br i1 %13, label %14, label %23
14: ; preds = %10
%15 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %33
%19 = tail call i32 @putchar(i32 10)
%20 = tail call i32 @free(i32* %12)
%21 = load i32, i32* @EXIT_SUCCESS
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %10, %33
%24 = phi i64 [ %34, %33 ], [ 0, %10 ]
%25 = getelementptr inbounds i32, i32* %12, i64 %24
%26 = load i32, i32* %25
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = trunc i64 %24 to i16
%29 = urem i16 %28, 101
%30 = icmp eq i16 %29, 100
br i1 %30, label %31, label %33
31: ; preds = %23
%32 = tail call i32 @putchar(i32 10)
br label %33
33: ; preds = %23, %31
%34 = add nuw nsw i64 %24, 1
%35 = icmp eq i64 %34, 1024
br i1 %35, label %18, label %23
}