#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*/ STDOUT_FILENO;
void *malloc(int);
int /*<<< orphan*/ memset(void *, unsigned char, int);
int /*<<< orphan*/ write(int /*<<< orphan*/, void *, int);
int main(int argc, char **argv) {
  void *block = malloc(512);
  unsigned char filler = 0;
  int i;
  for (i = 0; i < ((32 * 1024 * 1024) / 512); i++) {
    memset(block, filler, 512);
    write(STDOUT_FILENO, block, 512);
    filler += 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x200,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movb   $0x0,-0x19(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x10000,-0x20(%rbp)
jge    11af <main+0x7f>
mov    -0x18(%rbp),%rdi
mov    -0x19(%rbp),%al
movzbl %al,%esi
mov    $0x200,%edx
call   1040 <memset@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    $0x200,%edx
call   1030 <write@plt>
movzbl -0x19(%rbp),%eax
add    $0x1,%eax
mov    %al,-0x19(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115f <main+0x2f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x200,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
mov    0x2ea6(%rip),%r14
nopw   0x0(%rax,%rax,1)
movzbl %bpl,%esi
mov    %rbx,%rdi
mov    $0x200,%edx
call   1040 <memset@plt>
mov    (%r14),%edi
mov    %rbx,%rsi
mov    $0x200,%edx
call   1030 <write@plt>
add    $0x1,%ebp
cmp    $0x10000,%ebp
jne    1150 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i8* @malloc(i32 512)
store i8* %9, i8** %6
store i8 0, i8* %7
store i32 0, i32* %8
br label %10
10: ; preds = %24, %2
%11 = load i32, i32* %8
%12 = icmp slt i32 %11, 65536
br i1 %12, label %13, label %27
13: ; preds = %10
%14 = load i8*, i8** %6
%15 = load i8, i8* %7
%16 = call i32 @memset(i8* %14, i8 zeroext %15, i32 512)
%17 = load i32, i32* @STDOUT_FILENO
%18 = load i8*, i8** %6
%19 = call i32 @write(i32 %17, i8* %18, i32 512)
%20 = load i8, i8* %7
%21 = zext i8 %20 to i32
%22 = add nsw i32 %21, 1
%23 = trunc i32 %22 to i8
store i8 %23, i8* %7
br label %24
24: ; preds = %13
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %10
27: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(512) i8* @malloc(i32 512)
br label %4
4: ; preds = %2, %4
%5 = phi i32 [ 0, %2 ], [ %10, %4 ]
%6 = trunc i32 %5 to i8
%7 = tail call i32 @memset(i8* %3, i8 zeroext %6, i32 512)
%8 = load i32, i32* @STDOUT_FILENO
%9 = tail call i32 @write(i32 %8, i8* %3, i32 512)
%10 = add nuw nsw i32 %5, 1
%11 = icmp eq i32 %10, 65536
br i1 %11, label %12, label %4
12: ; preds = %4
ret i32 0
}