#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*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ allocaEInizializzaMemoria();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ handleLine(char *);
int /*<<< orphan*/ initializeMutex();
int /*<<< orphan*/ logM(char *);
int loadConfig() {
  char *filename = "CONFIG";
  FILE *filePointer = fopen(filename, "ru");
  if (filePointer == NULL) {
    logM("File di config non trovato.\n");
    return EXIT_FAILURE;
  } else {
    logM("File di config trovato\n");
  }
  char buf[256];
  while (fgets(buf, sizeof(buf), filePointer)) {
    handleLine(buf);
  }
  fclose(filePointer);
  allocaEInizializzaMemoria();
  initializeMutex();
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<loadConfig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
lea    0xe7e(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c2 <loadConfig+0x52>
lea    0xe5e(%rip),%rdi
call   1060 <logM@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1226 <loadConfig+0xb6>
lea    0xe5e(%rip),%rdi
call   1060 <logM@plt>
jmp    11d3 <loadConfig+0x63>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1203 <loadConfig+0x93>
lea    -0x120(%rbp),%rdi
call   1040 <handleLine@plt>
jmp    11d3 <loadConfig+0x63>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x0,%al
call   1090 <allocaEInizializzaMemoria@plt>
mov    $0x0,%al
call   1070 <initializeMutex@plt>
mov    0x2db7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadConfig>:
push   %r14
push   %rbx
sub    $0x108,%rsp
lea    0xe7f(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11fc <loadConfig+0x8c>
mov    %rax,%r14
lea    0xe8b(%rip),%rdi
call   1060 <logM@plt>
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11dd <loadConfig+0x6d>
mov    %rsp,%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1040 <handleLine@plt>
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    11c0 <loadConfig+0x50>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
call   1090 <allocaEInizializzaMemoria@plt>
xor    %eax,%eax
call   1070 <initializeMutex@plt>
mov    0x2dde(%rip),%rax
jmp    120f <loadConfig+0x9f>
lea    0xe07(%rip),%rdi
call   1060 <logM@plt>
mov    0x2dd1(%rip),%rax
mov    (%rax),%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"CONFIG\00"
@.str.1 = [3 x i8] c"ru\00"
@.str.2 = [29 x i8] c"File di config non trovato.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [24 x i8] c"File di config trovato\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @loadConfig() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [256 x i8]
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = load i8*, i8** %2
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %3
%7 = load i32*, i32** %3
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i32 @logM(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
store i32 %11, i32* %1
br label %29
12: ; preds = %0
%13 = call i32 @logM(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %14
14: ; preds = %12
br label %15
15: ; preds = %20, %14
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%17 = load i32*, i32** %3
%18 = call i64 @fgets(i8* %16, i32 256, i32* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%22 = call i32 @handleLine(i8* %21)
br label %15
23: ; preds = %15
%24 = load i32*, i32** %3
%25 = call i32 @fclose(i32* %24)
%26 = call i32 (...) @allocaEInizializzaMemoria()
%27 = call i32 (...) @initializeMutex()
%28 = load i32, i32* @EXIT_SUCCESS
store i32 %28, i32* %1
br label %29
29: ; preds = %23, %9
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [7 x i8] c"CONFIG\00"
@.str.1 = [3 x i8] c"ru\00"
@.str.2 = [29 x i8] c"File di config non trovato.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [24 x i8] c"File di config trovato\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @loadConfig() {
%1 = alloca [256 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = tail call i32 @logM(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
br label %21
7: ; preds = %0
%8 = tail call i32 @logM(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%10 = call i64 @fgets(i8* %9, i32 256, i32* %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %7, %12
%13 = call i32 @handleLine(i8* %9)
%14 = call i64 @fgets(i8* %9, i32 256, i32* %2)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %12
16: ; preds = %12, %7
%17 = call i32 @fclose(i32* %2)
%18 = call i32 (...) @allocaEInizializzaMemoria()
%19 = call i32 (...) @initializeMutex()
%20 = load i32, i32* @EXIT_SUCCESS
br label %21
21: ; preds = %16, %4
%22 = phi i32 [ %6, %4 ], [ %20, %16 ]
ret i32 %22
}