#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 */
scalar_t__ atoi(char *);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ ped2geno(char *, char *, int *, int *);
int /*<<< orphan*/ ped2lfmm(char *, char *, int *, int *);
int /*<<< orphan*/ printf(char *, int, int, int, int);
int /*<<< orphan*/ read_ped(char *, int, int, int *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ write_data_int(char *, int, int, int *);
int main(int argc, char *argv[]) {
  char input_file[512];
  char output_file1[512];
  char output_file2[512];
  char output_file3[512];
  int N, M;
  int test_N, test_M;
  int test_n, test_m;
  int *data;
  strcpy(input_file, argv[1]);
  N = (int)atoi(argv[2]);
  M = (int)atoi(argv[3]);
  strcpy(output_file1, argv[4]);
  strcpy(output_file2, argv[5]);
  strcpy(output_file3, argv[6]);
  data = (int *)malloc(N * M * sizeof(int));
  read_ped(input_file, N, M, data);
  write_data_int(output_file1, N, M, data);
  ped2geno(input_file, output_file2, &test_N, &test_M);
  if (N != test_N || M != test_M) {
    printf(
        "Test ERROR: incorrect N or M detected, %d (%d) instead of %d (%d) !\n",
        test_N, test_M, N, M);
    return 1;
  }
  ped2lfmm(input_file, output_file3, &test_n, &test_m);
  if (N != test_n || M != test_m) {
    printf(
        "Test ERROR: incorrect N or M detected, %d (%d) instead of %d (%d) !\n",
        test_n, test_m, N, M);
    return 1;
  }
  free(data);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x814(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x818(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
call   1040 <strcpy@plt>
lea    -0x610(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rsi
call   1040 <strcpy@plt>
lea    -0x810(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x814(%rbp),%eax
imul   -0x818(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x830(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x814(%rbp),%esi
mov    -0x818(%rbp),%edx
mov    -0x830(%rbp),%rcx
call   10b0 <read_ped@plt>
lea    -0x410(%rbp),%rdi
mov    -0x814(%rbp),%esi
mov    -0x818(%rbp),%edx
mov    -0x830(%rbp),%rcx
call   1080 <write_data_int@plt>
lea    -0x210(%rbp),%rdi
lea    -0x610(%rbp),%rsi
lea    -0x81c(%rbp),%rdx
lea    -0x820(%rbp),%rcx
call   1060 <ped2geno@plt>
mov    -0x814(%rbp),%eax
cmp    -0x81c(%rbp),%eax
jne    12c3 <main+0x133>
mov    -0x818(%rbp),%eax
cmp    -0x820(%rbp),%eax
je     12f4 <main+0x164>
mov    -0x81c(%rbp),%esi
mov    -0x820(%rbp),%edx
mov    -0x814(%rbp),%ecx
mov    -0x818(%rbp),%r8d
lea    0xd1d(%rip),%rdi
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    137d <main+0x1ed>
lea    -0x210(%rbp),%rdi
lea    -0x810(%rbp),%rsi
lea    -0x824(%rbp),%rdx
lea    -0x828(%rbp),%rcx
call   1050 <ped2lfmm@plt>
mov    -0x814(%rbp),%eax
cmp    -0x824(%rbp),%eax
jne    1339 <main+0x1a9>
mov    -0x818(%rbp),%eax
cmp    -0x828(%rbp),%eax
je     136a <main+0x1da>
mov    -0x824(%rbp),%esi
mov    -0x828(%rbp),%edx
mov    -0x814(%rbp),%ecx
mov    -0x818(%rbp),%r8d
lea    0xca7(%rip),%rdi
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    137d <main+0x1ed>
mov    -0x830(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcpy@plt>
mov    0x10(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %rax,%rbp
mov    0x18(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %rax,%r14
mov    0x20(%rbx),%rsi
lea    0x610(%rsp),%r15
mov    %r15,%rdi
call   1040 <strcpy@plt>
mov    0x28(%rbx),%rsi
lea    0x410(%rsp),%r13
mov    %r13,%rdi
call   1040 <strcpy@plt>
mov    0x30(%rbx),%rsi
lea    0x210(%rsp),%rdi
call   1040 <strcpy@plt>
mov    %r14d,%edi
imul   %ebp,%edi
shl    $0x2,%edi
call   1090 <malloc@plt>
mov    %rax,%r12
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %rax,%rcx
call   10b0 <read_ped@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %r12,%rcx
call   1080 <write_data_int@plt>
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <ped2geno@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
cmp    %ebp,%esi
jne    1295 <main+0x105>
cmp    %r14d,%edx
jne    1295 <main+0x105>
lea    0x10(%rsp),%rdi
lea    0x210(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
call   1050 <ped2lfmm@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
cmp    %ebp,%esi
jne    1295 <main+0x105>
cmp    %r14d,%edx
jne    1295 <main+0x105>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    12ab <main+0x11b>
lea    0xd64(%rip),%rdi
mov    %ebp,%ecx
mov    %r14d,%r8d
call   1070 <printf@plt>
mov    $0x1,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [69 x i8] c"Test ERROR: incorrect N or M detected, %d (%d) instead of %d (%d) !\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [512 x i8]
%7 = alloca [512 x i8]
%8 = alloca [512 x i8]
%9 = alloca [512 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strcpy(i8* %17, i8* %20)
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i64 @atoi(i8* %24)
%26 = trunc i64 %25 to i32
store i32 %26, i32* %10
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 3
%29 = load i8*, i8** %28
%30 = call i64 @atoi(i8* %29)
%31 = trunc i64 %30 to i32
store i32 %31, i32* %11
%32 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 4
%35 = load i8*, i8** %34
%36 = call i32 @strcpy(i8* %32, i8* %35)
%37 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 5
%40 = load i8*, i8** %39
%41 = call i32 @strcpy(i8* %37, i8* %40)
%42 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 6
%45 = load i8*, i8** %44
%46 = call i32 @strcpy(i8* %42, i8* %45)
%47 = load i32, i32* %10
%48 = load i32, i32* %11
%49 = mul nsw i32 %47, %48
%50 = sext i32 %49 to i64
%51 = mul i64 %50, 4
%52 = trunc i64 %51 to i32
%53 = call i64 @malloc(i32 %52)
%54 = inttoptr i64 %53 to i32*
store i32* %54, i32** %16
%55 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%56 = load i32, i32* %10
%57 = load i32, i32* %11
%58 = load i32*, i32** %16
%59 = call i32 @read_ped(i8* %55, i32 %56, i32 %57, i32* %58)
%60 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%61 = load i32, i32* %10
%62 = load i32, i32* %11
%63 = load i32*, i32** %16
%64 = call i32 @write_data_int(i8* %60, i32 %61, i32 %62, i32* %63)
%65 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%66 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%67 = call i32 @ped2geno(i8* %65, i8* %66, i32* %12, i32* %13)
%68 = load i32, i32* %10
%69 = load i32, i32* %12
%70 = icmp ne i32 %68, %69
br i1 %70, label %75, label %71
71: ; preds = %2
%72 = load i32, i32* %11
%73 = load i32, i32* %13
%74 = icmp ne i32 %72, %73
br i1 %74, label %75, label %81
75: ; preds = %71, %2
%76 = load i32, i32* %12
%77 = load i32, i32* %13
%78 = load i32, i32* %10
%79 = load i32, i32* %11
%80 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i32 %76, i32 %77, i32 %78, i32 %79)
store i32 1, i32* %3
br label %101
81: ; preds = %71
%82 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%83 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%84 = call i32 @ped2lfmm(i8* %82, i8* %83, i32* %14, i32* %15)
%85 = load i32, i32* %10
%86 = load i32, i32* %14
%87 = icmp ne i32 %85, %86
br i1 %87, label %92, label %88
88: ; preds = %81
%89 = load i32, i32* %11
%90 = load i32, i32* %15
%91 = icmp ne i32 %89, %90
br i1 %91, label %92, label %98
92: ; preds = %88, %81
%93 = load i32, i32* %14
%94 = load i32, i32* %15
%95 = load i32, i32* %10
%96 = load i32, i32* %11
%97 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i32 %93, i32 %94, i32 %95, i32 %96)
store i32 1, i32* %3
br label %101
98: ; preds = %88
%99 = load i32*, i32** %16
%100 = call i32 @free(i32* %99)
store i32 0, i32* %3
br label %101
101: ; preds = %98, %92, %75
%102 = load i32, i32* %3
ret i32 %102
}

LLVM IR (-O2):
@.str = [69 x i8] c"Test ERROR: incorrect N or M detected, %d (%d) instead of %d (%d) !\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = alloca [512 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%15 = bitcast i32* %7 to i8*
%16 = bitcast i32* %8 to i8*
%17 = bitcast i32* %9 to i8*
%18 = bitcast i32* %10 to i8*
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strcpy(i8* %11, i8* %20)
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = call i64 @atoi(i8* %23)
%25 = trunc i64 %24 to i32
%26 = getelementptr inbounds i8*, i8** %1, i64 3
%27 = load i8*, i8** %26
%28 = call i64 @atoi(i8* %27)
%29 = trunc i64 %28 to i32
%30 = getelementptr inbounds i8*, i8** %1, i64 4
%31 = load i8*, i8** %30
%32 = call i32 @strcpy(i8* %12, i8* %31)
%33 = getelementptr inbounds i8*, i8** %1, i64 5
%34 = load i8*, i8** %33
%35 = call i32 @strcpy(i8* %13, i8* %34)
%36 = getelementptr inbounds i8*, i8** %1, i64 6
%37 = load i8*, i8** %36
%38 = call i32 @strcpy(i8* %14, i8* %37)
%39 = mul i64 %28, %24
%40 = trunc i64 %39 to i32
%41 = shl i32 %40, 2
%42 = call i64 @malloc(i32 %41)
%43 = inttoptr i64 %42 to i32*
%44 = call i32 @read_ped(i8* %11, i32 %25, i32 %29, i32* %43)
%45 = call i32 @write_data_int(i8* %12, i32 %25, i32 %29, i32* %43)
%46 = call i32 @ped2geno(i8* %11, i8* %13, i32* %7, i32* %8)
%47 = load i32, i32* %7
%48 = icmp eq i32 %47, %25
%49 = load i32, i32* %8
%50 = icmp eq i32 %49, %29
%51 = select i1 %48, i1 %50, i1 false
br i1 %51, label %54, label %52
52: ; preds = %2
%53 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i32 %47, i32 %49, i32 %25, i32 %29)
br label %65
54: ; preds = %2
%55 = call i32 @ped2lfmm(i8* %11, i8* %14, i32* %9, i32* %10)
%56 = load i32, i32* %9
%57 = icmp eq i32 %56, %25
%58 = load i32, i32* %10
%59 = icmp eq i32 %58, %29
%60 = select i1 %57, i1 %59, i1 false
br i1 %60, label %63, label %61
61: ; preds = %54
%62 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i32 %56, i32 %58, i32 %25, i32 %29)
br label %65
63: ; preds = %54
%64 = call i32 @free(i32* %43)
br label %65
65: ; preds = %63, %61, %52
%66 = phi i32 [ 1, %52 ], [ 1, %61 ], [ 0, %63 ]
ret i32 %66
}