#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 */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen_read(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
int nb_ind_ancestrymap(char *input_file) {
  FILE *File = NULL;
  int max_char_per_line = 1000;
  int nb = 0, diff = 0;
  char szbuff[max_char_per_line];
  char *token;
  char tmp[512] = "";
  File = fopen_read(input_file);
  token = fgets(szbuff, max_char_per_line, File);
  token = strtok(szbuff, " \t\n");
  strcpy(tmp, token);
  while (!feof(File) && !diff) {
    token = fgets(szbuff, max_char_per_line, File);
    token = strtok(szbuff, " \t\n");
    diff = strcmp(tmp, token) != 0;
    nb++;
  }
  fclose(File);
  return nb;
}


x86 assembly (clang, -O0):
<nb_ind_ancestrymap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x3e8,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x248(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
lea    -0x240(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rdi
call   1090 <fopen_read@plt>
mov    -0x248(%rbp),%rdi
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1060 <fgets@plt>
mov    -0x248(%rbp),%rdi
mov    %rax,-0x38(%rbp)
lea    0xde6(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x38(%rbp)
lea    -0x240(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
call   1080 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x249(%rbp)
jne    125e <nb_ind_ancestrymap+0xde>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x249(%rbp)
mov    -0x249(%rbp),%al
test   $0x1,%al
jne    1271 <nb_ind_ancestrymap+0xf1>
jmp    12cc <nb_ind_ancestrymap+0x14c>
mov    -0x248(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1060 <fgets@plt>
mov    -0x248(%rbp),%rdi
mov    %rax,-0x38(%rbp)
lea    0xd6a(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x38(%rbp)
lea    -0x240(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1233 <nb_ind_ancestrymap+0xb3>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%eax
mov    -0x28(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nb_ind_ancestrymap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x5e8,%rsp
mov    %rdi,%rbp
mov    %rsp,%r15
xor    %ebx,%ebx
mov    $0x200,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rbp,%rdi
call   1090 <fopen_read@plt>
mov    %rax,%r14
lea    0x200(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x3e8,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
lea    0xe2e(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <strtok@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    124d <nb_ind_ancestrymap+0xcd>
xor    %ebx,%ebx
lea    0x200(%rsp),%r15
lea    0xdfe(%rip),%r12
mov    %rsp,%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    $0x3e8,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   10a0 <strtok@plt>
mov    %r13,%rdi
mov    %rax,%rsi
call   1070 <strcmp@plt>
mov    %rax,%rbp
add    $0x1,%ebx
mov    %r14,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    124d <nb_ind_ancestrymap+0xcd>
test   %rbp,%rbp
je     1210 <nb_ind_ancestrymap+0x90>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %ebx,%eax
add    $0x5e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c" \09\0A\00"
define i32 @nb_ind_ancestrymap(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca [512 x i8]
store i8* %0, i8** %2
store i32* null, i32** %3
store i32 1000, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%11 = load i32, i32* %4
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %7
%14 = alloca i8, i64 %12
store i64 %12, i64* %8
%15 = bitcast [512 x i8]* %10 to i8*
%16 = load i8*, i8** %2
%17 = call i32* @fopen_read(i8* %16)
store i32* %17, i32** %3
%18 = load i32, i32* %4
%19 = load i32*, i32** %3
%20 = call i8* @fgets(i8* %14, i32 %18, i32* %19)
store i8* %20, i8** %9
%21 = call i8* @strtok(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %21, i8** %9
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%23 = load i8*, i8** %9
%24 = call i32 @strcpy(i8* %22, i8* %23)
br label %25
25: ; preds = %35, %1
%26 = load i32*, i32** %3
%27 = call i32 @feof(i32* %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i32, i32* %6
%31 = icmp ne i32 %30, 0
%32 = xor i1 %31, true
br label %33
33: ; preds = %29, %25
%34 = phi i1 [ false, %25 ], [ %32, %29 ]
br i1 %34, label %35, label %47
35: ; preds = %33
%36 = load i32, i32* %4
%37 = load i32*, i32** %3
%38 = call i8* @fgets(i8* %14, i32 %36, i32* %37)
store i8* %38, i8** %9
%39 = call i8* @strtok(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %39, i8** %9
%40 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%41 = load i8*, i8** %9
%42 = call i64 @strcmp(i8* %40, i8* %41)
%43 = icmp ne i64 %42, 0
%44 = zext i1 %43 to i32
store i32 %44, i32* %6
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %25
47: ; preds = %33
%48 = load i32*, i32** %3
%49 = call i32 @fclose(i32* %48)
%50 = load i32, i32* %5
%51 = load i8*, i8** %7
ret i32 %50
}

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