#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*/ SEEK_SET;
int /*<<< orphan*/ fread(double *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ offset(int, int, int, int);
double get_matrix(int n, int m, int i, int j, FILE *ptr_out) {
  fseek(ptr_out, offset(i, j, n, m), SEEK_SET);
  double x = 0;
  fread(&x, sizeof(double), 1, ptr_out);
  return x;
}


x86 assembly (clang, -O0):
<get_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
call   1050 <offset@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    0x2e72(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rcx
lea    -0x20(%rbp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_matrix>:
push   %r14
push   %rbx
push   %rax
mov    %r8,%r14
mov    %esi,%eax
mov    %edi,%ebx
mov    %edx,%edi
mov    %ecx,%esi
mov    %ebx,%edx
mov    %eax,%ecx
call   1050 <offset@plt>
mov    0x2e91(%rip),%rcx
mov    (%rcx),%edx
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <fseek@plt>
movq   $0x0,(%rsp)
mov    %rsp,%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
movsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define double @get_matrix(i32 %0, i32 %1, i32 %2, i32 %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca double
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32* %4, i32** %10
%12 = load i32*, i32** %10
%13 = load i32, i32* %8
%14 = load i32, i32* %9
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = call i32 @offset(i32 %13, i32 %14, i32 %15, i32 %16)
%18 = load i32, i32* @SEEK_SET
%19 = call i32 @fseek(i32* %12, i32 %17, i32 %18)
store double 0.000000e+00, double* %11
%20 = load i32*, i32** %10
%21 = call i32 @fread(double* %11, i32 8, i32 1, i32* %20)
%22 = load double, double* %11
ret double %22
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define double @get_matrix(i32 %0, i32 %1, i32 %2, i32 %3, i32* nocapture %4) {
%6 = alloca double
%7 = tail call i32 @offset(i32 %2, i32 %3, i32 %0, i32 %1)
%8 = load i32, i32* @SEEK_SET
%9 = tail call i32 @fseek(i32* %4, i32 %7, i32 %8)
%10 = bitcast double* %6 to i8*
store double 0.000000e+00, double* %6
%11 = call i32 @fread(double* %6, i32 8, i32 1, i32* %4)
%12 = load double, double* %6
ret double %12
}