#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 */
float average(float, float);
int /*<<< orphan*/ displayResult(int, float);
int /*<<< orphan*/ draw(int /*<<< orphan*/, int);
int /*<<< orphan*/ getDailyData(float *, float *, char *);
int getInteger(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ symbolToDraw(char, float);
int main(void) {
  int numDays;
  int i;
  float sum = 0;
  float dailyHigh;
  float dailyLow;
  char conditions;
  float dailyAvg = 0;
  printf("\nWeather Analyzer 2.0\n");
  printf("=====================\n");
  printf("\nHow many days of data? \n");
  numDays = getInteger(1, 14);
  for (i = 0; i < numDays; i++) {
    getDailyData(&dailyHigh, &dailyLow, &conditions);
    dailyAvg = average(dailyHigh, dailyLow);
    printf("Today's average temperature is: %.2f\n", dailyAvg);
    sum += dailyAvg;
    draw(symbolToDraw(conditions, dailyAvg), 20);
  }
  displayResult(numDays, (sum / numDays));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
mov    $0xe,%esi
call   1050 <getInteger@plt>
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1253 <main+0xe3>
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x19(%rbp),%rdx
call   1030 <getDailyData@plt>
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
call   1090 <average@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe35(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movss  -0x20(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x19(%rbp),%al
movss  -0x20(%rbp),%xmm0
movsbl %al,%edi
call   1060 <symbolToDraw@plt>
mov    %eax,%edi
mov    $0x14,%esi
call   1040 <draw@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d2 <main+0x62>
mov    -0x8(%rbp),%edi
movss  -0x10(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
call   1080 <displayResult@plt>
xor    %eax,%eax
add    $0x20,%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    0xe91(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9b(%rip),%rdi
call   1040 <puts@plt>
lea    0xea5(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
mov    $0xe,%esi
call   1060 <getInteger@plt>
mov    %eax,%r14d
xorps  %xmm0,%xmm0
test   %eax,%eax
jle    1259 <main+0xd9>
movss  %xmm0,0x8(%rsp)
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0x7(%rsp),%r13
lea    0xe15(%rip),%rbp
mov    %r14d,%ebx
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1030 <getDailyData@plt>
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
call   10a0 <average@plt>
movss  %xmm0,0xc(%rsp)
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1080 <printf@plt>
movss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,0x8(%rsp)
movsbl 0x7(%rsp),%edi
movaps %xmm1,%xmm0
call   1070 <symbolToDraw@plt>
mov    %eax,%edi
mov    $0x14,%esi
call   1050 <draw@plt>
add    $0xffffffff,%ebx
jne    11f0 <main+0x70>
jmp    125f <main+0xdf>
movss  %xmm0,0x8(%rsp)
xorps  %xmm1,%xmm1
cvtsi2ss %r14d,%xmm1
movss  0x8(%rsp),%xmm0
divss  %xmm1,%xmm0
mov    %r14d,%edi
call   1090 <displayResult@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\0AWeather Analyzer 2.0\0A\00"
@.str.1 = [23 x i8] c"=====================\0A\00"
@.str.2 = [26 x i8] c"\0AHow many days of data? \0A\00"
@.str.3 = [38 x i8] c"Today's average temperature is: %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i8
%8 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @getInteger(i32 1, i32 14)
store i32 %12, i32* %2
store i32 0, i32* %3
br label %13
13: ; preds = %32, %0
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %35
17: ; preds = %13
%18 = call i32 @getDailyData(float* %5, float* %6, i8* %7)
%19 = load float, float* %5
%20 = load float, float* %6
%21 = call float @average(float %19, float %20)
store float %21, float* %8
%22 = load float, float* %8
%23 = fpext float %22 to double
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), double %23)
%25 = load float, float* %8
%26 = load float, float* %4
%27 = fadd float %26, %25
store float %27, float* %4
%28 = load i8, i8* %7
%29 = load float, float* %8
%30 = call i32 @symbolToDraw(i8 signext %28, float %29)
%31 = call i32 @draw(i32 %30, i32 20)
br label %32
32: ; preds = %17
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %13
35: ; preds = %13
%36 = load i32, i32* %2
%37 = load float, float* %4
%38 = load i32, i32* %2
%39 = sitofp i32 %38 to float
%40 = fdiv float %37, %39
%41 = call i32 @displayResult(i32 %36, float %40)
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [38 x i8] c"Today's average temperature is: %.2f\0A\00"
@str = [22 x i8] c"\0AWeather Analyzer 2.0\00"
@str.4 = [22 x i8] c"=====================\00"
@str.5 = [25 x i8] c"\0AHow many days of data? \00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca i8
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0))
%9 = tail call i32 @getInteger(i32 1, i32 14)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %26
11: ; preds = %0, %11
%12 = phi float [ %20, %11 ], [ 0.000000e+00, %0 ]
%13 = phi i32 [ %24, %11 ], [ 0, %0 ]
%14 = call i32 @getDailyData(float* %1, float* %2, i8* %3)
%15 = load float, float* %1
%16 = load float, float* %2
%17 = call float @average(float %15, float %16)
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), double %18)
%20 = fadd float %12, %17
%21 = load i8, i8* %3
%22 = call i32 @symbolToDraw(i8 signext %21, float %17)
%23 = call i32 @draw(i32 %22, i32 20)
%24 = add nuw nsw i32 %13, 1
%25 = icmp eq i32 %24, %9
br i1 %25, label %26, label %11
26: ; preds = %11, %0
%27 = phi float [ 0.000000e+00, %0 ], [ %20, %11 ]
%28 = sitofp i32 %9 to float
%29 = fdiv float %27, %28
%30 = call i32 @displayResult(i32 %9, float %29)
ret i32 0
}