#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*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
char *malloc(int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int countNodeInFile(char *strFileNode) {
  FILE *pFile = NULL;
  char *strLine, *strOldLine;
  int iNbNode = 0;
  pFile = fopen(strFileNode, "r");
  if (pFile != NULL) {
    strLine = malloc(sizeof(char) * 256);
    strOldLine = malloc(sizeof(char) * 256);
    while (fscanf(pFile, "%s", strLine) > 0) {
      if (strlen(strLine) > 1) {
        if (strcmp(strLine, strOldLine) != 0) {
          iNbNode++;
        }
        strcpy(strOldLine, strLine);
      }
    }
    free(strLine);
    free(strOldLine);
    fclose(pFile);
  }
  return iNbNode;
}


x86 assembly (clang, -O0):
<countNodeInFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1253 <countNodeInFile+0xd3>
mov    $0x100,%edi
call   1090 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x100,%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe1d(%rip),%rsi
call   1070 <fscanf@plt>
cmp    $0x0,%rax
jle    1238 <countNodeInFile+0xb8>
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x1,%eax
jle    1233 <countNodeInFile+0xb3>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1226 <countNodeInFile+0xa6>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    11d6 <countNodeInFile+0x56>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<countNodeInFile>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xe71(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1239 <countNodeInFile+0xb9>
mov    %rax,%r14
mov    $0x100,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    $0x100,%edi
call   1090 <malloc@plt>
mov    %rax,%r15
lea    0xe41(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1070 <fscanf@plt>
xor    %ebp,%ebp
test   %rax,%rax
jle    121f <countNodeInFile+0x9f>
lea    0xe28(%rip),%r12
jmp    11f3 <countNodeInFile+0x73>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1070 <fscanf@plt>
test   %rax,%rax
jle    121f <countNodeInFile+0x9f>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cmp    $0x2,%eax
jl     11e0 <countNodeInFile+0x60>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strcmp@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
jmp    11e0 <countNodeInFile+0x60>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
jmp    123b <countNodeInFile+0xbb>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @countNodeInFile(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %28, label %4
4: ; preds = %1
%5 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%6 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%7 = tail call i64 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %23
9: ; preds = %4, %19
%10 = phi i32 [ %20, %19 ], [ 0, %4 ]
%11 = tail call i32 @strlen(i8* %5)
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = tail call i64 @strcmp(i8* %5, i8* %6)
%15 = icmp ne i64 %14, 0
%16 = zext i1 %15 to i32
%17 = add nsw i32 %10, %16
%18 = tail call i32 @strcpy(i8* %6, i8* %5)
br label %19
19: ; preds = %13, %9
%20 = phi i32 [ %17, %13 ], [ %10, %9 ]
%21 = tail call i64 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%22 = icmp sgt i64 %21, 0
br i1 %22, label %9, label %23
23: ; preds = %19, %4
%24 = phi i32 [ 0, %4 ], [ %20, %19 ]
%25 = tail call i32 @free(i8* %5)
%26 = tail call i32 @free(i8* %6)
%27 = tail call i32 @fclose(i32* %2)
br label %28
28: ; preds = %23, %1
%29 = phi i32 [ %24, %23 ], [ 0, %1 ]
ret i32 %29
}