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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, size_t);
size_t random();
int /*<<< orphan*/ seed(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  seed(time(NULL));
  int i;
  uint32_t v;
  uint32_t col[256];
  for (i = 0; i < 256; i++) {
    col[i] = 0;
  }
  for (i = 0; i < 1000000; i++) {
    v = random();
    col[v]++;
  }
  FILE *fw = fopen("output.dat", "w");
  for (i = 0; i < 256; i++) {
    fprintf(fw, "%d %u\n", i, col[i]);
  }
  fclose(fw);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <seed@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    11bb <main+0x5b>
movslq -0x14(%rbp),%rax
movq   $0x0,-0x820(%rbp,%rax,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1190 <main+0x30>
movl   $0x0,-0x14(%rbp)
cmpl   $0xf4240,-0x14(%rbp)
jge    1200 <main+0xa0>
mov    $0x0,%al
call   1070 <random@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x820(%rbp,%rax,8),%rcx
ff
add    $0x1,%rcx
mov    %rcx,-0x820(%rbp,%rax,8)
ff
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c2 <main+0x62>
lea    0xdf9(%rip),%rdi
lea    0xdfd(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x828(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    125e <main+0xfe>
mov    -0x828(%rbp),%rdi
mov    -0x14(%rbp),%edx
movslq -0x14(%rbp),%rax
mov    -0x820(%rbp,%rax,8),%rcx
ff
lea    0xdc2(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1221 <main+0xc1>
mov    -0x828(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x800,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1040 <seed@plt>
mov    %rsp,%rdi
mov    $0x800,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    $0xf4240,%ebx
xchg   %ax,%ax
xor    %eax,%eax
call   1080 <random@plt>
addq   $0x1,(%rsp,%rax,8)
add    $0xffffffff,%ebx
jne    11a0 <main+0x30>
lea    0xe48(%rip),%rdi
lea    0xe4c(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
xor    %ebx,%ebx
lea    0xe3d(%rip),%r15
mov    (%rsp,%rbx,8),%rcx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1060 <fprintf@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    11d0 <main+0x60>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"output.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [7 x i8] c"%d %u\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca [256 x i64]
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @time(i32* null)
%11 = call i32 @seed(i32 %10)
store i32 0, i32* %6
br label %12
12: ; preds = %19, %2
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 256
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [256 x i64], [256 x i64]* %8, i64 0, i64 %17
store i64 0, i64* %18
br label %19
19: ; preds = %15
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
br label %12
22: ; preds = %12
store i32 0, i32* %6
br label %23
23: ; preds = %32, %22
%24 = load i32, i32* %6
%25 = icmp slt i32 %24, 1000000
br i1 %25, label %26, label %35
26: ; preds = %23
%27 = call i64 (...) @random()
store i64 %27, i64* %7
%28 = load i64, i64* %7
%29 = getelementptr inbounds [256 x i64], [256 x i64]* %8, i64 0, i64 %28
%30 = load i64, i64* %29
%31 = add i64 %30, 1
store i64 %31, i64* %29
br label %32
32: ; preds = %26
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %23
35: ; preds = %23
%36 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %36, i32** %9
store i32 0, i32* %6
br label %37
37: ; preds = %48, %35
%38 = load i32, i32* %6
%39 = icmp slt i32 %38, 256
br i1 %39, label %40, label %51
40: ; preds = %37
%41 = load i32*, i32** %9
%42 = load i32, i32* %6
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [256 x i64], [256 x i64]* %8, i64 0, i64 %44
%46 = load i64, i64* %45
%47 = call i32 @fprintf(i32* %41, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %42, i64 %46)
br label %48
48: ; preds = %40
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %37
51: ; preds = %37
%52 = load i32*, i32** %9
%53 = call i32 @fclose(i32* %52)
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@.str = [11 x i8] c"output.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [7 x i8] c"%d %u\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i64]
%4 = bitcast [256 x i64]* %3 to i8*
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @seed(i32 %5)
br label %7
7: ; preds = %2, %7
%8 = phi i32 [ %13, %7 ], [ 0, %2 ]
%9 = tail call i64 (...) @random()
%10 = getelementptr inbounds [256 x i64], [256 x i64]* %3, i64 0, i64 %9
%11 = load i64, i64* %10
%12 = add i64 %11, 1
store i64 %12, i64* %10
%13 = add nuw nsw i32 %8, 1
%14 = icmp eq i32 %13, 1000000
br i1 %14, label %15, label %7
15: ; preds = %7
%16 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 0, %15 ], [ %23, %17 ]
%19 = getelementptr inbounds [256 x i64], [256 x i64]* %3, i64 0, i64 %18
%20 = load i64, i64* %19
%21 = trunc i64 %18 to i32
%22 = tail call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %21, i64 %20)
%23 = add nuw nsw i64 %18, 1
%24 = icmp eq i64 %23, 256
br i1 %24, label %25, label %17
25: ; preds = %17
%26 = tail call i32 @fclose(i32* %16)
ret i32 0
}