#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*/ fscanf(int /*<<< orphan*/ *, char *, double *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  FILE *myfile;
  double myvariable;
  int i;
  int j;
  myfile = fopen("myfile.txt", "r");
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 3; j++) {
      fscanf(myfile, "%lf", &myvariable);
      printf("%.15f ", myvariable);
    }
    printf("\n");
  }
  fclose(myfile);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    11d9 <main+0x99>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    11bd <main+0x7d>
mov    -0x10(%rbp),%rdi
lea    0xe7a(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <fscanf@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xe69(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    117e <main+0x3e>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116d <main+0x2d>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xea1(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe98(%rip),%r14
mov    %rsp,%r15
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <fscanf@plt>
movsd  (%rsp),%xmm0
lea    0xe7f(%rip),%r12
mov    %r12,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <fscanf@plt>
movsd  (%rsp),%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <fscanf@plt>
movsd  (%rsp),%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <fscanf@plt>
movsd  (%rsp),%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <fscanf@plt>
movsd  (%rsp),%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <fscanf@plt>
movsd  (%rsp),%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"myfile.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [7 x i8] c"%.15f \00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
store i32 0, i32* %4
br label %7
7: ; preds = %24, %0
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %27
10: ; preds = %7
store i32 0, i32* %5
br label %11
11: ; preds = %19, %10
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = load i32*, i32** %2
%16 = call i32 @fscanf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
%17 = load double, double* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %17)
br label %19
19: ; preds = %14
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %11
22: ; preds = %11
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %24
24: ; preds = %22
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %7
27: ; preds = %7
%28 = load i32*, i32** %2
%29 = call i32 @fclose(i32* %28)
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [11 x i8] c"myfile.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [7 x i8] c"%.15f \00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%5 = load double, double* %1
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %5)
%7 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%8 = load double, double* %1
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %8)
%10 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%11 = load double, double* %1
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %11)
%13 = call i32 @putchar(i32 10)
%14 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%15 = load double, double* %1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %15)
%17 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%18 = load double, double* %1
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %18)
%20 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%21 = load double, double* %1
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %21)
%23 = call i32 @putchar(i32 10)
%24 = call i32 @fclose(i32* %3)
ret i32 0
}