#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 */
struct sNodeProperty {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ addNode(struct sNodeProperty **, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int checkMachineFile(char *machineFile, struct sNodeProperty **pListe) {
  FILE *fFile;
  char *strBuff;
  int iNbNode = 0;
  fFile = fopen(machineFile, "r");
  if (fFile != NULL) {
    strBuff = malloc(256);
    while (fscanf(fFile, "%s", strBuff) > 0) {
      iNbNode++;
      addNode(pListe, strBuff);
    }
    free(strBuff);
    fclose(fFile);
    if (iNbNode < 3) {
      printf("Must have at least 3 nodes !\n");
      return -1;
    }
    return 1;
  }
  printf("File %s does not exist !\n", machineFile);
  return 0;
}


x86 assembly (clang, -O0):
<checkMachineFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     122f <checkMachineFile+0xbf>
mov    $0x100,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe3f(%rip),%rsi
call   1060 <fscanf@plt>
cmp    $0x0,%rax
jle    11ed <checkMachineFile+0x7d>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <addNode@plt>
jmp    11b4 <checkMachineFile+0x44>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
cmpl   $0x3,-0x2c(%rbp)
jge    1223 <checkMachineFile+0xb3>
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1248 <checkMachineFile+0xd8>
movl   $0x1,-0x4(%rbp)
jmp    1248 <checkMachineFile+0xd8>
mov    -0x10(%rbp),%rsi
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkMachineFile>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe6b(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     121e <checkMachineFile+0x9e>
mov    %rax,%r15
mov    $0x100,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
lea    0xe4c(%rip),%rsi
mov    %r15,%rdi
mov    %rax,%rdx
call   1070 <fscanf@plt>
test   %rax,%rax
jle    1234 <checkMachineFile+0xb4>
mov    $0xffffffff,%ebp
lea    0xe30(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <addNode@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1070 <fscanf@plt>
add    $0x1,%ebp
test   %rax,%rax
jg     11e0 <checkMachineFile+0x60>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    $0x1,%r14d
cmp    $0x2,%ebp
jb     1244 <checkMachineFile+0xc4>
jmp    1256 <checkMachineFile+0xd6>
lea    0xde0(%rip),%rdi
xor    %r14d,%r14d
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1256 <checkMachineFile+0xd6>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
lea    0xdd4(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sNodeProperty = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [30 x i8] c"Must have at least 3 nodes !\0A\00"
@.str.3 = [26 x i8] c"File %s does not exist !\0A\00"
define i32 @checkMachineFile(i8* %0, %struct.sNodeProperty** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.sNodeProperty**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store %struct.sNodeProperty** %1, %struct.sNodeProperty*** %5
store i32 0, i32* %8
%9 = load i8*, i8** %4
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %6
%11 = load i32*, i32** %6
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %36
13: ; preds = %2
%14 = call i8* @malloc(i32 256)
store i8* %14, i8** %7
br label %15
15: ; preds = %20, %13
%16 = load i32*, i32** %6
%17 = load i8*, i8** %7
%18 = call i64 @fscanf(i32* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = icmp sgt i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %15
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
store i32 %22, i32* %8
%23 = load %struct.sNodeProperty**, %struct.sNodeProperty*** %5
%24 = load i8*, i8** %7
%25 = call i32 @addNode(%struct.sNodeProperty** %23, i8* %24)
br label %15
26: ; preds = %15
%27 = load i8*, i8** %7
%28 = call i32 @free(i8* %27)
%29 = load i32*, i32** %6
%30 = call i32 @fclose(i32* %29)
%31 = load i32, i32* %8
%32 = icmp slt i32 %31, 3
br i1 %32, label %33, label %35
33: ; preds = %26
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %39
35: ; preds = %26
store i32 1, i32* %3
br label %39
36: ; preds = %2
%37 = load i8*, i8** %4
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %37)
store i32 0, i32* %3
br label %39
39: ; preds = %36, %35, %33
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
%struct.sNodeProperty = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [26 x i8] c"File %s does not exist !\0A\00"
@str = [29 x i8] c"Must have at least 3 nodes !\00"
define i32 @checkMachineFile(i8* %0, %struct.sNodeProperty** %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %24, label %5
5: ; preds = %2
%6 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%7 = tail call i64 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %5, %9
%10 = phi i32 [ %11, %9 ], [ 0, %5 ]
%11 = add nuw nsw i32 %10, 1
%12 = tail call i32 @addNode(%struct.sNodeProperty** %1, i8* %6)
%13 = tail call i64 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%14 = icmp sgt i64 %13, 0
br i1 %14, label %9, label %15
15: ; preds = %9
%16 = icmp ult i32 %10, 2
%17 = tail call i32 @free(i8* %6)
%18 = tail call i32 @fclose(i32* %3)
br i1 %16, label %22, label %26
19: ; preds = %5
%20 = tail call i32 @free(i8* %6)
%21 = tail call i32 @fclose(i32* %3)
br label %22
22: ; preds = %19, %15
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %26
24: ; preds = %2
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %26
26: ; preds = %15, %24, %22
%27 = phi i32 [ -1, %22 ], [ 0, %24 ], [ 1, %15 ]
ret i32 %27
}