#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 */
struct stat {
  int st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
double RAND_MAX;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
double random();
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  struct stat stat_s;
  unsigned int n, i;
  srandom(time(NULL));
  unsigned char x;
  FILE *stream;
  if (stat(argv[1], &stat_s)) {
    perror(argv[1]);
    exit(EXIT_FAILURE);
  }
  if (!(stream = fopen(argv[2], "wb"))) {
    perror(argv[2]);
    exit(EXIT_FAILURE);
  }
  n = (stat_s.st_size >= 128 ? 0 : 128 - stat_s.st_size) +
      .01 * stat_s.st_size * random() / RAND_MAX;
  for (i = 0; i < n; i++) {
    x = random();
    if (fwrite(&x, sizeof(unsigned char), 1, stream) != 1) {
      perror(argv[2]);
      exit(EXIT_FAILURE);
    }
  }
  if (fclose(stream)) {
    perror(argv[2]);
    exit(EXIT_FAILURE);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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   1030 <srandom@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
je     11ec <main+0x5c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <perror@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe0d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    1229 <main+0x99>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <perror@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
cmpl   $0x80,-0x18(%rbp)
jl     1240 <main+0xb0>
xor    %eax,%eax
mov    %eax,-0x34(%rbp)
jmp    124b <main+0xbb>
mov    $0x80,%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  0xd9c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
xor    %eax,%eax
call   1070 <random@plt>
movsd  -0x48(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm2,%xmm1
mov    0x2d5c(%rip),%rax
movsd  (%rax),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    130c <main+0x17c>
xor    %eax,%eax
call   1070 <random@plt>
cvttsd2si %xmm0,%eax
mov    %al,-0x21(%rbp)
mov    -0x30(%rbp),%rcx
lea    -0x21(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   10b0 <fwrite@plt>
cmp    $0x1,%eax
je     12f9 <main+0x169>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <perror@plt>
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    12fe <main+0x16e>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12a7 <main+0x117>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     133a <main+0x1aa>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <perror@plt>
mov    0x2ca5(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x2c8f(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
mov    0x8(%r14),%rdi
lea    0x10(%rsp),%rsi
call   1050 <stat@plt>
test   %rax,%rax
jne    1289 <main+0xf9>
mov    0x10(%r14),%rdi
lea    0xe3a(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     128f <main+0xff>
mov    %rax,%r12
mov    0x10(%rsp),%eax
mov    $0x80,%ecx
sub    %eax,%ecx
xor    %edx,%edx
cmp    $0x7f,%eax
cmovg  %edx,%ecx
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,0x20(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xdf5(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   1070 <random@plt>
mulsd  0x18(%rsp),%xmm0
mov    0x2dc3(%rip),%rax
divsd  (%rax),%xmm0
addsd  0x20(%rsp),%xmm0
cvttsd2si %xmm0,%rbx
test   %ebx,%ebx
je     126e <main+0xde>
lea    0xf(%rsp),%r15
nopl   (%rax)
xor    %eax,%eax
call   1070 <random@plt>
cvttsd2si %xmm0,%eax
mov    %al,0xf(%rsp)
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10b0 <fwrite@plt>
cmp    $0x1,%eax
jne    128f <main+0xff>
add    $0xffffffff,%ebx
jne    1240 <main+0xb0>
mov    %r12,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
jne    128f <main+0xff>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x8(%r14),%rdi
jmp    1293 <main+0x103>
mov    0x10(%r14),%rdi
call   1090 <perror@plt>
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@EXIT_FAILURE = global i32 0
@.str = [3 x i8] c"wb\00"
@RAND_MAX = global double 0.000000e+00
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 @time(i32* null)
%12 = call i32 @srandom(i32 %11)
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @stat(i8* %15, %struct.stat* %6)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @perror(i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %29, i32** %10
%30 = icmp ne i32* %29, null
br i1 %30, label %38, label %31
31: ; preds = %25
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i32 @perror(i8* %34)
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %25
%39 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%40 = load i32, i32* %39
%41 = icmp sge i32 %40, 128
br i1 %41, label %42, label %43
42: ; preds = %38
br label %47
43: ; preds = %38
%44 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%45 = load i32, i32* %44
%46 = sub nsw i32 128, %45
br label %47
47: ; preds = %43, %42
%48 = phi i32 [ 0, %42 ], [ %46, %43 ]
%49 = sitofp i32 %48 to double
%50 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%51 = load i32, i32* %50
%52 = sitofp i32 %51 to double
%53 = fmul double 1.000000e-02, %52
%54 = call double (...) @random()
%55 = fmul double %53, %54
%56 = load double, double* @RAND_MAX
%57 = fdiv double %55, %56
%58 = fadd double %49, %57
%59 = fptoui double %58 to i32
store i32 %59, i32* %7
store i32 0, i32* %8
br label %60
60: ; preds = %78, %47
%61 = load i32, i32* %8
%62 = load i32, i32* %7
%63 = icmp ult i32 %61, %62
br i1 %63, label %64, label %81
64: ; preds = %60
%65 = call double (...) @random()
%66 = fptoui double %65 to i8
store i8 %66, i8* %9
%67 = load i32*, i32** %10
%68 = call i32 @fwrite(i8* %9, i32 1, i32 1, i32* %67)
%69 = icmp ne i32 %68, 1
br i1 %69, label %70, label %77
70: ; preds = %64
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 2
%73 = load i8*, i8** %72
%74 = call i32 @perror(i8* %73)
%75 = load i32, i32* @EXIT_FAILURE
%76 = call i32 @exit(i32 %75)
unreachable
77: ; preds = %64
br label %78
78: ; preds = %77
%79 = load i32, i32* %8
%80 = add i32 %79, 1
store i32 %80, i32* %8
br label %60
81: ; preds = %60
%82 = load i32*, i32** %10
%83 = call i64 @fclose(i32* %82)
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %92
85: ; preds = %81
%86 = load i8**, i8*** %5
%87 = getelementptr inbounds i8*, i8** %86, i64 2
%88 = load i8*, i8** %87
%89 = call i32 @perror(i8* %88)
%90 = load i32, i32* @EXIT_FAILURE
%91 = call i32 @exit(i32 %90)
unreachable
92: ; preds = %81
%93 = load i32, i32* @EXIT_SUCCESS
%94 = call i32 @exit(i32 %93)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@EXIT_FAILURE = global i32 0
@.str = [3 x i8] c"wb\00"
@RAND_MAX = global double 0.000000e+00
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca i8
%5 = bitcast %struct.stat* %3 to i8*
%6 = tail call i32 @time(i32* null)
%7 = tail call i32 @srandom(i32 %6)
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = call i64 @stat(i8* %9, %struct.stat* %3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = load i8*, i8** %8
%14 = call i32 @perror(i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load i8*, i8** %18
%24 = call i32 @perror(i8* %23)
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %17
%28 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%29 = load i32, i32* %28
%30 = icmp sgt i32 %29, 127
%31 = sub nsw i32 128, %29
%32 = select i1 %30, i32 0, i32 %31
%33 = sitofp i32 %32 to double
%34 = sitofp i32 %29 to double
%35 = fmul double %34, 1.000000e-02
%36 = call double (...) @random()
%37 = fmul double %36, %35
%38 = load double, double* @RAND_MAX
%39 = fdiv double %37, %38
%40 = fadd double %39, %33
%41 = fptoui double %40 to i32
%42 = icmp eq i32 %41, 0
br i1 %42, label %57, label %45
43: ; preds = %45
%44 = icmp eq i32 %51, %41
br i1 %44, label %57, label %45
45: ; preds = %27, %43
%46 = phi i32 [ %51, %43 ], [ 0, %27 ]
%47 = call double (...) @random()
%48 = fptoui double %47 to i8
store i8 %48, i8* %4
%49 = call i32 @fwrite(i8* %4, i32 1, i32 1, i32* %20)
%50 = icmp eq i32 %49, 1
%51 = add nuw i32 %46, 1
br i1 %50, label %43, label %52
52: ; preds = %45
%53 = load i8*, i8** %18
%54 = call i32 @perror(i8* %53)
%55 = load i32, i32* @EXIT_FAILURE
%56 = call i32 @exit(i32 %55)
unreachable
57: ; preds = %43, %27
%58 = call i64 @fclose(i32* %20)
%59 = icmp eq i64 %58, 0
br i1 %59, label %65, label %60
60: ; preds = %57
%61 = load i8*, i8** %18
%62 = call i32 @perror(i8* %61)
%63 = load i32, i32* @EXIT_FAILURE
%64 = call i32 @exit(i32 %63)
unreachable
65: ; preds = %57
%66 = load i32, i32* @EXIT_SUCCESS
%67 = call i32 @exit(i32 %66)
unreachable
}