#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 */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, long double);
void counter(long double *array) {
  FILE *fp;
  char output[] = "cgrfs.dat";
  int q;
  fp = fopen(output, "w");
  for (q = 0; q < 250000; q++) {
    fprintf(fp, "%Lf\n", array[q]);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<counter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x1a(%rbp)
mov    0xeba(%rip),%ax
mov    %ax,-0x12(%rbp)
lea    -0x1a(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x3d090,-0x20(%rbp)
jge    11ac <counter+0x7c>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
shl    $0x4,%rcx
fldt   (%rax,%rcx,1)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xe73(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116d <counter+0x3d>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<counter>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r14
movabs $0x61642e7366726763,%rax
2e 64 61
mov    %rax,0x18(%rsp)
movw   $0x74,0x20(%rsp)
lea    0xeaf(%rip),%rsi
lea    0x18(%rsp),%rdi
call   1050 <fopen@plt>
mov    %rax,%r12
xor    %ebx,%ebx
lea    0xe9b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
fldt   (%r14,%rbx,1)
fstpt  (%rsp)
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <fprintf@plt>
add    $0x10,%rbx
cmp    $0x3d0900,%rbx
jne    1180 <counter+0x50>
mov    %r12,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@__const.counter.output = [10 x i8] c"cgrfs.dat\00"
@.str = [2 x i8] c"w\00"
@.str.1 = [5 x i8] c"%Lf\0A\00"
define void @counter(x86_fp80* %0) {
%2 = alloca x86_fp80*
%3 = alloca i32*
%4 = alloca [10 x i8]
%5 = alloca i32
store x86_fp80* %0, x86_fp80** %2
%6 = bitcast [10 x i8]* %4 to i8*
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %3
store i32 0, i32* %5
br label %9
9: ; preds = %20, %1
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 250000
br i1 %11, label %12, label %23
12: ; preds = %9
%13 = load i32*, i32** %3
%14 = load x86_fp80*, x86_fp80** %2
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds x86_fp80, x86_fp80* %14, i64 %16
%18 = load x86_fp80, x86_fp80* %17
%19 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), x86_fp80 %18)
br label %20
20: ; preds = %12
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %9
23: ; preds = %9
%24 = load i32*, i32** %3
%25 = call i32 @fclose(i32* %24)
ret void
}

LLVM IR (-O2):
@__const.counter.output = [10 x i8] c"cgrfs.dat\00"
@.str = [2 x i8] c"w\00"
@.str.1 = [5 x i8] c"%Lf\0A\00"
define void @counter(x86_fp80* nocapture %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %1, %5
%6 = phi i64 [ 0, %1 ], [ %10, %5 ]
%7 = getelementptr inbounds x86_fp80, x86_fp80* %0, i64 %6
%8 = load x86_fp80, x86_fp80* %7
%9 = tail call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), x86_fp80 %8)
%10 = add nuw nsw i64 %6, 1
%11 = icmp eq i64 %10, 250000
br i1 %11, label %12, label %5
12: ; preds = %5
%13 = tail call i32 @fclose(i32* %4)
ret void
}