#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_lfmm(char *);
int nb_lines(char *, int);
int /*<<< orphan*/ read_ped(char *, int, int, int *);
int /*<<< orphan*/ write_geno(char *, int, int, int *);
void ped2geno(char *input_file, char *output_file, int *N, int *M) {
  int *data;
  int nb;
  nb = nb_cols_lfmm(input_file);
  *M = (nb - 6) / 2;
  *N = nb_lines(input_file, nb);
  data = (int *)malloc((*N) * (*M) * sizeof(int));
  read_ped(input_file, *N, *M, data);
  write_geno(output_file, *N, *M, data);
  free(data);
}


x86 assembly (clang, -O0):
<ped2geno>:
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   1070 <nb_cols_lfmm@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
sub    $0x6,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1050 <nb_lines@plt>
mov    %eax,%ecx
mov    -0x18(%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   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
mov    -0x28(%rbp),%rcx
call   1080 <read_ped@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
mov    -0x28(%rbp),%rcx
call   1030 <write_geno@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ped2geno>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r13
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
call   1070 <nb_cols_lfmm@plt>
lea    -0x6(%rax),%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
add    $0xfffffffa,%ecx
sar    %ecx
mov    %ecx,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   1060 <malloc@plt>
mov    %rax,%rbx
mov    (%r15),%esi
mov    0x0(%r13),%edx
mov    %r12,%rdi
mov    %rax,%rcx
call   1080 <read_ped@plt>
mov    (%r15),%esi
mov    0x0(%r13),%edx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1030 <write_geno@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <free@plt>

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

LLVM IR (-O2):
define void @ped2geno(i8* %0, i8* %1, i32* nocapture %2, i32* nocapture %3) {
%5 = tail call i32 @nb_cols_lfmm(i8* %0)
%6 = add nsw i32 %5, -6
%7 = sdiv i32 %6, 2
store i32 %7, i32* %3
%8 = tail call i32 @nb_lines(i8* %0, i32 %5)
store i32 %8, i32* %2
%9 = load i32, i32* %3
%10 = shl i32 %8, 2
%11 = mul i32 %10, %9
%12 = tail call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32*
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = tail call i32 @read_ped(i8* %0, i32 %14, i32 %15, i32* %13)
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = tail call i32 @write_geno(i8* %1, i32 %17, i32 %18, i32* %13)
%20 = tail call i32 @free(i32* %13)
ret void
}