#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(int *);
scalar_t__ malloc(int);
int nb_cols_geno(char *);
int nb_lines(char *, int);
int /*<<< orphan*/ read_geno(char *, int *, int, int);
int /*<<< orphan*/ write_data_int(char *, int, int, int *);
void geno2lfmm(char *input_file, char *output_file, int *N, int *M) {
  int *data;
  *N = nb_cols_geno(input_file);
  *M = nb_lines(input_file, *N);
  data = (int *)malloc((*N) * (*M) * sizeof(int));
  read_geno(input_file, data, *N, *M);
  write_data_int(output_file, *N, *M, data);
  free(data);
}


x86 assembly (clang, -O0):
<geno2lfmm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <nb_cols_geno@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1050 <nb_lines@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    -0x20(%rbp),%rcx
imul   (%rcx),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
call   1030 <read_geno@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
mov    -0x28(%rbp),%rcx
call   1060 <write_data_int@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geno2lfmm>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r15
mov    %rdx,%r13
mov    %rsi,%r14
mov    %rdi,%r12
call   1080 <nb_cols_geno@plt>
mov    %eax,0x0(%r13)
mov    %r12,%rdi
mov    %eax,%esi
call   1050 <nb_lines@plt>
mov    %eax,(%r15)
imul   0x0(%r13),%eax
lea    0x0(,%rax,4),%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    0x0(%r13),%edx
mov    (%r15),%ecx
mov    %r12,%rdi
mov    %rax,%rsi
call   1030 <read_geno@plt>
mov    0x0(%r13),%esi
mov    (%r15),%edx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <write_data_int@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <free@plt>

LLVM IR (-O0):
define void @geno2lfmm(i8* %0, i8* %1, i32* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%10 = load i8*, i8** %5
%11 = call i32 @nb_cols_geno(i8* %10)
%12 = load i32*, i32** %7
store i32 %11, i32* %12
%13 = load i8*, i8** %5
%14 = load i32*, i32** %7
%15 = load i32, i32* %14
%16 = call i32 @nb_lines(i8* %13, i32 %15)
%17 = load i32*, i32** %8
store i32 %16, i32* %17
%18 = load i32*, i32** %7
%19 = load i32, i32* %18
%20 = load i32*, i32** %8
%21 = load i32, i32* %20
%22 = mul nsw i32 %19, %21
%23 = sext i32 %22 to i64
%24 = mul i64 %23, 4
%25 = trunc i64 %24 to i32
%26 = call i64 @malloc(i32 %25)
%27 = inttoptr i64 %26 to i32*
store i32* %27, i32** %9
%28 = load i8*, i8** %5
%29 = load i32*, i32** %9
%30 = load i32*, i32** %7
%31 = load i32, i32* %30
%32 = load i32*, i32** %8
%33 = load i32, i32* %32
%34 = call i32 @read_geno(i8* %28, i32* %29, i32 %31, i32 %33)
%35 = load i8*, i8** %6
%36 = load i32*, i32** %7
%37 = load i32, i32* %36
%38 = load i32*, i32** %8
%39 = load i32, i32* %38
%40 = load i32*, i32** %9
%41 = call i32 @write_data_int(i8* %35, i32 %37, i32 %39, i32* %40)
%42 = load i32*, i32** %9
%43 = call i32 @free(i32* %42)
ret void
}

LLVM IR (-O2):
define void @geno2lfmm(i8* %0, i8* %1, i32* nocapture %2, i32* nocapture %3) {
%5 = tail call i32 @nb_cols_geno(i8* %0)
store i32 %5, i32* %2
%6 = tail call i32 @nb_lines(i8* %0, i32 %5)
store i32 %6, i32* %3
%7 = load i32, i32* %2
%8 = shl i32 %6, 2
%9 = mul i32 %8, %7
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i32*
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = tail call i32 @read_geno(i8* %0, i32* %11, i32 %12, i32 %13)
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = tail call i32 @write_data_int(i8* %1, i32 %15, i32 %16, i32* %11)
%18 = tail call i32 @free(i32* %11)
ret void
}