#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 */

/* Variables and functions */
int scanf(char *, ...);
int ler_volumes(float *volumes) {
  int num;
  scanf("%d", &num);
  for (int i = 0; i < num; ++i) {
    if (scanf("%f", volumes + i) < 1) {
      num = i;
      break;
    }
  }
  return num;
}


x86 assembly (clang, -O0):
<ler_volumes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1030 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1185 <ler_volumes+0x75>
mov    -0x8(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <scanf@plt>
cmp    $0x1,%eax
jge    1172 <ler_volumes+0x62>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1185 <ler_volumes+0x75>
jmp    1177 <ler_volumes+0x67>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1135 <ler_volumes+0x25>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ler_volumes>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0xedd(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
jle    1165 <ler_volumes+0x55>
lea    0xec5(%rip),%r15
xor    %ebx,%ebx
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
test   %eax,%eax
jle    1165 <ler_volumes+0x55>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r14
cmp    %rax,%rbx
jl     1140 <ler_volumes+0x30>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%f\00"
define i32 @ler_volumes(float* %0) {
%2 = alloca float*
%3 = alloca i32
%4 = alloca i32
store float* %0, float** %2
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 0, i32* %4
br label %6
6: ; preds = %20, %1
%7 = load i32, i32* %4
%8 = load i32, i32* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %23
10: ; preds = %6
%11 = load float*, float** %2
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds float, float* %11, i64 %13
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %14)
%16 = icmp slt i32 %15, 1
br i1 %16, label %17, label %19
17: ; preds = %10
%18 = load i32, i32* %4
store i32 %18, i32* %3
br label %23
19: ; preds = %10
br label %20
20: ; preds = %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %6
23: ; preds = %17, %6
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%f\00"
define i32 @ler_volumes(float* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %19
7: ; preds = %1, %14
%8 = phi i64 [ %15, %14 ], [ 0, %1 ]
%9 = getelementptr inbounds float, float* %0, i64 %8
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %9)
%11 = icmp slt i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = trunc i64 %8 to i32
br label %19
14: ; preds = %7
%15 = add nuw nsw i64 %8, 1
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %15, %17
br i1 %18, label %7, label %19
19: ; preds = %14, %1, %12
%20 = phi i32 [ %5, %1 ], [ %13, %12 ], [ %16, %14 ]
ret i32 %20
}