#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 atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int i, num_floats;
  union {
    double d;
    char c[sizeof(double)];
  } u;
  if (argc != 2) {
    fprintf(stderr, "usage: create-float-file [num-floats]\n");
    return 1;
  }
  num_floats = atoi(argv[1]);
  if (num_floats <= 0) {
    fprintf(stderr, "failed to parse num_floats.\n"
                    "usage: create-float-file [num-floats]\n");
    return 1;
  }
  u.d = 0.0;
  for (i = 0; i < num_floats; i++) {
    if (u.d > 100000)
      u.d = 0.0;
    fwrite(u.c, 1, sizeof(double), stdout);
    u.d += 0.5;
  }
  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)
cmpl   $0x2,-0x8(%rbp)
je     1171 <main+0x41>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1229 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jg     11ac <main+0x7c>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1229 <main+0xf9>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1222 <main+0xf2>
movsd  -0x20(%rbp),%xmm0
movsd  0xe2c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11e6 <main+0xb6>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    -0x20(%rbp),%rdi
mov    0x2de7(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x8,%edx
call   1050 <fwrite@plt>
movsd  0xdfe(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bb <main+0x8b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    11b3 <main+0x83>
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
test   %eax,%eax
jle    11c0 <main+0x90>
mov    %eax,%ebx
movq   $0x0,0x8(%rsp)
xorpd  %xmm0,%xmm0
mov    0x2e77(%rip),%r15
lea    0x8(%rsp),%r14
jmp    119e <main+0x6e>
nopl   0x0(%rax,%rax,1)
mov    (%r15),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x8,%edx
call   1050 <fwrite@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xe75(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0xffffffff,%ebx
je     11bc <main+0x8c>
ucomisd 0xe5a(%rip),%xmm0
jbe    1170 <main+0x40>
movq   $0x0,0x8(%rsp)
jmp    1170 <main+0x40>
lea    0xe72(%rip),%rsi
jmp    11c7 <main+0x97>
xor    %eax,%eax
jmp    11da <main+0xaa>
lea    0xe49(%rip),%rsi
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
call   1030 <fprintf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%union.anon = type { double }
@stderr = global i32 0
@.str = [39 x i8] c"usage: create-float-file [num-floats]\0A\00"
@.str.1 = [67 x i8] c"failed to parse num_floats.\0Ausage: create-float-file [num-floats]\0A\00"
@stdout = 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 %union.anon
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %48
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = icmp sle i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %48
24: ; preds = %14
%25 = bitcast %union.anon* %8 to double*
store double 0.000000e+00, double* %25
store i32 0, i32* %6
br label %26
26: ; preds = %44, %24
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %47
30: ; preds = %26
%31 = bitcast %union.anon* %8 to double*
%32 = load double, double* %31
%33 = fcmp ogt double %32, 1.000000e+05
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = bitcast %union.anon* %8 to double*
store double 0.000000e+00, double* %35
br label %36
36: ; preds = %34, %30
%37 = bitcast %union.anon* %8 to [8 x i8]*
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %37, i64 0, i64 0
%39 = load i32, i32* @stdout
%40 = call i32 @fwrite(i8* %38, i32 1, i32 8, i32 %39)
%41 = bitcast %union.anon* %8 to double*
%42 = load double, double* %41
%43 = fadd double %42, 5.000000e-01
store double %43, double* %41
br label %44
44: ; preds = %36
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
br label %26
47: ; preds = %26
store i32 0, i32* %3
br label %48
48: ; preds = %47, %21, %11
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
%union.anon = type { double }
@stderr = global i32 0
@.str = [39 x i8] c"usage: create-float-file [num-floats]\0A\00"
@.str.1 = [67 x i8] c"failed to parse num_floats.\0Ausage: create-float-file [num-floats]\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %union.anon
%4 = bitcast %union.anon* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %25
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = icmp slt i32 %9, 1
br i1 %10, label %25, label %11
11: ; preds = %6
%12 = getelementptr inbounds %union.anon, %union.anon* %3, i64 0, i32 0
store double 0.000000e+00, double* %12
br label %13
13: ; preds = %11, %18
%14 = phi double [ %22, %18 ], [ 0.000000e+00, %11 ]
%15 = phi i32 [ %23, %18 ], [ 0, %11 ]
%16 = fcmp ogt double %14, 1.000000e+05
br i1 %16, label %17, label %18
17: ; preds = %13
store double 0.000000e+00, double* %12
br label %18
18: ; preds = %17, %13
%19 = load i32, i32* @stdout
%20 = call i32 @fwrite(i8* %4, i32 1, i32 8, i32 %19)
%21 = load double, double* %12
%22 = fadd double %21, 5.000000e-01
store double %22, double* %12
%23 = add nuw nsw i32 %15, 1
%24 = icmp eq i32 %23, %9
br i1 %24, label %29, label %13
25: ; preds = %6, %2
%26 = phi i8* [ getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0), %6 ]
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* %26)
br label %29
29: ; preds = %18, %25
%30 = phi i32 [ 1, %25 ], [ 0, %18 ]
ret i32 %30
}