#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  float num, average, sum;
  int i, n;
  printf("Maximum no. of inputs: ");
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    printf("Enter n%d: ", i);
    scanf("%f", &num);
    if (num < 0.0)
      goto jump;
    sum = sum + num;
  }
jump:
  average = sum / (i - 1);
  printf("Average: %.2f", average);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11bd <main+0x9d>
mov    -0x14(%rbp),%esi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11a0 <main+0x80>
jmp    11c2 <main+0xa2>
movss  -0x10(%rbp),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <main+0x36>
jmp    11c2 <main+0xa2>
movss  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe40(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x10(%rsp)
jle    11b4 <main+0x94>
mov    $0x1,%ebx
lea    0xec0(%rip),%r14
lea    0xec5(%rip),%r15
lea    0x14(%rsp),%r12
nopl   0x0(%rax,%rax,1)
movss  %xmm1,0xc(%rsp)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movss  0x14(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     11bb <main+0x9b>
movss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
lea    0x1(%rbx),%eax
cmp    0x10(%rsp),%ebx
mov    %eax,%ebx
jl     1170 <main+0x50>
jmp    11c3 <main+0xa3>
mov    $0x1,%eax
jmp    11c3 <main+0xa3>
mov    %ebx,%eax
movss  0xc(%rsp),%xmm1
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe4f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Maximum no. of inputs: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [12 x i8] c"Enter n%d: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [14 x i8] c"Average: %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 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* %6)
store i32 1, i32* %5
br label %9
9: ; preds = %25, %0
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %28
13: ; preds = %9
%14 = load i32, i32* %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%17 = load float, float* %2
%18 = fpext float %17 to double
%19 = fcmp olt double %18, 0.000000e+00
br i1 %19, label %20, label %21
20: ; preds = %13
br label %29
21: ; preds = %13
%22 = load float, float* %4
%23 = load float, float* %2
%24 = fadd float %22, %23
store float %24, float* %4
br label %25
25: ; preds = %21
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %9
28: ; preds = %9
br label %29
29: ; preds = %28, %20
%30 = load float, float* %4
%31 = load i32, i32* %5
%32 = sub nsw i32 %31, 1
%33 = sitofp i32 %32 to float
%34 = fdiv float %30, %33
store float %34, float* %3
%35 = load float, float* %3
%36 = fpext float %35 to double
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), double %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Maximum no. of inputs: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [12 x i8] c"Enter n%d: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [14 x i8] c"Average: %.2f\00"
define i32 @main() {
%1 = alloca float
%2 = alloca i32
%3 = bitcast float* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 1
br i1 %8, label %21, label %9
9: ; preds = %0, %16
%10 = phi i32 [ %18, %16 ], [ 1, %0 ]
%11 = phi float [ %17, %16 ], [ undef, %0 ]
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %1)
%14 = load float, float* %1
%15 = fcmp olt float %14, 0.000000e+00
br i1 %15, label %21, label %16
16: ; preds = %9
%17 = fadd float %11, %14
%18 = add nuw nsw i32 %10, 1
%19 = load i32, i32* %2
%20 = icmp slt i32 %10, %19
br i1 %20, label %9, label %21
21: ; preds = %9, %16, %0
%22 = phi float [ undef, %0 ], [ %17, %16 ], [ %11, %9 ]
%23 = phi i32 [ 1, %0 ], [ %18, %16 ], [ %10, %9 ]
%24 = add nsw i32 %23, -1
%25 = sitofp i32 %24 to float
%26 = fdiv float %22, %25
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), double %27)
ret i32 0
}