#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 */
scalar_t__ atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen_read(char *);
int /*<<< orphan*/ free(char *);
int nb_cols_geno(char *);
int nb_cols_lfmm(char *);
int nb_lines(char *, int);
int /*<<< orphan*/ printf(char *, ...);
char *remove_ext(char *, char, char);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  char input1[512];
  char input2[512];
  int M, N, test_N, test_M;
  char *tmp_file1, *tmp_file2;
  FILE *file1;
  strcpy(input1, argv[1]);
  strcpy(input2, argv[2]);
  N = (int)atoi(argv[3]);
  M = (int)atoi(argv[4]);
  tmp_file1 = remove_ext(input1, '.', '/');
  printf("%s\n", tmp_file1);
  tmp_file2 = remove_ext(input2, '.', '/');
  printf("%s\n", tmp_file2);
  if (strcmp(input1, "NULL")) {
    file1 = fopen_read(input1);
    fclose(file1);
    test_N = nb_cols_geno(input1);
    if (N != test_N) {
      printf("Test cols_geno ERROR: incorrect N detected, %d instead of %d!\n",
             test_N, N);
      return 1;
    }
    test_M = nb_lines(input1, N);
    if (M != test_M) {
      printf("Test lines eERROR: incorrect M detected, %d instead of %d!\n",
             test_M, M);
      return 1;
    }
  }
  test_M = nb_cols_lfmm(input2);
  if (M != test_M) {
    printf("Test cols_lfmm ERROR: incorrect M detected, %d instead of %d!\n",
           test_M, M);
    return 1;
  }
  test_N = nb_lines(input2, M);
  if (N != test_N) {
    printf("Test lines EeRROR: incorrect N detected, %d instead of %d!\n",
           test_N, N);
    return 1;
  }
  free(tmp_file1);
  free(tmp_file2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%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>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x418(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x414(%rbp)
lea    -0x210(%rbp),%rdi
mov    $0x2e,%esi
mov    $0x2f,%edx
call   1070 <remove_ext@plt>
mov    %rax,-0x428(%rbp)
mov    -0x428(%rbp),%rsi
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x410(%rbp),%rdi
mov    $0x2e,%esi
mov    $0x2f,%edx
call   1070 <remove_ext@plt>
mov    %rax,-0x430(%rbp)
mov    -0x430(%rbp),%rsi
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x210(%rbp),%rdi
lea    0xd7b(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     1356 <main+0x1a6>
lea    -0x210(%rbp),%rdi
call   10b0 <fopen_read@plt>
mov    %rax,-0x438(%rbp)
mov    -0x438(%rbp),%rdi
call   1060 <fclose@plt>
lea    -0x210(%rbp),%rdi
call   10a0 <nb_cols_geno@plt>
mov    %eax,-0x41c(%rbp)
mov    -0x418(%rbp),%eax
cmp    -0x41c(%rbp),%eax
je     1301 <main+0x151>
mov    -0x41c(%rbp),%esi
mov    -0x418(%rbp),%edx
lea    0xd1b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    140f <main+0x25f>
lea    -0x210(%rbp),%rdi
mov    -0x418(%rbp),%esi
call   1050 <nb_lines@plt>
mov    %eax,-0x420(%rbp)
mov    -0x414(%rbp),%eax
cmp    -0x420(%rbp),%eax
je     1351 <main+0x1a1>
mov    -0x420(%rbp),%esi
mov    -0x414(%rbp),%edx
lea    0xd0a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    140f <main+0x25f>
jmp    1356 <main+0x1a6>
lea    -0x410(%rbp),%rdi
call   10d0 <nb_cols_lfmm@plt>
mov    %eax,-0x420(%rbp)
mov    -0x414(%rbp),%eax
cmp    -0x420(%rbp),%eax
je     13a0 <main+0x1f0>
mov    -0x420(%rbp),%esi
mov    -0x414(%rbp),%edx
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    140f <main+0x25f>
lea    -0x410(%rbp),%rdi
mov    -0x414(%rbp),%esi
call   1050 <nb_lines@plt>
mov    %eax,-0x41c(%rbp)
mov    -0x418(%rbp),%eax
cmp    -0x41c(%rbp),%eax
je     13f0 <main+0x240>
mov    -0x41c(%rbp),%esi
mov    -0x418(%rbp),%edx
lea    0xce6(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    140f <main+0x25f>
mov    -0x428(%rbp),%rdi
call   1030 <free@plt>
mov    -0x430(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0x200(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strcpy@plt>
mov    0x10(%rbx),%rsi
mov    %rsp,%r13
mov    %r13,%rdi
call   1040 <strcpy@plt>
mov    0x18(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %rax,%r14
mov    0x20(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %rax,%r12
mov    %rbp,%rdi
mov    $0x2e,%esi
mov    $0x2f,%edx
call   1080 <remove_ext@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1060 <puts@plt>
mov    %r13,%rdi
mov    $0x2e,%esi
mov    $0x2f,%edx
call   1080 <remove_ext@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1060 <puts@plt>
lea    0xdb0(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1297 <main+0xd7>
lea    0x200(%rsp),%rbx
mov    %rbx,%rdi
call   10c0 <fopen_read@plt>
mov    %rax,%rdi
call   1070 <fclose@plt>
mov    %rbx,%rdi
call   10b0 <nb_cols_geno@plt>
cmp    %r14d,%eax
jne    12c8 <main+0x108>
lea    0x200(%rsp),%rdi
mov    %r14d,%esi
call   1050 <nb_lines@plt>
cmp    %r12d,%eax
jne    12da <main+0x11a>
mov    %rsp,%rdi
call   10e0 <nb_cols_lfmm@plt>
cmp    %r12d,%eax
jne    12d1 <main+0x111>
mov    %rsp,%rdi
mov    %r12d,%esi
call   1050 <nb_lines@plt>
cmp    %r14d,%eax
jne    12e8 <main+0x128>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    1300 <main+0x140>
lea    0xd36(%rip),%rdi
jmp    12ef <main+0x12f>
lea    0xda8(%rip),%rdi
jmp    12e1 <main+0x121>
lea    0xd63(%rip),%rdi
mov    %eax,%esi
mov    %r12d,%edx
jmp    12f4 <main+0x134>
lea    0xdd0(%rip),%rdi
mov    %eax,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [5 x i8] c"NULL\00"
@.str.2 = [63 x i8] c"Test cols_geno ERROR: incorrect N detected, %d instead of %d!\0A\00"
@.str.3 = [60 x i8] c"Test lines eERROR: incorrect M detected, %d instead of %d!\0A\00"
@.str.4 = [63 x i8] c"Test cols_lfmm ERROR: incorrect M detected, %d instead of %d!\0A\00"
@.str.5 = [60 x i8] c"Test lines EeRROR: incorrect N detected, %d instead of %d!\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i32 @strcpy(i8* %5, i8* %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = call i32 @strcpy(i8* %6, i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 3
%14 = load i8*, i8** %13
%15 = call i64 @atoi(i8* %14)
%16 = trunc i64 %15 to i32
%17 = getelementptr inbounds i8*, i8** %1, i64 4
%18 = load i8*, i8** %17
%19 = call i64 @atoi(i8* %18)
%20 = trunc i64 %19 to i32
%21 = call i8* @remove_ext(i8* %5, i8 signext 46, i8 signext 47)
%22 = call i32 @puts(i8* dereferenceable(1) %21)
%23 = call i8* @remove_ext(i8* %6, i8 signext 46, i8 signext 47)
%24 = call i32 @puts(i8* dereferenceable(1) %23)
%25 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %39, label %27
27: ; preds = %2
%28 = call i32* @fopen_read(i8* %5)
%29 = call i32 @fclose(i32* %28)
%30 = call i32 @nb_cols_geno(i8* %5)
%31 = icmp eq i32 %30, %16
br i1 %31, label %34, label %32
32: ; preds = %27
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i32 %30, i32 %16)
br label %52
34: ; preds = %27
%35 = call i32 @nb_lines(i8* %5, i32 %16)
%36 = icmp eq i32 %35, %20
br i1 %36, label %39, label %37
37: ; preds = %34
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0), i32 %35, i32 %20)
br label %52
39: ; preds = %34, %2
%40 = call i32 @nb_cols_lfmm(i8* %6)
%41 = icmp eq i32 %40, %20
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.4, i64 0, i64 0), i32 %40, i32 %20)
br label %52
44: ; preds = %39
%45 = call i32 @nb_lines(i8* %6, i32 %20)
%46 = icmp eq i32 %45, %16
br i1 %46, label %49, label %47
47: ; preds = %44
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.5, i64 0, i64 0), i32 %45, i32 %16)
br label %52
49: ; preds = %44
%50 = call i32 @free(i8* %21)
%51 = call i32 @free(i8* %23)
br label %52
52: ; preds = %49, %47, %42, %37, %32
%53 = phi i32 [ 1, %32 ], [ 1, %37 ], [ 1, %42 ], [ 1, %47 ], [ 0, %49 ]
ret i32 %53
}