#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*/ buffer;

/* Variables and functions */
double SNPHWE_pValue(int, int, int, int);
int atoi(char *);
char **calloc(int, int);
int /*<<< orphan*/ exit(int);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char **);
int pq_countcols(char *, char const *);
int pq_str2array(char **, char *, int, char const *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  int ctype;
  ctype = 1;
  if (argc > 1) {
    ctype = atoi(argv[1]);
  }
  int ohets;
  int ohom1;
  int ohom2;
  double pval;
  int i;
  int ncols;
  char **array;
  char buffer[5120];
  const char delim = '\t';
  int rown;
  rown = 0;
  while (fgets(buffer, sizeof(buffer), stdin)) {
    if (rown == 0) {
      ncols = pq_countcols(buffer, &delim);
      array = calloc(ncols, sizeof(char *));
    }
    if (pq_str2array(array, buffer, ncols, &delim) == -1) {
      free(array);
      exit(1);
    }
    ohom1 = atoi(array[4]);
    ohets = atoi(array[5]);
    ohom2 = atoi(array[6]);
    pval = SNPHWE_pValue(ohets, ohom1, ohom2, ctype);
    printf("%s", array[0]);
    for (i = 1; i < 7; i++) {
      printf("\t%s", array[i]);
    }
    printf("\t%f\n", pval);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11ca <main+0x3a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
movb   $0x9,-0x1441(%rbp)
movl   $0x0,-0x1448(%rbp)
lea    -0x1440(%rbp),%rdi
mov    0x2dff(%rip),%rax
mov    (%rax),%edx
mov    $0x1400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1315 <main+0x185>
cmpl   $0x0,-0x1448(%rbp)
jne    1233 <main+0xa3>
lea    -0x1440(%rbp),%rdi
lea    -0x1441(%rbp),%rsi
call   1080 <pq_countcols@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    -0x1440(%rbp),%rsi
mov    -0x30(%rbp),%edx
lea    -0x1441(%rbp),%rcx
call   10b0 <pq_str2array@plt>
cmp    $0xffffffff,%eax
jne    1269 <main+0xd9>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x38(%rbp),%rax
mov    0x20(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x38(%rbp),%rax
mov    0x28(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x38(%rbp),%rax
mov    0x30(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1050 <SNPHWE_pValue@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%rsi
lea    0xd44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x2c(%rbp)
cmpl   $0x7,-0x2c(%rbp)
jge    12fd <main+0x16d>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12cb <main+0x13b>
movsd  -0x28(%rbp),%xmm0
lea    0xcfb(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11db <main+0x4b>
xor    %eax,%eax
add    $0x1450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1418,%rsp
movl   $0x1,0x4(%rsp)
cmp    $0x2,%edi
jl     11bb <main+0x2b>
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
mov    %eax,0x4(%rsp)
movb   $0x9,0x3(%rsp)
mov    0x2e21(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rdi
mov    $0x1400,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     12f8 <main+0x168>
lea    0x10(%rsp),%r14
lea    0xe13(%rip),%r12
nopl   (%rax)
mov    %r14,%rdi
lea    0x3(%rsp),%rbx
mov    %rbx,%rsi
call   1080 <pq_countcols@plt>
mov    %eax,%r13d
mov    %eax,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
mov    %rbx,%rcx
call   10b0 <pq_str2array@plt>
cmp    $0xffffffff,%eax
je     130c <main+0x17c>
mov    0x20(%r15),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebx
mov    0x28(%r15),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebp
mov    0x30(%r15),%rdi
call   1090 <atoi@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %eax,%edx
mov    0x4(%rsp),%ecx
call   1050 <SNPHWE_pValue@plt>
movsd  %xmm0,0x8(%rsp)
mov    (%r15),%rsi
lea    0xd97(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%r15),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%r15),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%r15),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%r15),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%r15),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x30(%r15),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd38(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2d08(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x1400,%esi
call   1060 <fgets@plt>
test   %rax,%rax
jne    11f0 <main+0x60>
xor    %eax,%eax
add    $0x1418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15,%rdi
call   1030 <free@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"\09%s\00"
@.str.2 = [5 x i8] c"\09%f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8**
%14 = alloca [5120 x i8]
%15 = alloca i8
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
%17 = load i32, i32* %4
%18 = icmp sgt i32 %17, 1
br i1 %18, label %19, label %24
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %6
br label %24
24: ; preds = %19, %2
store i8 9, i8* %15
store i32 0, i32* %16
br label %25
25: ; preds = %83, %24
%26 = getelementptr inbounds [5120 x i8], [5120 x i8]* %14, i64 0, i64 0
%27 = load i32, i32* @stdin
%28 = call i64 @fgets(i8* %26, i32 5120, i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %86
30: ; preds = %25
%31 = load i32, i32* %16
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = getelementptr inbounds [5120 x i8], [5120 x i8]* %14, i64 0, i64 0
%35 = call i32 @pq_countcols(i8* %34, i8* %15)
store i32 %35, i32* %12
%36 = load i32, i32* %12
%37 = call i8** @calloc(i32 %36, i32 8)
store i8** %37, i8*** %13
br label %38
38: ; preds = %33, %30
%39 = load i8**, i8*** %13
%40 = getelementptr inbounds [5120 x i8], [5120 x i8]* %14, i64 0, i64 0
%41 = load i32, i32* %12
%42 = call i32 @pq_str2array(i8** %39, i8* %40, i32 %41, i8* %15)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %48
44: ; preds = %38
%45 = load i8**, i8*** %13
%46 = call i32 @free(i8** %45)
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %38
%49 = load i8**, i8*** %13
%50 = getelementptr inbounds i8*, i8** %49, i64 4
%51 = load i8*, i8** %50
%52 = call i32 @atoi(i8* %51)
store i32 %52, i32* %8
%53 = load i8**, i8*** %13
%54 = getelementptr inbounds i8*, i8** %53, i64 5
%55 = load i8*, i8** %54
%56 = call i32 @atoi(i8* %55)
store i32 %56, i32* %7
%57 = load i8**, i8*** %13
%58 = getelementptr inbounds i8*, i8** %57, i64 6
%59 = load i8*, i8** %58
%60 = call i32 @atoi(i8* %59)
store i32 %60, i32* %9
%61 = load i32, i32* %7
%62 = load i32, i32* %8
%63 = load i32, i32* %9
%64 = load i32, i32* %6
%65 = call double @SNPHWE_pValue(i32 %61, i32 %62, i32 %63, i32 %64)
store double %65, double* %10
%66 = load i8**, i8*** %13
%67 = getelementptr inbounds i8*, i8** %66, i64 0
%68 = load i8*, i8** %67
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %68)
store i32 1, i32* %11
br label %70
70: ; preds = %80, %48
%71 = load i32, i32* %11
%72 = icmp slt i32 %71, 7
br i1 %72, label %73, label %83
73: ; preds = %70
%74 = load i8**, i8*** %13
%75 = load i32, i32* %11
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8*, i8** %74, i64 %76
%78 = load i8*, i8** %77
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %78)
br label %80
80: ; preds = %73
%81 = load i32, i32* %11
%82 = add nsw i32 %81, 1
store i32 %82, i32* %11
br label %70
83: ; preds = %70
%84 = load double, double* %10
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %84)
br label %25
86: ; preds = %25
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"\09%s\00"
@.str.2 = [5 x i8] c"\09%f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [5120 x i8]
%4 = alloca i8
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
br label %10
10: ; preds = %6, %2
%11 = phi i32 [ %9, %6 ], [ 1, %2 ]
%12 = getelementptr inbounds [5120 x i8], [5120 x i8]* %3, i64 0, i64 0
store i8 9, i8* %4
%13 = load i32, i32* @stdin
%14 = call i64 @fgets(i8* %12, i32 5120, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %56, label %16
16: ; preds = %10, %24
%17 = call i32 @pq_countcols(i8* %12, i8* %4)
%18 = call i8** @calloc(i32 %17, i32 8)
%19 = call i32 @pq_str2array(i8** %18, i8* %12, i32 %17, i8* %4)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = call i32 @free(i8** %18)
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %16
%25 = getelementptr inbounds i8*, i8** %18, i64 4
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
%28 = getelementptr inbounds i8*, i8** %18, i64 5
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
%31 = getelementptr inbounds i8*, i8** %18, i64 6
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
%34 = call double @SNPHWE_pValue(i32 %30, i32 %27, i32 %33, i32 %11)
%35 = load i8*, i8** %18
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %35)
%37 = getelementptr inbounds i8*, i8** %18, i64 1
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %38)
%40 = getelementptr inbounds i8*, i8** %18, i64 2
%41 = load i8*, i8** %40
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %41)
%43 = getelementptr inbounds i8*, i8** %18, i64 3
%44 = load i8*, i8** %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %44)
%46 = load i8*, i8** %25
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %46)
%48 = load i8*, i8** %28
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %48)
%50 = load i8*, i8** %31
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %50)
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %34)
%53 = load i32, i32* @stdin
%54 = call i64 @fgets(i8* %12, i32 5120, i32 %53)
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %16
56: ; preds = %24, %10
ret i32 0
}