#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*/ *fopen(char *, char *);
int /*<<< orphan*/ getchar();
unsigned int lettura_dati(int /*<<< orphan*/ *, float *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ totale_unita_abitative(float *, unsigned int);
int main(void) {
  FILE *file_dati;
  float consumi_unita[1000] = {0};
  unsigned int numero_unita;
  file_dati = fopen("consumi.txt", "r");
  if (file_dati != NULL) {
    numero_unita = lettura_dati(file_dati, consumi_unita);
    if (numero_unita != 0) {
      totale_unita_abitative(consumi_unita, numero_unita);
    } else {
      printf("Attenzione, numero unita 0, il file e' vuoto oppure errato");
    }
  } else {
    printf("Non e' stato possibile aprire il file consumi.txt il programma "
           "terminera' ora!");
  }
  getchar();
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xfb0(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1040 <memset@plt>
lea    0xe74(%rip),%rdi
lea    0xe79(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11f2 <main+0x92>
mov    -0x10(%rbp),%rdi
lea    -0xfb0(%rbp),%rsi
call   1080 <lettura_dati@plt>
mov    %eax,-0xfb4(%rbp)
cmpl   $0x0,-0xfb4(%rbp)
je     11e1 <main+0x81>
lea    -0xfb0(%rbp),%rdi
mov    -0xfb4(%rbp),%esi
call   1060 <totale_unita_abitative@plt>
jmp    11ed <main+0x8d>
lea    0xe26(%rip),%rdi
call   1030 <printf@plt>
jmp    11fe <main+0x9e>
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0xfc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0xfa8,%rsp
mov    %rsp,%rdi
mov    $0xfa0,%edx
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xe83(%rip),%rdi
lea    0xe88(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11a9 <main+0x49>
mov    %rsp,%rsi
mov    %rax,%rdi
call   1080 <lettura_dati@plt>
test   %eax,%eax
je     11b2 <main+0x52>
mov    %rsp,%rdi
mov    %eax,%esi
call   1060 <totale_unita_abitative@plt>
jmp    11be <main+0x5e>
lea    0xe99(%rip),%rdi
jmp    11b9 <main+0x59>
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0xfa8,%rsp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"consumi.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [59 x i8] c"Attenzione, numero unita 0, il file e' vuoto oppure errato\00"
@.str.3 = [79 x i8] c"Non e' stato possibile aprire il file consumi.txt il programma terminera' ora!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [1000 x float]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [1000 x float]* %3 to i8*
%6 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
%7 = load i32*, i32** %2
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %22
9: ; preds = %0
%10 = load i32*, i32** %2
%11 = getelementptr inbounds [1000 x float], [1000 x float]* %3, i64 0, i64 0
%12 = call i32 @lettura_dati(i32* %10, float* %11)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %9
%16 = getelementptr inbounds [1000 x float], [1000 x float]* %3, i64 0, i64 0
%17 = load i32, i32* %4
%18 = call i32 @totale_unita_abitative(float* %16, i32 %17)
br label %21
19: ; preds = %9
%20 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %15
br label %24
22: ; preds = %0
%23 = call i32 @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %22, %21
%25 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"consumi.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [59 x i8] c"Attenzione, numero unita 0, il file e' vuoto oppure errato\00"
@.str.3 = [79 x i8] c"Non e' stato possibile aprire il file consumi.txt il programma terminera' ora!\00"
define i32 @main() {
%1 = alloca [1000 x float]
%2 = bitcast [1000 x float]* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %13, label %5
5: ; preds = %0
%6 = getelementptr inbounds [1000 x float], [1000 x float]* %1, i64 0, i64 0
%7 = call i32 @lettura_dati(i32* %3, float* %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = call i32 @totale_unita_abitative(float* %6, i32 %7)
br label %15
11: ; preds = %5
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
br label %15
13: ; preds = %0
%14 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0))
br label %15
15: ; preds = %9, %11, %13
%16 = call i32 (...) @getchar()
ret i32 0
}