#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 /*<<< orphan*/ free(float *);
int /*<<< orphan*/ printf(char *, ...);
float *readfile(char *, int *, int *);
int main(int argc, char *argv[]) {
  int m, n;
  char *filename = argv[1];
  float *data = readfile(filename, &n, &m);
  printf("%i, %i, \n", m, n);
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      printf("%f ", data[i * n + j]);
    }
    printf("\n");
  }
  free(data);
}


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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <readfile@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f3 <main+0xc3>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11d7 <main+0xa7>
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe48(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1195 <main+0x65>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1182 <main+0x52>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
call   1060 <readfile@plt>
mov    %rax,%r15
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xe96(%rip),%rdi
xor    %r12d,%r12d
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11da <main+0x9a>
lea    0xe88(%rip),%r14
jmp    11a5 <main+0x65>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x1,%r12d
cmp    0x4(%rsp),%r12d
jge    11da <main+0x9a>
mov    (%rsp),%eax
test   %eax,%eax
jle    1190 <main+0x50>
xor    %ebx,%ebx
xchg   %ax,%ax
imul   %r12d,%eax
cltq
add    %rbx,%rax
movss  (%r15,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    (%rsp),%eax
add    $0x1,%rbx
cmp    %eax,%ebx
jl     11b0 <main+0x70>
jmp    1190 <main+0x50>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%i, %i, \0A\00"
@.str.1 = [4 x i8] c"%f \00"
@.str.2 = [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 i32
%8 = alloca i8*
%9 = alloca float*
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
store i8* %14, i8** %8
%15 = load i8*, i8** %8
%16 = call float* @readfile(i8* %15, i32* %7, i32* %6)
store float* %16, float** %9
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
store i32 0, i32* %10
br label %20
20: ; preds = %46, %2
%21 = load i32, i32* %10
%22 = load i32, i32* %6
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %49
24: ; preds = %20
store i32 0, i32* %11
br label %25
25: ; preds = %41, %24
%26 = load i32, i32* %11
%27 = load i32, i32* %7
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %44
29: ; preds = %25
%30 = load float*, float** %9
%31 = load i32, i32* %10
%32 = load i32, i32* %7
%33 = mul nsw i32 %31, %32
%34 = load i32, i32* %11
%35 = add nsw i32 %33, %34
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds float, float* %30, i64 %36
%38 = load float, float* %37
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %39)
br label %41
41: ; preds = %29
%42 = load i32, i32* %11
%43 = add nsw i32 %42, 1
store i32 %43, i32* %11
br label %25
44: ; preds = %25
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %46
46: ; preds = %44
%47 = load i32, i32* %10
%48 = add nsw i32 %47, 1
store i32 %48, i32* %10
br label %20
49: ; preds = %20
%50 = load float*, float** %9
%51 = call i32 @free(float* %50)
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str = [10 x i8] c"%i, %i, \0A\00"
@.str.1 = [4 x i8] c"%f \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call float* @readfile(i8* %8, i32* %4, i32* %3)
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11)
%13 = load i32, i32* %3
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %2, %21
%16 = phi i32 [ %23, %21 ], [ 0, %2 ]
%17 = load i32, i32* %4
%18 = icmp sgt i32 %17, 0
br i1 %18, label %26, label %21
19: ; preds = %21, %2
%20 = call i32 @free(float* %9)
ret i32 0
21: ; preds = %26, %15
%22 = call i32 @putchar(i32 10)
%23 = add nuw nsw i32 %16, 1
%24 = load i32, i32* %3
%25 = icmp slt i32 %23, %24
br i1 %25, label %15, label %19
26: ; preds = %15, %26
%27 = phi i32 [ %37, %26 ], [ %17, %15 ]
%28 = phi i32 [ %36, %26 ], [ 0, %15 ]
%29 = mul nsw i32 %27, %16
%30 = add nsw i32 %29, %28
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float, float* %9, i64 %31
%33 = load float, float* %32
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %34)
%36 = add nuw nsw i32 %28, 1
%37 = load i32, i32* %4
%38 = icmp slt i32 %36, %37
br i1 %38, label %26, label %21
}