#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 /*<<< orphan*/ clearIBuffer();
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  float cantidadAgua, aguaPorPiso, capacidadTanque, aguaPorPersona,
      pisoMasAguaCantidad, consumoTotalEdificio;
  int nPersonas, nApartamento, nPisos, nPisoMasAgua, i;
  char r;
  pisoMasAguaCantidad = consumoTotalEdificio = 0;
  printf("Bienvenido!\n\nPor favor ingrese el número de pisos:");
  scanf("%d", &nPisos);
  if (nPisos > 0) {
    for (i = 0; i < nPisos; i++) {
      printf("\n\n/************** PISO #%d **************/\n\n", i + 1);
      aguaPorPiso = 0;
      nApartamento = 0;
      do {
        nApartamento++;
        printf("APARTAMENTO %d\n\tIngrese el numero de personas en el "
               "departamento:",
               nApartamento);
        scanf("%d", &nPersonas);
        printf("\tIngrese el consumo de agua (en litros):");
        scanf("%f", &cantidadAgua);
        aguaPorPiso += cantidadAgua;
        aguaPorPersona = cantidadAgua / nPersonas;
        printf("\nLa cantidad de agua por persona es %.2f.", aguaPorPersona);
        printf("\nHay otro apartamento?(s/n)");
        clearIBuffer();
        r = getchar();
      } while (r == 's' || r == 'S');
      if ((aguaPorPiso > pisoMasAguaCantidad) && (i != nPisos - 1)) {
        nPisoMasAgua = i + 1;
        pisoMasAguaCantidad = aguaPorPiso;
      }
      consumoTotalEdificio += aguaPorPiso;
    }
    capacidadTanque = consumoTotalEdificio * 0.125 + consumoTotalEdificio;
    printf("\n\n\nEl consumo total del edificio es %.2f y el tanque deberia "
           "tener una capacidad de %.2f",
           consumoTotalEdificio, capacidadTanque);
  } else
    printf("El numero de pisos proporcionado es incorrecto.");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
cmpl   $0x0,-0x28(%rbp)
jle    132d <main+0x1ed>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    12dd <main+0x19d>
mov    -0x30(%rbp),%esi
add    $0x1,%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5c(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
cvtsi2ssl -0x20(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe9d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <clearIBuffer@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x31(%rbp)
movsbl -0x31(%rbp),%ecx
mov    $0x1,%al
cmp    $0x73,%ecx
mov    %al,-0x32(%rbp)
je     1282 <main+0x142>
movsbl -0x31(%rbp),%eax
cmp    $0x53,%eax
sete   %al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
test   $0x1,%al
jne    11bf <main+0x7f>
movss  -0xc(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    12c0 <main+0x180>
mov    -0x30(%rbp),%eax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     12c0 <main+0x180>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1190 <main+0x50>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xd09(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdff(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    133b <main+0x1fb>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed9(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    12a8 <main+0x168>
xorps  %xmm0,%xmm0
xor    %esi,%esi
nop
movss  %xmm0,0xc(%rsp)
add    $0x1,%esi
lea    0xeaf(%rip),%rdi
mov    %esi,0x8(%rsp)
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%r13d
xorps  %xmm0,%xmm0
movss  %xmm0,(%rsp)
lea    0xefe(%rip),%r15
lea    0xf20(%rip),%r12
lea    0x14(%rsp),%rbx
lea    0xf17(%rip),%rbp
lea    0xf3a(%rip),%r14
nopw   0x0(%rax,%rax,1)
lea    0xe95(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe54(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
xorps  %xmm0,%xmm0
cvtsi2ssl 0x10(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
movss  (%rsp),%xmm2
addss  %xmm1,%xmm2
movss  %xmm2,(%rsp)
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <clearIBuffer@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
and    $0xdf,%al
add    $0x1,%r13d
cmp    $0x53,%al
je     11d0 <main+0x90>
movss  0xc(%rsp),%xmm0
addss  (%rsp),%xmm0
mov    0x8(%rsp),%esi
cmp    0x4(%rsp),%esi
jl     1180 <main+0x40>
cvtss2sd %xmm0,%xmm0
movsd  0xd78(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm0,%xmm1
cvtsd2ss %xmm1,%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe81(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    12b6 <main+0x176>
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [52 x i8] c"Bienvenido!\0A\0APor favor ingrese el n\C3\BAmero de pisos:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [45 x i8] c"\0A\0A/************** PISO #%d **************/\0A\0A\00"
@.str.3 = [66 x i8] c"APARTAMENTO %d\0A\09Ingrese el numero de personas en el departamento:\00"
@.str.4 = [41 x i8] c"\09Ingrese el consumo de agua (en litros):\00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [42 x i8] c"\0ALa cantidad de agua por persona es %.2f.\00"
@.str.7 = [28 x i8] c"\0AHay otro apartamento?(s/n)\00"
@.str.8 = [89 x i8] c"\0A\0A\0AEl consumo total del edificio es %.2f y el tanque deberia tener una capacidad de %.2f\00"
@.str.9 = [48 x i8] c"El numero de pisos proporcionado es incorrecto.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
store i32 0, i32* %1
store float 0.000000e+00, float* %7
store float 0.000000e+00, float* %6
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%16 = load i32, i32* %10
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %90
18: ; preds = %0
store i32 0, i32* %12
br label %19
19: ; preds = %75, %18
%20 = load i32, i32* %12
%21 = load i32, i32* %10
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %78
23: ; preds = %19
%24 = load i32, i32* %12
%25 = add nsw i32 %24, 1
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %25)
store float 0.000000e+00, float* %3
store i32 0, i32* %9
br label %27
27: ; preds = %56, %23
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 1
store i32 %29, i32* %9
%30 = load i32, i32* %9
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %2)
%35 = load float, float* %2
%36 = load float, float* %3
%37 = fadd float %36, %35
store float %37, float* %3
%38 = load float, float* %2
%39 = load i32, i32* %8
%40 = sitofp i32 %39 to float
%41 = fdiv float %38, %40
store float %41, float* %5
%42 = load float, float* %5
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), double %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%46 = call i32 (...) @clearIBuffer()
%47 = call signext i8 (...) @getchar()
store i8 %47, i8* %13
br label %48
48: ; preds = %27
%49 = load i8, i8* %13
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 115
br i1 %51, label %56, label %52
52: ; preds = %48
%53 = load i8, i8* %13
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 83
br label %56
56: ; preds = %52, %48
%57 = phi i1 [ true, %48 ], [ %55, %52 ]
br i1 %57, label %27, label %58
58: ; preds = %56
%59 = load float, float* %3
%60 = load float, float* %6
%61 = fcmp ogt float %59, %60
br i1 %61, label %62, label %71
62: ; preds = %58
%63 = load i32, i32* %12
%64 = load i32, i32* %10
%65 = sub nsw i32 %64, 1
%66 = icmp ne i32 %63, %65
br i1 %66, label %67, label %71
67: ; preds = %62
%68 = load i32, i32* %12
%69 = add nsw i32 %68, 1
store i32 %69, i32* %11
%70 = load float, float* %3
store float %70, float* %6
br label %71
71: ; preds = %67, %62, %58
%72 = load float, float* %3
%73 = load float, float* %7
%74 = fadd float %73, %72
store float %74, float* %7
br label %75
75: ; preds = %71
%76 = load i32, i32* %12
%77 = add nsw i32 %76, 1
store i32 %77, i32* %12
br label %19
78: ; preds = %19
%79 = load float, float* %7
%80 = fpext float %79 to double
%81 = load float, float* %7
%82 = fpext float %81 to double
%83 = call double @llvm.fmuladd.f64(double %80, double 1.250000e-01, double %82)
%84 = fptrunc double %83 to float
store float %84, float* %4
%85 = load float, float* %7
%86 = fpext float %85 to double
%87 = load float, float* %4
%88 = fpext float %87 to double
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.8, i64 0, i64 0), double %86, double %88)
br label %92
90: ; preds = %0
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0))
br label %92
92: ; preds = %90, %78
ret i32 0
}

LLVM IR (-O2):
@.str = [52 x i8] c"Bienvenido!\0A\0APor favor ingrese el n\C3\BAmero de pisos:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [45 x i8] c"\0A\0A/************** PISO #%d **************/\0A\0A\00"
@.str.3 = [66 x i8] c"APARTAMENTO %d\0A\09Ingrese el numero de personas en el departamento:\00"
@.str.4 = [41 x i8] c"\09Ingrese el consumo de agua (en litros):\00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [42 x i8] c"\0ALa cantidad de agua por persona es %.2f.\00"
@.str.7 = [28 x i8] c"\0AHay otro apartamento?(s/n)\00"
@.str.8 = [89 x i8] c"\0A\0A\0AEl consumo total del edificio es %.2f y el tanque deberia tener una capacidad de %.2f\00"
@.str.9 = [48 x i8] c"El numero de pisos proporcionado es incorrecto.\00"
define i32 @main() {
%1 = alloca float
%2 = alloca i32
%3 = alloca i32
%4 = bitcast float* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %46
11: ; preds = %0, %36
%12 = phi i32 [ %14, %36 ], [ 0, %0 ]
%13 = phi float [ %38, %36 ], [ 0.000000e+00, %0 ]
%14 = add nuw nsw i32 %12, 1
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %16, %11
%17 = phi i32 [ 0, %11 ], [ %19, %16 ]
%18 = phi float [ 0.000000e+00, %11 ], [ %25, %16 ]
%19 = add nuw nsw i32 %17, 1
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %1)
%24 = load float, float* %1
%25 = fadd float %18, %24
%26 = load i32, i32* %2
%27 = sitofp i32 %26 to float
%28 = fdiv float %24, %27
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), double %29)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%32 = call i32 (...) @clearIBuffer()
%33 = call signext i8 (...) @getchar()
%34 = and i8 %33, -33
%35 = icmp eq i8 %34, 83
br i1 %35, label %16, label %36
36: ; preds = %16
%37 = load i32, i32* %3
%38 = fadd float %13, %25
%39 = icmp slt i32 %14, %37
br i1 %39, label %11, label %40
40: ; preds = %36
%41 = fpext float %38 to double
%42 = call double @llvm.fmuladd.f64(double %41, double 1.250000e-01, double %41)
%43 = fptrunc double %42 to float
%44 = fpext float %43 to double
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([89 x i8], [89 x i8]* @.str.8, i64 0, i64 0), double %41, double %44)
br label %48
46: ; preds = %0
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0))
br label %48
48: ; preds = %46, %40
ret i32 0
}