#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
scalar_t__ fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
double frand();
int /*<<< orphan*/ init_random(long long *);
int nb_cols_geno(char *);
int nb_lines(char *, int);
int /*<<< orphan*/ print_error_global(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ print_summary_cds(int, int, long long, double, char *,
                                     char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ test_column(char *, int /*<<< orphan*/ *, int, int, int,
                               char *);
void createDataSet(char *input_file, long long seed, double e,
                   char *output_file) {
  int N = 0;
  int M = 0;
  int X;
  int i, j;
  FILE *in_File = NULL;
  FILE *out_File = NULL;
  char token;
  init_random(&seed);
  N = nb_cols_geno(input_file);
  M = nb_lines(input_file, N);
  print_summary_cds(N, M, seed, e, input_file, output_file);
  in_File = fopen(input_file, "r");
  out_File = fopen(output_file, "w");
  if (!in_File)
    print_error_global("open", input_file, 0);
  if (!out_File)
    print_error_global("open", output_file, 0);
  j = 0;
  while (!feof(in_File) & (j < M)) {
    i = 0;
    token = (char)fgetc(in_File);
    while (token != EOF && token != '\n' && i < N) {
      X = (int)(token - '0');
      if (frand() < e)
        fprintf(out_File, "9");
      else
        fprintf(out_File, "%d", X);
      i++;
      token = (char)fgetc(in_File);
    }
    fprintf(out_File, "\n");
    test_column(input_file, in_File, i, j, N, &token);
    j++;
  }
  fclose(in_File);
  fclose(out_File);
  printf("\n Write genotype file with masked data, %s:\t\tOK.\n\n",
         output_file);
}


x86 assembly (clang, -O0):
<createDataSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
lea    -0x10(%rbp),%rdi
call   1050 <init_random@plt>
mov    -0x8(%rbp),%rdi
call   10d0 <nb_cols_geno@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1030 <nb_lines@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x10(%rbp),%rdx
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1080 <print_summary_cds@plt>
mov    -0x8(%rbp),%rdi
lea    0xdae(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xd9c(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    128c <createDataSet+0xbc>
mov    -0x8(%rbp),%rsi
lea    0xd7f(%rip),%rdi
xor    %edx,%edx
call   10f0 <print_error_global@plt>
cmpq   $0x0,-0x48(%rbp)
jne    12a9 <createDataSet+0xd9>
mov    -0x20(%rbp),%rsi
lea    0xd62(%rip),%rdi
xor    %edx,%edx
call   10f0 <print_error_global@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x40(%rbp),%rdi
call   10a0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    -0x34(%rbp),%ecx
cmp    -0x28(%rbp),%ecx
setl   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     13e0 <createDataSet+0x210>
movl   $0x0,-0x30(%rbp)
mov    -0x40(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x49(%rbp)
movsbl -0x49(%rbp),%ecx
mov    0x2cea(%rip),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x4a(%rbp)
je     132c <createDataSet+0x15c>
movsbl -0x49(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x4a(%rbp)
je     132c <createDataSet+0x15c>
mov    -0x30(%rbp),%eax
cmp    -0x24(%rbp),%eax
setl   %al
mov    %al,-0x4a(%rbp)
mov    -0x4a(%rbp),%al
test   $0x1,%al
jne    133c <createDataSet+0x16c>
jmp    13a5 <createDataSet+0x1d5>
movsbl -0x49(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   10b0 <frand@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1376 <createDataSet+0x1a6>
mov    -0x48(%rbp),%rdi
lea    0xc9f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    138b <createDataSet+0x1bb>
mov    -0x48(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xc87(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x40(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x49(%rbp)
jmp    12f3 <createDataSet+0x123>
mov    -0x48(%rbp),%rdi
lea    0xc8f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x24(%rbp),%r8d
lea    -0x49(%rbp),%r9
call   10c0 <test_column@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12b0 <createDataSet+0xe0>
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rsi
lea    0xc11(%rip),%rdi
call   1060 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createDataSet>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r14
movsd  %xmm0,0x10(%rsp)
mov    %rdi,%rbx
mov    %rsi,0x18(%rsp)
lea    0x18(%rsp),%rdi
call   1050 <init_random@plt>
mov    %rbx,%rdi
call   10e0 <nb_cols_geno@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <nb_lines@plt>
mov    0x18(%rsp),%rdx
mov    %r13d,%edi
mov    %eax,0x4(%rsp)
mov    %eax,%esi
movsd  0x10(%rsp),%xmm0
mov    %rbx,%rcx
mov    %r14,%r8
call   1090 <print_summary_cds@plt>
lea    0xdbc(%rip),%rsi
mov    %rbx,0x8(%rsp)
mov    %rbx,%rdi
call   10f0 <fopen@plt>
mov    %rax,%rbx
lea    0xda7(%rip),%rsi
mov    %r14,%rdi
call   10f0 <fopen@plt>
mov    %rax,%r15
test   %rbx,%rbx
je     13d3 <createDataSet+0x1f3>
test   %r15,%r15
je     13ef <createDataSet+0x20f>
mov    %r14,0x20(%rsp)
mov    %rbx,%rdi
call   10b0 <feof@plt>
cmpl   $0x0,0x4(%rsp)
jle    13a3 <createDataSet+0x1c3>
test   %eax,%eax
jne    13a3 <createDataSet+0x1c3>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1070 <fgetc@plt>
mov    %rax,%r14
mov    %r14b,0x3(%rsp)
mov    $0x0,%r12d
cmp    $0xa,%r14b
je     1363 <createDataSet+0x183>
mov    $0x0,%r12d
mov    0x2d1b(%rip),%rax
cmp    %r14b,(%rax)
je     1363 <createDataSet+0x183>
mov    $0x0,%r12d
test   %r13d,%r13d
jle    1363 <createDataSet+0x183>
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10c0 <frand@plt>
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    1320 <createDataSet+0x140>
mov    $0x39,%edi
mov    %r15,%rsi
call   1080 <fputc@plt>
jmp    1338 <createDataSet+0x158>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %r14b,%edx
add    $0xffffffd0,%edx
mov    %r15,%rdi
lea    0xcd8(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
add    $0x1,%r12d
mov    %rbx,%rdi
call   1070 <fgetc@plt>
mov    %rax,%r14
mov    %r14b,0x3(%rsp)
cmp    $0xa,%r14b
je     1363 <createDataSet+0x183>
mov    0x2c8f(%rip),%rax
cmp    %r14b,(%rax)
je     1363 <createDataSet+0x183>
cmp    %r13d,%r12d
jl     12f0 <createDataSet+0x110>
mov    $0xa,%edi
mov    %r15,%rsi
call   1080 <fputc@plt>
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
mov    %ebp,%ecx
mov    %r13d,%r8d
lea    0x3(%rsp),%r9
call   10d0 <test_column@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
call   10b0 <feof@plt>
cmp    0x4(%rsp),%ebp
jge    13a3 <createDataSet+0x1c3>
test   %eax,%eax
je     12a0 <createDataSet+0xc0>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
lea    0xc52(%rip),%rdi
mov    0x20(%rsp),%rsi
call   1060 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc2a(%rip),%rdi
mov    0x8(%rsp),%rsi
xor    %edx,%edx
call   1100 <print_error_global@plt>
test   %r15,%r15
jne    1278 <createDataSet+0x98>
lea    0xc0e(%rip),%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1100 <print_error_global@plt>
jmp    1278 <createDataSet+0x98>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [5 x i8] c"open\00"
@EOF = global i8 0
@.str.3 = [2 x i8] c"9\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [51 x i8] c"\0A Write genotype file with masked data, %s:\09\09OK.\0A\0A\00"
define void @createDataSet(i8* %0, i64 %1, double %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca double
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i8
store i8* %0, i8** %5
store i64 %1, i64* %6
store double %2, double* %7
store i8* %3, i8** %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32* null, i32** %14
store i32* null, i32** %15
%17 = call i32 @init_random(i64* %6)
%18 = load i8*, i8** %5
%19 = call i32 @nb_cols_geno(i8* %18)
store i32 %19, i32* %9
%20 = load i8*, i8** %5
%21 = load i32, i32* %9
%22 = call i32 @nb_lines(i8* %20, i32 %21)
store i32 %22, i32* %10
%23 = load i32, i32* %9
%24 = load i32, i32* %10
%25 = load i64, i64* %6
%26 = load double, double* %7
%27 = load i8*, i8** %5
%28 = load i8*, i8** %8
%29 = call i32 @print_summary_cds(i32 %23, i32 %24, i64 %25, double %26, i8* %27, i8* %28)
%30 = load i8*, i8** %5
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %31, i32** %14
%32 = load i8*, i8** %8
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %33, i32** %15
%34 = load i32*, i32** %14
%35 = icmp ne i32* %34, null
br i1 %35, label %39, label %36
36: ; preds = %4
%37 = load i8*, i8** %5
%38 = call i32 @print_error_global(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %37, i32 0)
br label %39
39: ; preds = %36, %4
%40 = load i32*, i32** %15
%41 = icmp ne i32* %40, null
br i1 %41, label %45, label %42
42: ; preds = %39
%43 = load i8*, i8** %8
%44 = call i32 @print_error_global(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %43, i32 0)
br label %45
45: ; preds = %42, %39
store i32 0, i32* %13
br label %46
46: ; preds = %98, %45
%47 = load i32*, i32** %14
%48 = call i32 @feof(i32* %47)
%49 = icmp ne i32 %48, 0
%50 = xor i1 %49, true
%51 = zext i1 %50 to i32
%52 = load i32, i32* %13
%53 = load i32, i32* %10
%54 = icmp slt i32 %52, %53
%55 = zext i1 %54 to i32
%56 = and i32 %51, %55
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %109
58: ; preds = %46
store i32 0, i32* %12
%59 = load i32*, i32** %14
%60 = call i64 @fgetc(i32* %59)
%61 = trunc i64 %60 to i8
store i8 %61, i8* %16
br label %62
62: ; preds = %92, %58
%63 = load i8, i8* %16
%64 = sext i8 %63 to i32
%65 = load i8, i8* @EOF
%66 = sext i8 %65 to i32
%67 = icmp ne i32 %64, %66
br i1 %67, label %68, label %76
68: ; preds = %62
%69 = load i8, i8* %16
%70 = sext i8 %69 to i32
%71 = icmp ne i32 %70, 10
br i1 %71, label %72, label %76
72: ; preds = %68
%73 = load i32, i32* %12
%74 = load i32, i32* %9
%75 = icmp slt i32 %73, %74
br label %76
76: ; preds = %72, %68, %62
%77 = phi i1 [ false, %68 ], [ false, %62 ], [ %75, %72 ]
br i1 %77, label %78, label %98
78: ; preds = %76
%79 = load i8, i8* %16
%80 = sext i8 %79 to i32
%81 = sub nsw i32 %80, 48
store i32 %81, i32* %11
%82 = call double (...) @frand()
%83 = load double, double* %7
%84 = fcmp olt double %82, %83
br i1 %84, label %85, label %88
85: ; preds = %78
%86 = load i32*, i32** %15
%87 = call i32 (i32*, i8*, ...) @fprintf(i32* %86, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %92
88: ; preds = %78
%89 = load i32*, i32** %15
%90 = load i32, i32* %11
%91 = call i32 (i32*, i8*, ...) @fprintf(i32* %89, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %90)
br label %92
92: ; preds = %88, %85
%93 = load i32, i32* %12
%94 = add nsw i32 %93, 1
store i32 %94, i32* %12
%95 = load i32*, i32** %14
%96 = call i64 @fgetc(i32* %95)
%97 = trunc i64 %96 to i8
store i8 %97, i8* %16
br label %62
98: ; preds = %76
%99 = load i32*, i32** %15
%100 = call i32 (i32*, i8*, ...) @fprintf(i32* %99, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%101 = load i8*, i8** %5
%102 = load i32*, i32** %14
%103 = load i32, i32* %12
%104 = load i32, i32* %13
%105 = load i32, i32* %9
%106 = call i32 @test_column(i8* %101, i32* %102, i32 %103, i32 %104, i32 %105, i8* %16)
%107 = load i32, i32* %13
%108 = add nsw i32 %107, 1
store i32 %108, i32* %13
br label %46
109: ; preds = %46
%110 = load i32*, i32** %14
%111 = call i32 @fclose(i32* %110)
%112 = load i32*, i32** %15
%113 = call i32 @fclose(i32* %112)
%114 = load i8*, i8** %8
%115 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i8* %114)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [5 x i8] c"open\00"
@EOF = global i8 0
@.str.4 = [3 x i8] c"%d\00"
@.str.6 = [51 x i8] c"\0A Write genotype file with masked data, %s:\09\09OK.\0A\0A\00"
define void @createDataSet(i8* %0, i64 %1, double %2, i8* %3) {
%5 = alloca i64
%6 = alloca i8
store i64 %1, i64* %5
%7 = call i32 @init_random(i64* %5)
%8 = call i32 @nb_cols_geno(i8* %0)
%9 = call i32 @nb_lines(i8* %0, i32 %8)
%10 = load i64, i64* %5
%11 = call i32 @print_summary_cds(i32 %8, i32 %9, i64 %10, double %2, i8* %0, i8* %3)
%12 = call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %12, null
br i1 %14, label %15, label %17
15: ; preds = %4
%16 = call i32 @print_error_global(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 0)
br label %17
17: ; preds = %15, %4
%18 = icmp eq i32* %13, null
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = call i32 @print_error_global(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %3, i32 0)
br label %21
21: ; preds = %19, %17
%22 = call i32 @feof(i32* %12)
%23 = icmp eq i32 %22, 0
%24 = icmp sgt i32 %9, 0
%25 = and i1 %24, %23
br i1 %25, label %26, label %67
26: ; preds = %21
%27 = icmp sgt i32 %8, 0
br label %28
28: ; preds = %26, %58
%29 = phi i32 [ 0, %26 ], [ %62, %58 ]
%30 = call i64 @fgetc(i32* %12)
%31 = trunc i64 %30 to i8
store i8 %31, i8* %6
%32 = load i8, i8* @EOF
%33 = icmp ne i8 %32, %31
%34 = icmp ne i8 %31, 10
%35 = and i1 %34, %33
%36 = and i1 %35, %27
br i1 %36, label %37, label %58
37: ; preds = %28, %48
%38 = phi i8 [ %51, %48 ], [ %31, %28 ]
%39 = phi i32 [ %49, %48 ], [ 0, %28 ]
%40 = call double (...) @frand()
%41 = fcmp olt double %40, %2
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = call i32 @fputc(i32 57, i32* %13)
br label %48
44: ; preds = %37
%45 = sext i8 %38 to i32
%46 = add nsw i32 %45, -48
%47 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %44, %42
%49 = add nuw nsw i32 %39, 1
%50 = call i64 @fgetc(i32* %12)
%51 = trunc i64 %50 to i8
store i8 %51, i8* %6
%52 = load i8, i8* @EOF
%53 = icmp ne i8 %52, %51
%54 = icmp ne i8 %51, 10
%55 = and i1 %54, %53
%56 = icmp slt i32 %49, %8
%57 = select i1 %55, i1 %56, i1 false
br i1 %57, label %37, label %58
58: ; preds = %48, %28
%59 = phi i32 [ 0, %28 ], [ %49, %48 ]
%60 = call i32 @fputc(i32 10, i32* %13)
%61 = call i32 @test_column(i8* %0, i32* %12, i32 %59, i32 %29, i32 %8, i8* %6)
%62 = add nuw nsw i32 %29, 1
%63 = call i32 @feof(i32* %12)
%64 = icmp eq i32 %63, 0
%65 = icmp slt i32 %62, %9
%66 = and i1 %65, %64
br i1 %66, label %28, label %67
67: ; preds = %58, %21
%68 = call i32 @fclose(i32* %12)
%69 = call i32 @fclose(i32* %13)
%70 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i8* %3)
ret void
}