#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*/ caricaGiocatori(int *, int /*<<< orphan*/ *);
int /*<<< orphan*/ caricaInfoGiocatore(int *, int /*<<< orphan*/ *);
int /*<<< orphan*/ caricaInfoStato(int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ caricaMappa(int /*<<< orphan*/ *);
int /*<<< orphan*/ caricadati();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ headerOK(int /*<<< orphan*/ *);
int /*<<< orphan*/ inizializza();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ rigeneramappa();
int carica(char *nomefile) {
  FILE *fp;
  int inGioco[12];
  fp = fopen(nomefile, "r");
  if (fp == NULL) {
    perror("fopen fallita");
    return 1;
  }
  if (!headerOK(fp))
    return 1;
  caricadati();
  inizializza();
  caricaInfoStato(fp, inGioco);
  caricaMappa(fp);
  caricaInfoGiocatore(inGioco, fp);
  caricaGiocatori(inGioco, fp);
  fclose(fp);
  rigeneramappa();
  return 0;
}


x86 assembly (clang, -O0):
<carica>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f3 <carica+0x43>
lea    0xe20(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1266 <carica+0xb6>
mov    -0x18(%rbp),%rdi
call   1070 <headerOK@plt>
cmp    $0x0,%eax
jne    1211 <carica+0x61>
movl   $0x1,-0x4(%rbp)
jmp    1266 <carica+0xb6>
mov    $0x0,%al
call   10b0 <caricadati@plt>
mov    $0x0,%al
call   1080 <inizializza@plt>
mov    -0x18(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1040 <caricaInfoStato@plt>
mov    -0x18(%rbp),%rdi
call   1060 <caricaMappa@plt>
lea    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10d0 <caricaInfoGiocatore@plt>
lea    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10c0 <caricaGiocatori@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x0,%al
call   1050 <rigeneramappa@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<carica>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
lea    0xe41(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1226 <carica+0x76>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <headerOK@plt>
test   %eax,%eax
je     1232 <carica+0x82>
xor    %r14d,%r14d
xor    %eax,%eax
call   10b0 <caricadati@plt>
xor    %eax,%eax
call   1080 <inizializza@plt>
mov    %rsp,%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <caricaInfoStato@plt>
mov    %rbx,%rdi
call   1060 <caricaMappa@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10d0 <caricaInfoGiocatore@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10c0 <caricaGiocatori@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
call   1050 <rigeneramappa@plt>
jmp    1238 <carica+0x88>
lea    0xdd5(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [14 x i8] c"fopen fallita\00"
define i32 @carica(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [12 x i32]
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %4
%8 = load i32*, i32** %4
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %34
12: ; preds = %1
%13 = load i32*, i32** %4
%14 = call i32 @headerOK(i32* %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %12
store i32 1, i32* %2
br label %34
17: ; preds = %12
%18 = call i32 (...) @caricadati()
%19 = call i32 (...) @inizializza()
%20 = load i32*, i32** %4
%21 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 0
%22 = call i32 @caricaInfoStato(i32* %20, i32* %21)
%23 = load i32*, i32** %4
%24 = call i32 @caricaMappa(i32* %23)
%25 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 0
%26 = load i32*, i32** %4
%27 = call i32 @caricaInfoGiocatore(i32* %25, i32* %26)
%28 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 0
%29 = load i32*, i32** %4
%30 = call i32 @caricaGiocatori(i32* %28, i32* %29)
%31 = load i32*, i32** %4
%32 = call i32 @fclose(i32* %31)
%33 = call i32 (...) @rigeneramappa()
store i32 0, i32* %2
br label %34
34: ; preds = %17, %16, %10
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [14 x i8] c"fopen fallita\00"
define i32 @carica(i8* nocapture %0) {
%2 = alloca [12 x i32]
%3 = bitcast [12 x i32]* %2 to i8*
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %21
8: ; preds = %1
%9 = tail call i32 @headerOK(i32* %4)
%10 = icmp eq i32 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %8
%12 = tail call i32 (...) @caricadati()
%13 = tail call i32 (...) @inizializza()
%14 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 0
%15 = call i32 @caricaInfoStato(i32* %4, i32* %14)
%16 = call i32 @caricaMappa(i32* %4)
%17 = call i32 @caricaInfoGiocatore(i32* %14, i32* %4)
%18 = call i32 @caricaGiocatori(i32* %14, i32* %4)
%19 = call i32 @fclose(i32* %4)
%20 = call i32 (...) @rigeneramappa()
br label %21
21: ; preds = %8, %11, %6
%22 = phi i32 [ 1, %6 ], [ 0, %11 ], [ 1, %8 ]
ret i32 %22
}