#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 /*<<< orphan*/ FILE;

/* Variables and functions */
double drand48();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *fp;
  int i;
  double x;
  if (argc < 2) {
    fprintf(stderr, "Usage %s file.name\n", argv[0]);
    return 1;
  }
  fp = fopen(argv[1], "w");
  fprintf(fp, "%d\n", 100);
  for (i = 0; i < 100; ++i) {
    x = ((double)i) + 1.e-8 * drand48();
    fprintf(fp, "%22.15g\n", x);
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    118b <main+0x4b>
mov    0x2e79(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    122b <main+0xeb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe82(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe70(%rip),%rsi
mov    $0x64,%edx
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x64,-0x1c(%rbp)
jge    121b <main+0xdb>
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    $0x0,%al
call   1060 <drand48@plt>
movsd  -0x30(%rbp),%xmm1
movsd  0xe17(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
lea    0xe1c(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c1 <main+0x81>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jg     1172 <main+0x32>
mov    0x2e8c(%rip),%rax
movslq (%rax),%rdi
mov    (%rsi),%rdx
lea    0xeaf(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%eax
jmp    1205 <main+0xc5>
mov    0x8(%rsi),%rdi
lea    0xea7(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0xe9a(%rip),%rsi
mov    $0x64,%ebp
mov    %rax,%rdi
mov    $0x64,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xe79(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <drand48@plt>
mulsd  0xe31(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xe18(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0xffffffff,%ebp
jne    11c0 <main+0x80>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Usage %s file.name\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [9 x i8] c"%22.15g\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %19
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i32*
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %17)
store i32 1, i32* %3
br label %43
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %6
%24 = load i32*, i32** %6
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 100)
store i32 0, i32* %7
br label %26
26: ; preds = %37, %19
%27 = load i32, i32* %7
%28 = icmp slt i32 %27, 100
br i1 %28, label %29, label %40
29: ; preds = %26
%30 = load i32, i32* %7
%31 = sitofp i32 %30 to double
%32 = call double (...) @drand48()
%33 = call double @llvm.fmuladd.f64(double 1.000000e-08, double %32, double %31)
store double %33, double* %8
%34 = load i32*, i32** %6
%35 = load double, double* %8
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), double %35)
br label %37
37: ; preds = %29
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %26
40: ; preds = %26
%41 = load i32*, i32** %6
%42 = call i32 @fclose(i32* %41)
store i32 0, i32* %3
br label %43
43: ; preds = %40, %11
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Usage %s file.name\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [9 x i8] c"%22.15g\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i32*
%8 = load i8*, i8** %1
%9 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %25
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 100)
br label %15
15: ; preds = %10, %15
%16 = phi i32 [ 0, %10 ], [ %21, %15 ]
%17 = sitofp i32 %16 to double
%18 = tail call double (...) @drand48()
%19 = tail call double @llvm.fmuladd.f64(double %18, double 1.000000e-08, double %17)
%20 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), double %19)
%21 = add nuw nsw i32 %16, 1
%22 = icmp eq i32 %21, 100
br i1 %22, label %23, label %15
23: ; preds = %15
%24 = tail call i32 @fclose(i32* %13)
br label %25
25: ; preds = %23, %4
%26 = phi i32 [ 1, %4 ], [ 0, %23 ]
ret i32 %26
}