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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int n, count, loops, loopcount;
  float x, sum = 0, avg;
  printf("How many lists? ");
  scanf("%d", &loops);
  for (loopcount = 1; loopcount <= loops; loopcount++) {
    printf("List number %d\nHow many numbers? ", loopcount);
    scanf("%d", &n);
    for (count = 1; count <= n; count++) {
      printf("x = ");
      scanf("%f", &x);
      sum += x;
    }
    avg = sum / n;
    printf("Average is: %f\n", avg);
    printf("Size of average variable: %d", sizeof(avg));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf19(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1228 <main+0x108>
mov    -0x14(%rbp),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11dd <main+0xbd>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe83(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x18(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1194 <main+0x74>
movss  -0x1c(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe3b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe3d(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115e <main+0x3e>
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    0xecb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf22(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    124b <main+0x12b>
mov    $0x1,%ebx
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
lea    0xedc(%rip),%rbp
lea    0xebd(%rip),%r14
lea    0xebb(%rip),%r15
lea    0x14(%rsp),%r12
jmp    11d6 <main+0xb6>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movss  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm1,0x8(%rsp)
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe86(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x4,%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x1(%rbx),%eax
cmp    0xc(%rsp),%ebx
mov    %eax,%ebx
jge    124b <main+0x12b>
lea    0xe34(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe78(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
test   %eax,%eax
jle    1190 <main+0x70>
xor    %r13d,%r13d
movss  0x8(%rsp),%xmm1
nopw   0x0(%rax,%rax,1)
movss  %xmm1,0x8(%rsp)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movss  0x8(%rsp),%xmm1
addss  0x14(%rsp),%xmm1
mov    0x10(%rsp),%eax
add    $0x1,%r13d
cmp    %eax,%r13d
jl     1210 <main+0xf0>
jmp    1196 <main+0x76>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"How many lists? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"List number %d\0AHow many numbers? \00"
@.str.3 = [5 x i8] c"x = \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [16 x i8] c"Average is: %f\0A\00"
@.str.6 = [29 x i8] c"Size of average variable: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
%7 = alloca float
%8 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %7
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
store i32 1, i32* %5
br label %11
11: ; preds = %41, %0
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %44
15: ; preds = %11
%16 = load i32, i32* %5
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %19
19: ; preds = %29, %15
%20 = load i32, i32* %3
%21 = load i32, i32* %2
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %6)
%26 = load float, float* %6
%27 = load float, float* %7
%28 = fadd float %27, %26
store float %28, float* %7
br label %29
29: ; preds = %23
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %19
32: ; preds = %19
%33 = load float, float* %7
%34 = load i32, i32* %2
%35 = sitofp i32 %34 to float
%36 = fdiv float %33, %35
store float %36, float* %8
%37 = load float, float* %8
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), double %38)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i64 4)
br label %41
41: ; preds = %32
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %11
44: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"How many lists? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"List number %d\0AHow many numbers? \00"
@.str.3 = [5 x i8] c"x = \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [16 x i8] c"Average is: %f\0A\00"
@.str.6 = [29 x i8] c"Size of average variable: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 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* %2)
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 1
br i1 %10, label %39, label %11
11: ; preds = %0, %28
%12 = phi float [ %29, %28 ], [ 0.000000e+00, %0 ]
%13 = phi i32 [ %36, %28 ], [ 1, %0 ]
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = icmp slt i32 %16, 1
br i1 %17, label %28, label %18
18: ; preds = %11, %18
%19 = phi i32 [ %25, %18 ], [ 1, %11 ]
%20 = phi float [ %24, %18 ], [ %12, %11 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %3)
%23 = load float, float* %3
%24 = fadd float %20, %23
%25 = add nuw nsw i32 %19, 1
%26 = load i32, i32* %1
%27 = icmp slt i32 %19, %26
br i1 %27, label %18, label %28
28: ; preds = %18, %11
%29 = phi float [ %12, %11 ], [ %24, %18 ]
%30 = phi i32 [ %16, %11 ], [ %26, %18 ]
%31 = sitofp i32 %30 to float
%32 = fdiv float %29, %31
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), double %33)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i64 4)
%36 = add nuw nsw i32 %13, 1
%37 = load i32, i32* %2
%38 = icmp slt i32 %13, %37
br i1 %38, label %11, label %39
39: ; preds = %28, %0
ret i32 0
}