#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*/ clear_kb();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, float *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdout;
int main(int argc, char *argv[]) {
  FILE *fp;
  float data[5];
  int count;
  char filename[20];
  puts("Enter 5 floating-point numerical values.");
  for (count = 0; count < 5; count++)
    scanf("%f", &data[count]);
  clear_kb();
  puts("Enter a name for the file.");
  gets(filename);
  if ((fp = fopen(filename, "w")) == NULL) {
    fprintf(stderr, "Error opening file %s.", filename);
    exit(1);
  }
  for (count = 0; count < 5; count++) {
    fprintf(fp, "\ndata[%d] = %f", count, data[count]);
    fprintf(stdout, "\ndata[%d] = %f", count, data[count]);
  }
  fclose(fp);
  printf("\n");
  return 0;
}


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)
lea    0xe53(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x5,-0x34(%rbp)
jge    11ec <main+0x5c>
movslq -0x34(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe90(%rip),%rdi
call   1080 <scanf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11b9 <main+0x29>
mov    $0x0,%al
call   10a0 <clear_kb@plt>
lea    0xe2f(%rip),%rdi
call   1030 <puts@plt>
lea    -0x50(%rbp),%rdi
call   1070 <gets@plt>
lea    -0x50(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    124c <main+0xbc>
mov    0x2db3(%rip),%rax
movslq (%rax),%rdi
lea    -0x50(%rbp),%rdx
lea    0xe0b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x5,-0x34(%rbp)
jge    12b7 <main+0x127>
mov    -0x18(%rbp),%rdi
mov    -0x34(%rbp),%edx
movslq -0x34(%rbp),%rax
movss  -0x30(%rbp,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde4(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    0x2d51(%rip),%rax
mov    (%rax),%rdi
mov    -0x34(%rbp),%edx
movslq -0x34(%rbp),%rax
movss  -0x30(%rbp,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdbb(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1253 <main+0xc3>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xda5(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
lea    0xe60(%rip),%rdi
call   1040 <puts@plt>
lea    0xebd(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
xor    %eax,%eax
call   10a0 <clear_kb@plt>
lea    0xe30(%rip),%rdi
call   1040 <puts@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <gets@plt>
lea    0xe32(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1362 <main+0x1d2>
mov    %rax,%rbx
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe27(%rip),%r14
mov    %rax,%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    0x2d8c(%rip),%r15
mov    (%r15),%rdi
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rsi
xor    %edx,%edx
mov    $0x1,%al
call   1060 <fprintf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    (%r15),%rdi
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rsi
mov    $0x1,%edx
mov    $0x1,%al
call   1060 <fprintf@plt>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    (%r15),%rdi
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rsi
mov    $0x2,%edx
mov    $0x1,%al
call   1060 <fprintf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    (%r15),%rdi
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rsi
mov    $0x3,%edx
mov    $0x1,%al
call   1060 <fprintf@plt>
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    (%r15),%rdi
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rsi
mov    $0x4,%edx
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2c77(%rip),%rax
movslq (%rax),%rdi
lea    0xcd3(%rip),%rsi
lea    0x20(%rsp),%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"Enter 5 floating-point numerical values.\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [27 x i8] c"Enter a name for the file.\00"
@.str.3 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.4 = [23 x i8] c"Error opening file %s.\00"
@.str.5 = [15 x i8] c"\0Adata[%d] = %f\00"
@stdout = global i32* null
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [5 x float]
%8 = alloca i32
%9 = alloca [20 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @puts(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %11
11: ; preds = %19, %2
%12 = load i32, i32* %8
%13 = icmp slt i32 %12, 5
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [5 x float], [5 x float]* %7, i64 0, i64 %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %17)
br label %19
19: ; preds = %14
%20 = load i32, i32* %8
%21 = add nsw i32 %20, 1
store i32 %21, i32* %8
br label %11
22: ; preds = %11
%23 = call i32 (...) @clear_kb()
%24 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%26 = call i32 @gets(i8* %25)
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %28, i32** %6
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %37
30: ; preds = %22
%31 = load i32, i32* @stderr
%32 = sext i32 %31 to i64
%33 = inttoptr i64 %32 to i32*
%34 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %22
store i32 0, i32* %8
br label %38
38: ; preds = %58, %37
%39 = load i32, i32* %8
%40 = icmp slt i32 %39, 5
br i1 %40, label %41, label %61
41: ; preds = %38
%42 = load i32*, i32** %6
%43 = load i32, i32* %8
%44 = load i32, i32* %8
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [5 x float], [5 x float]* %7, i64 0, i64 %45
%47 = load float, float* %46
%48 = fpext float %47 to double
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %43, double %48)
%50 = load i32*, i32** @stdout
%51 = load i32, i32* %8
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [5 x float], [5 x float]* %7, i64 0, i64 %53
%55 = load float, float* %54
%56 = fpext float %55 to double
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %51, double %56)
br label %58
58: ; preds = %41
%59 = load i32, i32* %8
%60 = add nsw i32 %59, 1
store i32 %60, i32* %8
br label %38
61: ; preds = %38
%62 = load i32*, i32** %6
%63 = call i32 @fclose(i32* %62)
%64 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [41 x i8] c"Enter 5 floating-point numerical values.\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [27 x i8] c"Enter a name for the file.\00"
@.str.3 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.4 = [23 x i8] c"Error opening file %s.\00"
@.str.5 = [15 x i8] c"\0Adata[%d] = %f\00"
@stdout = global i32* null
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [5 x float]
%4 = alloca [20 x i8]
%5 = bitcast [5 x float]* %3 to i8*
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [5 x float], [5 x float]* %3, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %8)
%10 = getelementptr inbounds [5 x float], [5 x float]* %3, i64 0, i64 1
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %10)
%12 = getelementptr inbounds [5 x float], [5 x float]* %3, i64 0, i64 2
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %12)
%14 = getelementptr inbounds [5 x float], [5 x float]* %3, i64 0, i64 3
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %14)
%16 = getelementptr inbounds [5 x float], [5 x float]* %3, i64 0, i64 4
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %16)
%18 = call i32 (...) @clear_kb()
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @gets(i8* %6)
%21 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %61, label %23
23: ; preds = %2
%24 = load float, float* %8
%25 = fpext float %24 to double
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 0, double %25)
%27 = load i32*, i32** @stdout
%28 = load float, float* %8
%29 = fpext float %28 to double
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 0, double %29)
%31 = load float, float* %10
%32 = fpext float %31 to double
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 1, double %32)
%34 = load i32*, i32** @stdout
%35 = load float, float* %10
%36 = fpext float %35 to double
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 1, double %36)
%38 = load float, float* %12
%39 = fpext float %38 to double
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 2, double %39)
%41 = load i32*, i32** @stdout
%42 = load float, float* %12
%43 = fpext float %42 to double
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 2, double %43)
%45 = load float, float* %14
%46 = fpext float %45 to double
%47 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 3, double %46)
%48 = load i32*, i32** @stdout
%49 = load float, float* %14
%50 = fpext float %49 to double
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 3, double %50)
%52 = load float, float* %16
%53 = fpext float %52 to double
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 4, double %53)
%55 = load i32*, i32** @stdout
%56 = load float, float* %16
%57 = fpext float %56 to double
%58 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 4, double %57)
%59 = call i32 @fclose(i32* %21)
%60 = call i32 @putchar(i32 10)
ret i32 0
61: ; preds = %2
%62 = load i32, i32* @stderr
%63 = sext i32 %62 to i64
%64 = inttoptr i64 %63 to i32*
%65 = call i32 (i32*, i8*, ...) @fprintf(i32* %64, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%66 = call i32 @exit(i32 1)
unreachable
}