#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 uint32_t;
typedef scalar_t__ int32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ atoi(char *);
double binom_1sided(scalar_t__, scalar_t__, double);
double binom_2sided(scalar_t__, scalar_t__, double, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *, scalar_t__ *,
                          scalar_t__ *, double *);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, double *);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  uint32_t midp = 0;
  FILE *test_file;
  int32_t succ;
  int32_t obs;
  double rate;
  double p_value;
  char name[100];
  if (!strcmp(argv[argc - 1], "midp")) {
    midp = 1;
    argc--;
  }
  if ((argc == 4) || (argc == 5)) {
    succ = atoi(argv[1]);
    obs = atoi(argv[2]);
    if (sscanf(argv[3], "%lg", &rate) != 1) {
      printf("Error: Invalid expected success rate '%s'.\n", argv[3]);
      return 3;
    }
    if ((succ < 0) || (obs < 0) || (rate < 0)) {
      printf("Error: Negative parameter.\n");
      return 3;
    } else if (succ > obs) {
      printf("Error: # successes > # observations.\n");
      return 3;
    } else if ((rate == 0) || (rate >= 1)) {
      printf("Error: Invalid expected success rate '%s'.\n", argv[3]);
      return 3;
    }
    if (argc == 4) {
      p_value = binom_2sided(succ, obs, rate, midp);
    } else {
      if (argv[4][1] || ((argv[4][0] != '+') && (argv[4][0] != '-'))) {
        printf("Error: Invalid alternative hypothesis ('+' = more successes, "
               "'-' = fewer)\n");
        return 3;
      }
      if (midp) {
        printf("Error: 1-sided demo does not currently support mid-p "
               "adjustment.\n");
        return 3;
      }
      if (argv[4][0] == '+') {
        p_value = binom_1sided(obs - succ, obs, 1 - rate);
      } else {
        p_value = binom_1sided(succ, obs, rate);
      }
    }
    printf("P-value: %g\n", p_value);
    return 0;
  } else if (argc != 2) {
    printf(
        "Binomial test    https://github.com/chrchang/stats\n"
        "(C) 2013 Christopher Chang, GNU General Public License version 3\n\n"
        "  binom_test [success ct] [total obs ct] [expected succ rate] <+ | - "
        "| midp>\n"
        "  binom_test [filename]\n\n"
        "If a filename is provided, each line of the file is expected to "
        "contain an ID\n"
        "in the first column, and then 3 values (in succ-obs-rate order).\n");
    return 1;
  }
  test_file = fopen(argv[1], "r");
  if (!test_file) {
    printf("Error: Unable to open file.\n");
    return 2;
  }
  while (!feof(test_file)) {
    fscanf(test_file, "%s %d %d %lg\n", name, &succ, &obs, &rate);
    p_value = binom_2sided(succ, obs, rate, midp);
    printf("P-value for %s: %g\n", name, p_value);
  }
  fclose(test_file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe30(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    11f6 <main+0x56>
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     120a <main+0x6a>
cmpl   $0x5,-0x8(%rbp)
jne    1450 <main+0x2b0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <atoi@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10c0 <atoi@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xdd2(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
je     126f <main+0xcf>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1545 <main+0x3a5>
cmpq   $0x0,-0x28(%rbp)
jl     1293 <main+0xf3>
cmpq   $0x0,-0x30(%rbp)
jl     1293 <main+0xf3>
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    12ad <main+0x10d>
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1545 <main+0x3a5>
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jle    12d5 <main+0x135>
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1545 <main+0x3a5>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12f2 <main+0x152>
jp     12f2 <main+0x152>
jmp    1309 <main+0x169>
movsd  -0x38(%rbp),%xmm0
movsd  0xd01(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     132b <main+0x18b>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xcf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1545 <main+0x3a5>
jmp    1330 <main+0x190>
jmp    1335 <main+0x195>
cmpl   $0x4,-0x8(%rbp)
jne    135e <main+0x1be>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
movsd  -0x38(%rbp),%xmm0
mov    -0x14(%rbp),%edx
call   1060 <binom_2sided@plt>
movsd  %xmm0,-0x40(%rbp)
jmp    1431 <main+0x291>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    139b <main+0x1fb>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
je     13b5 <main+0x215>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     13b5 <main+0x215>
lea    0xcdd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1545 <main+0x3a5>
cmpl   $0x0,-0x14(%rbp)
je     13d9 <main+0x239>
lea    0xd04(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1545 <main+0x3a5>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    1415 <main+0x275>
mov    -0x30(%rbp),%rdi
sub    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
movsd  0xbff(%rip),%xmm0
subsd  -0x38(%rbp),%xmm0
call   1050 <binom_1sided@plt>
movsd  %xmm0,-0x40(%rbp)
jmp    142c <main+0x28c>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
movsd  -0x38(%rbp),%xmm0
call   1050 <binom_1sided@plt>
movsd  %xmm0,-0x40(%rbp)
jmp    1431 <main+0x291>
movsd  -0x40(%rbp),%xmm0
lea    0xccf(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1545 <main+0x3a5>
cmpl   $0x2,-0x8(%rbp)
je     1474 <main+0x2d4>
lea    0xcb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1545 <main+0x3a5>
jmp    1479 <main+0x2d9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdfc(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    14b6 <main+0x316>
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1545 <main+0x3a5>
jmp    14bb <main+0x31b>
mov    -0x20(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    14d9 <main+0x339>
jmp    1535 <main+0x395>
mov    -0x20(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
lea    0xdb8(%rip),%rsi
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
lea    -0x38(%rbp),%r9
call   1070 <fscanf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
movsd  -0x38(%rbp),%xmm0
mov    -0x14(%rbp),%edx
call   1060 <binom_2sided@plt>
movsd  %xmm0,-0x40(%rbp)
lea    -0xb0(%rbp),%rsi
movsd  -0x40(%rbp),%xmm0
lea    0xd88(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    14bb <main+0x31b>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movslq %edi,%r15
add    $0xffffffff,%ebp
mov    -0x8(%rsi,%r15,8),%rdi
lea    0xe30(%rip),%rsi
call   1090 <strcmp@plt>
mov    %eax,%r14d
xor    %r13d,%r13d
test   %eax,%eax
sete   %r13b
cmove  %ebp,%r15d
mov    %r15d,%eax
and    $0xfffffffe,%eax
cmp    $0x4,%eax
jne    126c <main+0xbc>
mov    0x8(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %rax,%r12
mov    0x10(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %rax,%rbp
mov    0x18(%rbx),%rdi
lea    0xdf2(%rip),%rsi
lea    0x8(%rsp),%rdx
call   10b0 <sscanf@plt>
cmp    $0x1,%eax
jne    138b <main+0x1db>
test   %r12,%r12
js     1330 <main+0x180>
test   %rbp,%rbp
js     1330 <main+0x180>
movsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1330 <main+0x180>
mov    %rbp,%rdi
sub    %r12,%rdi
jae    1351 <main+0x1a1>
lea    0x1018(%rip),%rdi
jmp    1337 <main+0x187>
cmp    $0x2,%r15d
jne    131d <main+0x16d>
mov    0x8(%rbx),%rdi
lea    0xdc9(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     133e <main+0x18e>
mov    %rax,%rbx
mov    %rax,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
jne    130e <main+0x15e>
lea    0x20(%rsp),%r15
lea    0x10(%rsp),%rbp
lea    0x8(%rsp),%r14
lea    0xda6(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
lea    0xd82(%rip),%rsi
mov    %r15,%rdx
lea    0x18(%rsp),%rcx
mov    %rbp,%r8
mov    %r14,%r9
call   1080 <fscanf@plt>
mov    0x18(%rsp),%rdi
mov    0x10(%rsp),%rsi
movsd  0x8(%rsp),%xmm0
mov    %r13d,%edx
call   1070 <binom_2sided@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
je     12c0 <main+0x110>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    13a2 <main+0x1f2>
lea    0xd66(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    13a2 <main+0x1f2>
lea    0xf6d(%rip),%rdi
call   1030 <puts@plt>
jmp    139d <main+0x1ed>
lea    0xd29(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%eax
jmp    13a2 <main+0x1f2>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    135d <main+0x1ad>
jnp    138b <main+0x1db>
ucomisd 0xc9b(%rip),%xmm0
jae    138b <main+0x1db>
cmp    $0x4,%r15d
jne    13b4 <main+0x204>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r13d,%edx
call   1070 <binom_2sided@plt>
lea    0xcbb(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    1316 <main+0x166>
mov    0x18(%rbx),%rsi
lea    0xc7b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x3,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x20(%rbx),%rax
cmpb   $0x0,0x1(%rax)
je     13ca <main+0x21a>
lea    0xe70(%rip),%rdi
jmp    1337 <main+0x187>
mov    (%rax),%al
cmp    $0x2b,%al
je     13d4 <main+0x224>
cmp    $0x2d,%al
jne    13be <main+0x20e>
test   %r14d,%r14d
je     13f2 <main+0x242>
cmp    $0x2b,%al
jne    13fe <main+0x24e>
movsd  0xc1b(%rip),%xmm1
subsd  %xmm0,%xmm1
mov    %rbp,%rsi
movapd %xmm1,%xmm0
jmp    1404 <main+0x254>
lea    0xdfb(%rip),%rdi
jmp    1337 <main+0x187>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1060 <binom_1sided@plt>
jmp    137b <main+0x1cb>

LLVM IR (-O0):
@.str = [5 x i8] c"midp\00"
@.str.1 = [4 x i8] c"%lg\00"
@.str.2 = [44 x i8] c"Error: Invalid expected success rate '%s'.\0A\00"
@.str.3 = [28 x i8] c"Error: Negative parameter.\0A\00"
@.str.4 = [38 x i8] c"Error: # successes > # observations.\0A\00"
@.str.5 = [75 x i8] c"Error: Invalid alternative hypothesis ('+' = more successes, '-' = fewer)\0A\00"
@.str.6 = [66 x i8] c"Error: 1-sided demo does not currently support mid-p adjustment.\0A\00"
@.str.7 = [13 x i8] c"P-value: %g\0A\00"
@.str.8 = [363 x i8] c"Binomial test https://github.com/chrchang/stats\0A(C) 2013 Christopher Chang, GNU General Public License version 3\0A\0A binom_test [success ct] [total obs ct] [expected succ rate] <+ | - | midp>\0A binom_test [filename]\0A\0AIf a filename is provided, each line of the file is expected to contain an ID\0Ain the first column, and then 3 values (in succ-obs-rate order).\0A\00"
@.str.9 = [2 x i8] c"r\00"
@.str.10 = [29 x i8] c"Error: Unable to open file.\0A\00"
@.str.11 = [14 x i8] c"%s %d %d %lg\0A\00"
@.str.12 = [20 x i8] c"P-value for %s: %g\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 i64
%9 = alloca i64
%10 = alloca double
%11 = alloca double
%12 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%13 = load i8**, i8*** %5
%14 = load i32, i32* %4
%15 = sub nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %13, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %2
store i32 1, i32* %6
%22 = load i32, i32* %4
%23 = add nsw i32 %22, -1
store i32 %23, i32* %4
br label %24
24: ; preds = %21, %2
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 4
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 5
br i1 %29, label %30, label %144
30: ; preds = %27, %24
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i64 @atoi(i8* %33)
store i64 %34, i64* %8
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i64 @atoi(i8* %37)
store i64 %38, i64* %9
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 3
%41 = load i8*, i8** %40
%42 = call i32 @sscanf(i8* %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %10)
%43 = icmp ne i32 %42, 1
br i1 %43, label %44, label %49
44: ; preds = %30
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 3
%47 = load i8*, i8** %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %47)
store i32 3, i32* %3
br label %180
49: ; preds = %30
%50 = load i64, i64* %8
%51 = icmp slt i64 %50, 0
br i1 %51, label %58, label %52
52: ; preds = %49
%53 = load i64, i64* %9
%54 = icmp slt i64 %53, 0
br i1 %54, label %58, label %55
55: ; preds = %52
%56 = load double, double* %10
%57 = fcmp olt double %56, 0.000000e+00
br i1 %57, label %58, label %60
58: ; preds = %55, %52, %49
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
store i32 3, i32* %3
br label %180
60: ; preds = %55
%61 = load i64, i64* %8
%62 = load i64, i64* %9
%63 = icmp sgt i64 %61, %62
br i1 %63, label %64, label %66
64: ; preds = %60
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
store i32 3, i32* %3
br label %180
66: ; preds = %60
%67 = load double, double* %10
%68 = fcmp oeq double %67, 0.000000e+00
br i1 %68, label %72, label %69
69: ; preds = %66
%70 = load double, double* %10
%71 = fcmp oge double %70, 1.000000e+00
br i1 %71, label %72, label %77
72: ; preds = %69, %66
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 3
%75 = load i8*, i8** %74
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %75)
store i32 3, i32* %3
br label %180
77: ; preds = %69
br label %78
78: ; preds = %77
br label %79
79: ; preds = %78
%80 = load i32, i32* %4
%81 = icmp eq i32 %80, 4
br i1 %81, label %82, label %88
82: ; preds = %79
%83 = load i64, i64* %8
%84 = load i64, i64* %9
%85 = load double, double* %10
%86 = load i32, i32* %6
%87 = call double @binom_2sided(i64 %83, i64 %84, double %85, i32 %86)
store double %87, double* %11
br label %141
88: ; preds = %79
%89 = load i8**, i8*** %5
%90 = getelementptr inbounds i8*, i8** %89, i64 4
%91 = load i8*, i8** %90
%92 = getelementptr inbounds i8, i8* %91, i64 1
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp ne i32 %94, 0
br i1 %95, label %112, label %96
96: ; preds = %88
%97 = load i8**, i8*** %5
%98 = getelementptr inbounds i8*, i8** %97, i64 4
%99 = load i8*, i8** %98
%100 = getelementptr inbounds i8, i8* %99, i64 0
%101 = load i8, i8* %100
%102 = sext i8 %101 to i32
%103 = icmp ne i32 %102, 43
br i1 %103, label %104, label %114
104: ; preds = %96
%105 = load i8**, i8*** %5
%106 = getelementptr inbounds i8*, i8** %105, i64 4
%107 = load i8*, i8** %106
%108 = getelementptr inbounds i8, i8* %107, i64 0
%109 = load i8, i8* %108
%110 = sext i8 %109 to i32
%111 = icmp ne i32 %110, 45
br i1 %111, label %112, label %114
112: ; preds = %104, %88
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.5, i64 0, i64 0))
store i32 3, i32* %3
br label %180
114: ; preds = %104, %96
%115 = load i32, i32* %6
%116 = icmp ne i32 %115, 0
br i1 %116, label %117, label %119
117: ; preds = %114
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.6, i64 0, i64 0))
store i32 3, i32* %3
br label %180
119: ; preds = %114
%120 = load i8**, i8*** %5
%121 = getelementptr inbounds i8*, i8** %120, i64 4
%122 = load i8*, i8** %121
%123 = getelementptr inbounds i8, i8* %122, i64 0
%124 = load i8, i8* %123
%125 = sext i8 %124 to i32
%126 = icmp eq i32 %125, 43
br i1 %126, label %127, label %135
127: ; preds = %119
%128 = load i64, i64* %9
%129 = load i64, i64* %8
%130 = sub nsw i64 %128, %129
%131 = load i64, i64* %9
%132 = load double, double* %10
%133 = fsub double 1.000000e+00, %132
%134 = call double @binom_1sided(i64 %130, i64 %131, double %133)
store double %134, double* %11
br label %140
135: ; preds = %119
%136 = load i64, i64* %8
%137 = load i64, i64* %9
%138 = load double, double* %10
%139 = call double @binom_1sided(i64 %136, i64 %137, double %138)
store double %139, double* %11
br label %140
140: ; preds = %135, %127
br label %141
141: ; preds = %140, %82
%142 = load double, double* %11
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), double %142)
store i32 0, i32* %3
br label %180
144: ; preds = %27
%145 = load i32, i32* %4
%146 = icmp ne i32 %145, 2
br i1 %146, label %147, label %149
147: ; preds = %144
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([363 x i8], [363 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
br label %180
149: ; preds = %144
br label %150
150: ; preds = %149
%151 = load i8**, i8*** %5
%152 = getelementptr inbounds i8*, i8** %151, i64 1
%153 = load i8*, i8** %152
%154 = call i32* @fopen(i8* %153, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %154, i32** %7
%155 = load i32*, i32** %7
%156 = icmp ne i32* %155, null
br i1 %156, label %159, label %157
157: ; preds = %150
%158 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
store i32 2, i32* %3
br label %180
159: ; preds = %150
br label %160
160: ; preds = %165, %159
%161 = load i32*, i32** %7
%162 = call i32 @feof(i32* %161)
%163 = icmp ne i32 %162, 0
%164 = xor i1 %163, true
br i1 %164, label %165, label %177
165: ; preds = %160
%166 = load i32*, i32** %7
%167 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%168 = call i32 @fscanf(i32* %166, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* %167, i64* %8, i64* %9, double* %10)
%169 = load i64, i64* %8
%170 = load i64, i64* %9
%171 = load double, double* %10
%172 = load i32, i32* %6
%173 = call double @binom_2sided(i64 %169, i64 %170, double %171, i32 %172)
store double %173, double* %11
%174 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%175 = load double, double* %11
%176 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* %174, double %175)
br label %160
177: ; preds = %160
%178 = load i32*, i32** %7
%179 = call i32 @fclose(i32* %178)
store i32 0, i32* %3
br label %180
180: ; preds = %177, %157, %147, %141, %117, %112, %72, %64, %58, %44
%181 = load i32, i32* %3
ret i32 %181
}

LLVM IR (-O2):
@.str = [5 x i8] c"midp\00"
@.str.1 = [4 x i8] c"%lg\00"
@.str.2 = [44 x i8] c"Error: Invalid expected success rate '%s'.\0A\00"
@.str.7 = [13 x i8] c"P-value: %g\0A\00"
@.str.9 = [2 x i8] c"r\00"
@.str.11 = [14 x i8] c"%s %d %d %lg\0A\00"
@.str.12 = [20 x i8] c"P-value for %s: %g\0A\00"
@str = [28 x i8] c"Error: Unable to open file.\00"
@str.13 = [362 x i8] c"Binomial test https://github.com/chrchang/stats\0A(C) 2013 Christopher Chang, GNU General Public License version 3\0A\0A binom_test [success ct] [total obs ct] [expected succ rate] <+ | - | midp>\0A binom_test [filename]\0A\0AIf a filename is provided, each line of the file is expected to contain an ID\0Ain the first column, and then 3 values (in succ-obs-rate order).\00"
@str.14 = [65 x i8] c"Error: 1-sided demo does not currently support mid-p adjustment.\00"
@str.15 = [74 x i8] c"Error: Invalid alternative hypothesis ('+' = more successes, '-' = fewer)\00"
@str.16 = [37 x i8] c"Error: # successes > # observations.\00"
@str.17 = [27 x i8] c"Error: Negative parameter.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca double
%6 = alloca [100 x i8]
%7 = bitcast i64* %3 to i8*
%8 = bitcast i64* %4 to i8*
%9 = bitcast double* %5 to i8*
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%11 = add nsw i32 %0, -1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %14, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
%17 = select i1 %16, i32 %11, i32 %0
%18 = zext i1 %16 to i32
%19 = icmp eq i32 %17, 4
%20 = and i32 %17, -2
%21 = icmp eq i32 %20, 4
br i1 %21, label %22, label %83
22: ; preds = %2
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = tail call i64 @atoi(i8* %24)
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = tail call i64 @atoi(i8* %27)
%29 = getelementptr inbounds i8*, i8** %1, i64 3
%30 = load i8*, i8** %29
%31 = call i32 @sscanf(i8* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %5)
%32 = icmp eq i32 %31, 1
br i1 %32, label %36, label %33
33: ; preds = %22
%34 = load i8*, i8** %29
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %34)
br label %108
36: ; preds = %22
%37 = icmp slt i64 %25, 0
%38 = icmp slt i64 %28, 0
%39 = select i1 %37, i1 true, i1 %38
%40 = load double, double* %5
%41 = fcmp olt double %40, 0.000000e+00
%42 = select i1 %39, i1 true, i1 %41
br i1 %42, label %43, label %45
43: ; preds = %36
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.17, i64 0, i64 0))
br label %108
45: ; preds = %36
%46 = icmp ult i64 %28, %25
br i1 %46, label %47, label %49
47: ; preds = %45
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.16, i64 0, i64 0))
br label %108
49: ; preds = %45
%50 = fcmp oeq double %40, 0.000000e+00
%51 = fcmp oge double %40, 1.000000e+00
%52 = or i1 %50, %51
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = load i8*, i8** %29
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %54)
br label %108
56: ; preds = %49
br i1 %19, label %57, label %59
57: ; preds = %56
%58 = call double @binom_2sided(i64 %25, i64 %28, double %40, i32 %18)
br label %80
59: ; preds = %56
%60 = getelementptr inbounds i8*, i8** %1, i64 4
%61 = load i8*, i8** %60
%62 = getelementptr inbounds i8, i8* %61, i64 1
%63 = load i8, i8* %62
%64 = icmp eq i8 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %59
%66 = load i8, i8* %61
switch i8 %66, label %67 [
i8 43, label %69
i8 45, label %69
]
67: ; preds = %65, %59
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str.15, i64 0, i64 0))
br label %108
69: ; preds = %65, %65
br i1 %16, label %70, label %72
70: ; preds = %69
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str.14, i64 0, i64 0))
br label %108
72: ; preds = %69
%73 = icmp eq i8 %66, 43
br i1 %73, label %74, label %78
74: ; preds = %72
%75 = sub nsw i64 %28, %25
%76 = fsub double 1.000000e+00, %40
%77 = call double @binom_1sided(i64 %75, i64 %28, double %76)
br label %80
78: ; preds = %72
%79 = call double @binom_1sided(i64 %25, i64 %28, double %40)
br label %80
80: ; preds = %74, %78, %57
%81 = phi double [ %58, %57 ], [ %77, %74 ], [ %79, %78 ]
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), double %81)
br label %108
83: ; preds = %2
%84 = icmp eq i32 %17, 2
br i1 %84, label %87, label %85
85: ; preds = %83
%86 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([362 x i8], [362 x i8]* @str.13, i64 0, i64 0))
br label %108
87: ; preds = %83
%88 = getelementptr inbounds i8*, i8** %1, i64 1
%89 = load i8*, i8** %88
%90 = tail call i32* @fopen(i8* %89, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%91 = icmp eq i32* %90, null
br i1 %91, label %95, label %92
92: ; preds = %87
%93 = call i32 @feof(i32* %90)
%94 = icmp eq i32 %93, 0
br i1 %94, label %97, label %106
95: ; preds = %87
%96 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %108
97: ; preds = %92, %97
%98 = call i32 @fscanf(i32* %90, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* %10, i64* %3, i64* %4, double* %5)
%99 = load i64, i64* %3
%100 = load i64, i64* %4
%101 = load double, double* %5
%102 = call double @binom_2sided(i64 %99, i64 %100, double %101, i32 %18)
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* %10, double %102)
%104 = call i32 @feof(i32* %90)
%105 = icmp eq i32 %104, 0
br i1 %105, label %97, label %106
106: ; preds = %97, %92
%107 = call i32 @fclose(i32* %90)
br label %108
108: ; preds = %106, %95, %85, %80, %70, %67, %53, %47, %43, %33
%109 = phi i32 [ 3, %33 ], [ 3, %43 ], [ 3, %47 ], [ 3, %53 ], [ 0, %80 ], [ 3, %67 ], [ 3, %70 ], [ 1, %85 ], [ 0, %106 ], [ 2, %95 ]
ret i32 %109
}