#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);
int /*<<< orphan*/ scanf(char *, int *);
int birthdayGift(void) {
  int numSteps;
  scanf("%d", &numSteps);
  int sum = 0;
  while (numSteps--) {
    int input;
    scanf("%d", &input);
    sum += input;
  }
  printf("%.1f", sum / 2.0);
  return 0;
}


x86 assembly (clang, -O0):
<birthdayGift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed9(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
je     1171 <birthdayGift+0x51>
lea    0xeae(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    113f <birthdayGift+0x1f>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe82(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<birthdayGift>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed9(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
xor    %esi,%esi
subl   $0x1,0x8(%rsp)
jb     1176 <birthdayGift+0x56>
xor    %ebp,%ebp
lea    0xebd(%rip),%r14
lea    0xc(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    0xc(%rsp),%ebp
subl   $0x1,0x8(%rsp)
jae    1150 <birthdayGift+0x30>
cvtsi2sd %ebp,%xmm0
mulsd  0xe8e(%rip),%xmm0
cvttsd2si %xmm0,%esi
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%.1f\00"
define i32 @birthdayGift() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
store i32 0, i32* %2
br label %5
5: ; preds = %9, %0
%6 = load i32, i32* %1
%7 = add nsw i32 %6, -1
store i32 %7, i32* %1
%8 = icmp ne i32 %6, 0
br i1 %8, label %9, label %14
9: ; preds = %5
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = add nsw i32 %12, %11
store i32 %13, i32* %2
br label %5
14: ; preds = %5
%15 = load i32, i32* %2
%16 = sitofp i32 %15 to double
%17 = fdiv double %16, 2.000000e+00
%18 = fptosi double %17 to i32
%19 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%.1f\00"
define i32 @birthdayGift() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = add nsw i32 %5, -1
store i32 %6, i32* %1
%7 = icmp eq i32 %5, 0
br i1 %7, label %22, label %8
8: ; preds = %0
%9 = bitcast i32* %2 to i8*
br label %10
10: ; preds = %8, %10
%11 = phi i32 [ 0, %8 ], [ %14, %10 ]
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = add nsw i32 %13, %11
%15 = load i32, i32* %1
%16 = add nsw i32 %15, -1
store i32 %16, i32* %1
%17 = icmp eq i32 %15, 0
br i1 %17, label %18, label %10
18: ; preds = %10
%19 = sitofp i32 %14 to double
%20 = fmul double %19, 5.000000e-01
%21 = fptosi double %20 to i32
br label %22
22: ; preds = %18, %0
%23 = phi i32 [ 0, %0 ], [ %21, %18 ]
%24 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %23)
ret i32 0
}