#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 */
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
int has_diff_genotype(char *line, int start_colN, char *refBase) {
  int isDiff = 0;
  char *part;
  part = strtok(line, "\t");
  int i = 0;
  while (part != NULL) {
    if (i < start_colN || strcmp(part, "N") == 0) {
      ;
    } else if (strcmp(refBase, "N") == 0) {
      strcpy(refBase, part);
    } else if (strcmp(refBase, part) != 0) {
      isDiff = 1;
      break;
    }
    i++;
    part = strtok(NULL, "\t");
  }
  return isDiff;
}


x86 assembly (clang, -O0):
<has_diff_genotype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1216 <has_diff_genotype+0xe6>
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     1196 <has_diff_genotype+0x66>
mov    -0x28(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    119b <has_diff_genotype+0x6b>
jmp    11f4 <has_diff_genotype+0xc4>
mov    -0x18(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c7 <has_diff_genotype+0x97>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11ef <has_diff_genotype+0xbf>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11ea <has_diff_genotype+0xba>
movl   $0x1,-0x1c(%rbp)
jmp    1216 <has_diff_genotype+0xe6>
jmp    11ef <has_diff_genotype+0xbf>
jmp    11f4 <has_diff_genotype+0xc4>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdf8(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    1165 <has_diff_genotype+0x35>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_diff_genotype>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %esi,%r13d
lea    0xeb8(%rip),%rsi
call   1050 <strtok@plt>
test   %rax,%rax
je     11cc <has_diff_genotype+0x9c>
mov    %rax,%rbx
xor    %r15d,%r15d
lea    0xea1(%rip),%r14
jmp    1188 <has_diff_genotype+0x58>
call   1030 <strcpy@plt>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r15d
xor    %ebp,%ebp
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11ce <has_diff_genotype+0x9e>
cmp    %r13d,%r15d
jl     1170 <has_diff_genotype+0x40>
mov    %rbx,%rdi
lea    0xe6b(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1170 <has_diff_genotype+0x40>
mov    %r12,%rdi
lea    0xe57(%rip),%rsi
call   1040 <strcmp@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
test   %rax,%rax
je     1161 <has_diff_genotype+0x31>
call   1040 <strcmp@plt>
test   %rax,%rax
je     1170 <has_diff_genotype+0x40>
mov    $0x1,%ebp
jmp    11ce <has_diff_genotype+0x9e>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\09\00"
@.str.1 = [2 x i8] c"N\00"
define i32 @has_diff_genotype(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 0, i32* %7
%10 = load i8*, i8** %4
%11 = call i8* @strtok(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %8
store i32 0, i32* %9
br label %12
12: ; preds = %40, %3
%13 = load i8*, i8** %8
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %44
15: ; preds = %12
%16 = load i32, i32* %9
%17 = load i32, i32* %5
%18 = icmp slt i32 %16, %17
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load i8*, i8** %8
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19, %15
br label %40
24: ; preds = %19
%25 = load i8*, i8** %6
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i8*, i8** %6
%30 = load i8*, i8** %8
%31 = call i32 @strcpy(i8* %29, i8* %30)
br label %39
32: ; preds = %24
%33 = load i8*, i8** %6
%34 = load i8*, i8** %8
%35 = call i64 @strcmp(i8* %33, i8* %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %32
store i32 1, i32* %7
br label %44
38: ; preds = %32
br label %39
39: ; preds = %38, %28
br label %40
40: ; preds = %39, %23
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 1
store i32 %42, i32* %9
%43 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %43, i8** %8
br label %12
44: ; preds = %37, %12
%45 = load i32, i32* %7
ret i32 %45
}

LLVM IR (-O2):
@.str = [2 x i8] c"\09\00"
@.str.1 = [2 x i8] c"N\00"
define i32 @has_diff_genotype(i8* %0, i32 %1, i8* %2) {
%4 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %25, label %6
6: ; preds = %3, %21
%7 = phi i32 [ %22, %21 ], [ 0, %3 ]
%8 = phi i8* [ %23, %21 ], [ %4, %3 ]
%9 = icmp slt i32 %7, %1
br i1 %9, label %21, label %10
10: ; preds = %6
%11 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %21, label %13
13: ; preds = %10
%14 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @strcpy(i8* %2, i8* %8)
br label %21
18: ; preds = %13
%19 = tail call i64 @strcmp(i8* %2, i8* %8)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %16, %18, %6, %10
%22 = add nuw nsw i32 %7, 1
%23 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %6
25: ; preds = %21, %18, %3
%26 = phi i32 [ 0, %3 ], [ 1, %18 ], [ 0, %21 ]
ret i32 %26
}