#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 */
int /*<<< orphan*/ my_err(char *, char *, int, ...);
scalar_t__ strcmp(char *, char *);
char *strsep(char **, char *);
void impute_parse_haplotypes(char *haplotypes, char *cur, long n_sample) {
  long expect_n, i;
  char *tok;
  char delim[] = " \t";
  expect_n = n_sample * 2;
  i = 0;
  while ((tok = strsep(&cur, delim)) != NULL) {
    if (i >= expect_n) {
      my_err("%s:%d: more haplotype values per row than expected (%ld)."
             " Current token: '%s'",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/"
             "snp2h5/impute.c",
             77, expect_n, tok);
    }
    if (strcmp(tok, "0") == 0) {
      haplotypes[i] = 0;
    } else if (strcmp(tok, "1") == 0) {
      haplotypes[i] = 1;
    } else {
      my_err("%s:%d: expected haplotype values to be either 0 or 1 but got "
             "%s",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/"
             "snp2h5/impute.c",
             89, tok);
    }
    i++;
  }
  if (i != expect_n) {
    my_err("%s:%d: fewer haplotype values (%ld) per row than expected (%ld)",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/snp2h5/"
           "impute.c",
           97, expect_n);
  }
}


x86 assembly (clang, -O0):
<impute_parse_haplotypes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0xeb5(%rip),%ax
mov    %ax,-0x33(%rbp)
mov    0xead(%rip),%al
mov    %al,-0x31(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0x33(%rbp),%rsi
lea    -0x10(%rbp),%rdi
call   1040 <strsep@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1241 <impute_parse_haplotypes+0x111>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jl     11b7 <impute_parse_haplotypes+0x87>
mov    -0x20(%rbp),%rcx
mov    -0x30(%rbp),%r8
lea    0xe5f(%rip),%rdi
lea    0xea6(%rip),%rsi
mov    $0x4d,%edx
mov    $0x0,%al
call   1050 <my_err@plt>
mov    -0x30(%rbp),%rdi
lea    0xf1a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11e2 <impute_parse_haplotypes+0xb2>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1230 <impute_parse_haplotypes+0x100>
mov    -0x30(%rbp),%rdi
lea    0xef1(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    120d <impute_parse_haplotypes+0xdd>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x1,(%rax,%rcx,1)
jmp    122b <impute_parse_haplotypes+0xfb>
mov    -0x30(%rbp),%rcx
lea    0xec8(%rip),%rdi
lea    0xe32(%rip),%rsi
mov    $0x59,%edx
mov    $0x0,%al
call   1050 <my_err@plt>
jmp    1230 <impute_parse_haplotypes+0x100>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    116c <impute_parse_haplotypes+0x3c>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     126d <impute_parse_haplotypes+0x13d>
mov    -0x20(%rbp),%rcx
lea    0xec6(%rip),%rdi
lea    0xdf0(%rip),%rsi
mov    $0x61,%edx
mov    $0x0,%al
call   1050 <my_err@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<impute_parse_haplotypes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
mov    %rdi,%r14
mov    %rsi,0x10(%rsp)
movb   $0x0,0xe(%rsp)
movw   $0x920,0xc(%rsp)
add    %rdx,%rbx
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1040 <strsep@plt>
test   %rax,%rax
je     122a <impute_parse_haplotypes+0xfa>
mov    %rax,%rbp
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
xor    %r15d,%r15d
jmp    11b0 <impute_parse_haplotypes+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movb   $0x0,(%r14,%r15,1)
add    $0x1,%r15
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <strsep@plt>
mov    %rax,%rbp
test   %rax,%rax
je     122d <impute_parse_haplotypes+0xfd>
cmp    %rbx,%r15
jl     11d5 <impute_parse_haplotypes+0xa5>
lea    0xe47(%rip),%rdi
lea    0xe8e(%rip),%rsi
mov    $0x4d,%edx
mov    %rbx,%rcx
mov    %rbp,%r8
xor    %eax,%eax
call   1050 <my_err@plt>
mov    %rbp,%rdi
lea    0xefd(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1190 <impute_parse_haplotypes+0x60>
mov    %rbp,%rdi
lea    0xeeb(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1220 <impute_parse_haplotypes+0xf0>
lea    0xedc(%rip),%rdi
lea    0xe46(%rip),%rsi
mov    $0x59,%edx
mov    %rbp,%rcx
xor    %eax,%eax
call   1050 <my_err@plt>
jmp    1195 <impute_parse_haplotypes+0x65>
nop
movb   $0x1,(%r14,%r15,1)
jmp    1195 <impute_parse_haplotypes+0x65>
xor    %r15d,%r15d
cmp    %rbx,%r15
je     124f <impute_parse_haplotypes+0x11f>
lea    0xee7(%rip),%rdi
lea    0xe11(%rip),%rsi
mov    $0x61,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <my_err@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.impute_parse_haplotypes.delim = [3 x i8] c" \09\00"
@.str = [78 x i8] c"%s:%d: more haplotype values per row than expected (%ld). Current token: '%s'\00"
@.str.1 = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/snp2h5/impute.c\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [64 x i8] c"%s:%d: expected haplotype values to be either 0 or 1 but got %s\00"
@.str.5 = [64 x i8] c"%s:%d: fewer haplotype values (%ld) per row than expected (%ld)\00"
define void @impute_parse_haplotypes(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca [3 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%11 = bitcast [3 x i8]* %10 to i8*
%12 = load i64, i64* %6
%13 = mul nsw i64 %12, 2
store i64 %13, i64* %7
store i64 0, i64* %8
br label %14
14: ; preds = %46, %3
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %10, i64 0, i64 0
%16 = call i8* @strsep(i8** %5, i8* %15)
store i8* %16, i8** %9
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %49
18: ; preds = %14
%19 = load i64, i64* %8
%20 = load i64, i64* %7
%21 = icmp sge i64 %19, %20
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i64, i64* %7
%24 = load i8*, i8** %9
%25 = call i32 (i8*, i8*, i32, ...) @my_err(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.1, i64 0, i64 0), i32 77, i64 %23, i8* %24)
br label %26
26: ; preds = %22, %18
%27 = load i8*, i8** %9
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load i8*, i8** %4
%32 = load i64, i64* %8
%33 = getelementptr inbounds i8, i8* %31, i64 %32
store i8 0, i8* %33
br label %46
34: ; preds = %26
%35 = load i8*, i8** %9
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load i8*, i8** %4
%40 = load i64, i64* %8
%41 = getelementptr inbounds i8, i8* %39, i64 %40
store i8 1, i8* %41
br label %45
42: ; preds = %34
%43 = load i8*, i8** %9
%44 = call i32 (i8*, i8*, i32, ...) @my_err(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.1, i64 0, i64 0), i32 89, i8* %43)
br label %45
45: ; preds = %42, %38
br label %46
46: ; preds = %45, %30
%47 = load i64, i64* %8
%48 = add nsw i64 %47, 1
store i64 %48, i64* %8
br label %14
49: ; preds = %14
%50 = load i64, i64* %8
%51 = load i64, i64* %7
%52 = icmp ne i64 %50, %51
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = load i64, i64* %7
%55 = call i32 (i8*, i8*, i32, ...) @my_err(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.1, i64 0, i64 0), i32 97, i64 %54)
br label %56
56: ; preds = %53, %49
ret void
}

LLVM IR (-O2):
@__const.impute_parse_haplotypes.delim = [3 x i8] c" \09\00"
@.str = [78 x i8] c"%s:%d: more haplotype values per row than expected (%ld). Current token: '%s'\00"
@.str.1 = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/snp2h5/impute.c\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [64 x i8] c"%s:%d: expected haplotype values to be either 0 or 1 but got %s\00"
@.str.5 = [64 x i8] c"%s:%d: fewer haplotype values (%ld) per row than expected (%ld)\00"
define void @impute_parse_haplotypes(i8* nocapture writeonly %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca [3 x i8]
store i8* %1, i8** %4
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%7 = shl nsw i64 %2, 1
%8 = call i8* @strsep(i8** %4, i8* %6)
%9 = icmp eq i8* %8, null
br i1 %9, label %32, label %10
10: ; preds = %3, %28
%11 = phi i8* [ %30, %28 ], [ %8, %3 ]
%12 = phi i64 [ %29, %28 ], [ 0, %3 ]
%13 = icmp slt i64 %12, %7
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = call i32 (i8*, i8*, i32, ...) @my_err(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.1, i64 0, i64 0), i32 77, i64 %7, i8* %11)
br label %16
16: ; preds = %14, %10
%17 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = getelementptr inbounds i8, i8* %0, i64 %12
store i8 0, i8* %20
br label %28
21: ; preds = %16
%22 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = getelementptr inbounds i8, i8* %0, i64 %12
store i8 1, i8* %25
br label %28
26: ; preds = %21
%27 = call i32 (i8*, i8*, i32, ...) @my_err(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.1, i64 0, i64 0), i32 89, i8* %11)
br label %28
28: ; preds = %24, %26, %19
%29 = add nuw nsw i64 %12, 1
%30 = call i8* @strsep(i8** %4, i8* %6)
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %10
32: ; preds = %28, %3
%33 = phi i64 [ 0, %3 ], [ %29, %28 ]
%34 = icmp eq i64 %33, %7
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = call i32 (i8*, i8*, i32, ...) @my_err(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.1, i64 0, i64 0), i32 97, i64 %7)
br label %37
37: ; preds = %35, %32
ret void
}