#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*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *, ...);
unsigned int lettura_dati(FILE *file_dati, float consumi_unita[]) {
  unsigned int numero_unita;
  unsigned int numero_unita_lette;
  char buffer[8];
  fscanf(file_dati, "%7s %u", buffer, &numero_unita);
  numero_unita_lette = 0;
  while (!feof(file_dati) && numero_unita < 1000) {
    fscanf(file_dati, "%8s %f", buffer, &consumi_unita[numero_unita_lette]);
    numero_unita_lette++;
  }
  if (numero_unita_lette != (numero_unita + 1)) {
    return (0);
  }
  return (numero_unita);
}


x86 assembly (clang, -O0):
<lettura_dati>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rdx
lea    0xec1(%rip),%rsi
lea    -0x1c(%rbp),%rcx
mov    $0x0,%al
call   1030 <fscanf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
jne    1177 <lettura_dati+0x57>
cmpl   $0x3e8,-0x1c(%rbp)
setb   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1187 <lettura_dati+0x67>
jmp    11b9 <lettura_dati+0x99>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%eax
shl    $0x2,%rax
add    %rax,%rcx
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1030 <fscanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1151 <lettura_dati+0x31>
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
je     11d6 <lettura_dati+0xb6>
movl   $0x0,-0x4(%rbp)
jmp    11dc <lettura_dati+0xbc>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lettura_dati>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r13
mov    %rdi,%rbp
lea    0xec5(%rip),%rsi
xor    %r14d,%r14d
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
xor    %eax,%eax
call   1030 <fscanf@plt>
mov    %rbp,%rdi
call   1040 <feof@plt>
mov    0xc(%rsp),%ecx
test   %eax,%eax
jne    11ba <lettura_dati+0x9a>
mov    $0x0,%ebx
cmp    $0x3e7,%ecx
ja     11bc <lettura_dati+0x9c>
lea    0xe94(%rip),%r15
lea    0x10(%rsp),%r12
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebx,%eax
lea    0x0(,%rax,4),%rcx
add    %r13,%rcx
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <fscanf@plt>
add    $0x1,%ebx
mov    %rbp,%rdi
call   1040 <feof@plt>
mov    0xc(%rsp),%ecx
test   %eax,%eax
jne    11bc <lettura_dati+0x9c>
cmp    $0x3e8,%ecx
jb     1180 <lettura_dati+0x60>
jmp    11bc <lettura_dati+0x9c>
xor    %ebx,%ebx
lea    0x1(%rcx),%eax
cmp    %eax,%ebx
cmove  %ecx,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%7s %u\00"
@.str.1 = [7 x i8] c"%8s %f\00"
define i32 @lettura_dati(i32* %0, float* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca float*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [8 x i8]
store i32* %0, i32** %4
store float* %1, float** %5
%9 = load i32*, i32** %4
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%11 = call i32 (i32*, i8*, i8*, ...) @fscanf(i32* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %10, i32* %6)
store i32 0, i32* %7
br label %12
12: ; preds = %21, %2
%13 = load i32*, i32** %4
%14 = call i32 @feof(i32* %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = load i32, i32* %6
%18 = icmp ult i32 %17, 1000
br label %19
19: ; preds = %16, %12
%20 = phi i1 [ false, %12 ], [ %18, %16 ]
br i1 %20, label %21, label %31
21: ; preds = %19
%22 = load i32*, i32** %4
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%24 = load float*, float** %5
%25 = load i32, i32* %7
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds float, float* %24, i64 %26
%28 = call i32 (i32*, i8*, i8*, ...) @fscanf(i32* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %23, float* %27)
%29 = load i32, i32* %7
%30 = add i32 %29, 1
store i32 %30, i32* %7
br label %12
31: ; preds = %19
%32 = load i32, i32* %7
%33 = load i32, i32* %6
%34 = add i32 %33, 1
%35 = icmp ne i32 %32, %34
br i1 %35, label %36, label %37
36: ; preds = %31
store i32 0, i32* %3
br label %39
37: ; preds = %31
%38 = load i32, i32* %6
store i32 %38, i32* %3
br label %39
39: ; preds = %37, %36
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [7 x i8] c"%7s %u\00"
@.str.1 = [7 x i8] c"%8s %f\00"
define i32 @lettura_dati(i32* nocapture %0, float* %1) {
%3 = alloca i32
%4 = alloca [8 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%7 = call i32 (i32*, i8*, i8*, ...) @fscanf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %6, i32* %3)
%8 = call i32 @feof(i32* %0)
%9 = icmp eq i32 %8, 0
%10 = load i32, i32* %3
%11 = icmp ult i32 %10, 1000
%12 = select i1 %9, i1 %11, i1 false
br i1 %12, label %13, label %24
13: ; preds = %2, %13
%14 = phi i32 [ %18, %13 ], [ 0, %2 ]
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds float, float* %1, i64 %15
%17 = call i32 (i32*, i8*, i8*, ...) @fscanf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %6, float* %16)
%18 = add i32 %14, 1
%19 = call i32 @feof(i32* %0)
%20 = icmp eq i32 %19, 0
%21 = load i32, i32* %3
%22 = icmp ult i32 %21, 1000
%23 = select i1 %20, i1 %22, i1 false
br i1 %23, label %13, label %24
24: ; preds = %13, %2
%25 = phi i32 [ 0, %2 ], [ %18, %13 ]
%26 = phi i32 [ %10, %2 ], [ %21, %13 ]
%27 = add i32 %26, 1
%28 = icmp eq i32 %25, %27
%29 = select i1 %28, i32 %26, i32 0
ret i32 %29
}