#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 */
typedef int uint64_t;
typedef int /*<<< orphan*/ uint32_t;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ fwrite(void *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ pcg32();
int /*<<< orphan*/ pcg32_seed(int);
int /*<<< orphan*/ stdout;
int main() {
  uint64_t seedvalue = 12345678;
  pcg32_seed(seedvalue);
  uint32_t buffer[512];
  while (1) {
    for (int k = 0; k < 512; k++)
      buffer[k] = pcg32();
    fwrite((void *)buffer, sizeof(buffer), 1, stdout);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xbc614e,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <pcg32_seed@plt>
movl   $0x0,-0x814(%rbp)
cmpl   $0x200,-0x814(%rbp)
jge    1196 <main+0x66>
mov    $0x0,%al
call   1030 <pcg32@plt>
mov    %eax,%ecx
movslq -0x814(%rbp),%rax
mov    %ecx,-0x810(%rbp,%rax,4)
mov    -0x814(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x814(%rbp)
jmp    115b <main+0x2b>
lea    -0x810(%rbp),%rdi
mov    0x2e3c(%rip),%rax
mov    (%rax),%ecx
mov    $0x800,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
jmp    1151 <main+0x21>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    $0xbc614e,%edi
call   1040 <pcg32_seed@plt>
mov    0x2e93(%rip),%r14
mov    %rsp,%r15
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <pcg32@plt>
mov    %eax,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x200,%rbx
jne    1152 <main+0x22>
mov    (%r14),%ecx
mov    %r15,%rdi
mov    $0x800,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
jmp    1150 <main+0x20>

LLVM IR (-O0):
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [512 x i32]
%4 = alloca i32
store i32 0, i32* %1
store i32 12345678, i32* %2
%5 = load i32, i32* %2
%6 = call i32 @pcg32_seed(i32 %5)
br label %7
7: ; preds = %0, %19
store i32 0, i32* %4
br label %8
8: ; preds = %16, %7
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 512
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = call i32 (...) @pcg32()
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [512 x i32], [512 x i32]* %3, i64 0, i64 %14
store i32 %12, i32* %15
br label %16
16: ; preds = %11
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %8
19: ; preds = %8
%20 = getelementptr inbounds [512 x i32], [512 x i32]* %3, i64 0, i64 0
%21 = bitcast i32* %20 to i8*
%22 = load i32, i32* @stdout
%23 = call i32 @fwrite(i8* %21, i32 2048, i32 1, i32 %22)
br label %7
}

LLVM IR (-O2):
@stdout = global i32 0
define i32 @main() {
%1 = alloca [512 x i32]
%2 = tail call i32 @pcg32_seed(i32 12345678)
%3 = bitcast [512 x i32]* %1 to i8*
br label %7
4: ; preds = %7
%5 = load i32, i32* @stdout
%6 = call i32 @fwrite(i8* %3, i32 2048, i32 1, i32 %5)
br label %13
7: ; preds = %13, %0
%8 = phi i64 [ 0, %0 ], [ %14, %13 ]
%9 = call i32 (...) @pcg32()
%10 = getelementptr inbounds [512 x i32], [512 x i32]* %1, i64 0, i64 %8
store i32 %9, i32* %10
%11 = add nuw nsw i64 %8, 1
%12 = icmp eq i64 %11, 512
br i1 %12, label %4, label %13
13: ; preds = %7, %4
%14 = phi i64 [ %11, %7 ], [ 0, %4 ]
br label %7
}