#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*/ F_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ freopen(char *, char *, int /*<<< orphan*/);
double *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, double);
int /*<<< orphan*/ sscanf(char *, char *, double *);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  int people_amount;
  int i;
  double total_cost = 0;
  double average_cost = 0.0;
  double diff_minus = 0.0;
  double diff_plus = 0.0;
  double *cost;
  char temp[1000];
  if (argc != 2) {
    printf("Usage: %s INPUT_FILE\n\n", argv[0]);
    exit(-1);
  }
  if (access(argv[1], F_OK)) {
    printf("Error: INPUT_FILE %s does not exist\n", argv[1]);
    exit(-1);
  }
  freopen(argv[1], "r", stdin);
  while (scanf("%d", &people_amount) == 1 && people_amount) {
    cost = malloc(people_amount * sizeof(double));
    total_cost = 0.0;
    for (i = 0; i < people_amount; ++i) {
      scanf("%lf", &cost[i]);
      total_cost += cost[i];
    }
    average_cost = total_cost / people_amount;
    sprintf(temp, "%.2lf", average_cost);
    sscanf(temp, "%lf", &average_cost);
    diff_plus = 0.0;
    diff_minus = 0.0;
    for (i = 0; i < people_amount; ++i) {
      if (cost[i] > average_cost)
        diff_plus += cost[i] - average_cost;
      else
        diff_minus += average_cost - cost[i];
    }
    printf("$%.2lf\n", (diff_plus > diff_minus) ? diff_minus : diff_plus);
    free(cost);
  }
  fclose(stdin);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1202 <main+0x62>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dbf(%rip),%rax
mov    (%rax),%esi
call   10a0 <access@plt>
cmp    $0x0,%rax
je     1242 <main+0xa2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d97(%rip),%rax
mov    (%rax),%edx
lea    0xde2(%rip),%rsi
call   1060 <freopen@plt>
lea    0xdd8(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
mov    %al,-0x431(%rbp)
jne    1291 <main+0xf1>
cmpl   $0x0,-0x14(%rbp)
setne  %al
mov    %al,-0x431(%rbp)
mov    -0x431(%rbp),%al
test   $0x1,%al
jne    12a4 <main+0x104>
jmp    1434 <main+0x294>
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1314 <main+0x174>
mov    -0x40(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1090 <scanf@plt>
mov    -0x40(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12c6 <main+0x126>
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
lea    -0x430(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
lea    0xd0b(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x430(%rbp),%rdi
lea    0xcf4(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1080 <sscanf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    13e1 <main+0x241>
mov    -0x40(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    13b2 <main+0x212>
mov    -0x40(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x28(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    13ce <main+0x22e>
movsd  -0x28(%rbp),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x18(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    13d3 <main+0x233>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    136d <main+0x1cd>
movsd  -0x38(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1403 <main+0x263>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x440(%rbp)
ff
jmp    1410 <main+0x270>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x440(%rbp)
ff
movsd  -0x440(%rbp),%xmm0
ff
lea    0xc2c(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
jmp    125f <main+0xbf>
mov    0x2bad(%rip),%rax
mov    (%rax),%edi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%rbx
movq   $0x0,0x10(%rsp)
cmp    $0x2,%edi
jne    1495 <main+0x2f5>
mov    0x8(%rbx),%rdi
mov    0x2dff(%rip),%rax
mov    (%rax),%esi
call   10a0 <access@plt>
mov    0x8(%rbx),%rcx
test   %rax,%rax
jne    14a1 <main+0x301>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edx
lea    0xe4f(%rip),%rsi
mov    %rcx,%rdi
call   1060 <freopen@plt>
lea    0xe42(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
cmp    $0x1,%eax
jne    1473 <main+0x2d3>
mov    0xc(%rsp),%ebp
test   %ebp,%ebp
je     1473 <main+0x2d3>
lea    0xe1d(%rip),%rbx
lea    0x20(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x0(,%rbp,8),%edi
call   1070 <malloc@plt>
mov    %rax,%r13
xorpd  %xmm0,%xmm0
test   %ebp,%ebp
jle    12a1 <main+0x101>
xorpd  %xmm0,%xmm0
mov    %r13,%r12
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x18(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
movsd  0x18(%rsp),%xmm0
addsd  (%r12),%xmm0
add    $0x1,%r14
movslq 0xc(%rsp),%rbp
add    $0x8,%r12
cmp    %rbp,%r14
jl     1270 <main+0xd0>
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r15,%rdi
lea    0xd91(%rip),%rsi
call   10b0 <sprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
lea    0x10(%rsp),%rdx
call   1080 <sscanf@plt>
mov    0xc(%rsp),%eax
xorpd  %xmm1,%xmm1
test   %eax,%eax
xorpd  %xmm0,%xmm0
jle    1435 <main+0x295>
movsd  0x10(%rsp),%xmm9
cmp    $0x1,%eax
jne    1330 <main+0x190>
xorpd  %xmm1,%xmm1
xor    %ecx,%ecx
xorpd  %xmm0,%xmm0
test   $0x1,%al
je     1435 <main+0x295>
movsd  0x0(%r13,%rcx,8),%xmm2
ucomisd %xmm9,%xmm2
ja     13f9 <main+0x259>
movsd  0xce3(%rip),%xmm4
movapd %xmm4,%xmm3
jmp    140a <main+0x26a>
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%edx
and    $0xfffffffe,%edx
xorpd  %xmm1,%xmm1
xor    %ecx,%ecx
xorpd  %xmm0,%xmm0
movsd  0xcb8(%rip),%xmm8
jmp    13ba <main+0x21a>
nopw   0x0(%rax,%rax,1)
movapd %xmm8,%xmm5
movapd %xmm9,%xmm6
subsd  %xmm4,%xmm6
movapd %xmm9,%xmm7
cmpltsd %xmm4,%xmm7
movapd %xmm7,%xmm4
andnpd %xmm6,%xmm4
andpd  %xmm8,%xmm7
orpd   %xmm4,%xmm7
addsd  %xmm7,%xmm0
addsd  %xmm2,%xmm1
addsd  %xmm5,%xmm1
movapd %xmm9,%xmm2
subsd  %xmm3,%xmm2
movapd %xmm9,%xmm4
cmpltsd %xmm3,%xmm4
movapd %xmm4,%xmm3
andnpd %xmm2,%xmm3
andpd  %xmm8,%xmm4
orpd   %xmm3,%xmm4
addsd  %xmm4,%xmm0
add    $0x2,%rcx
cmp    %rcx,%rdx
je     12fb <main+0x15b>
movsd  0x0(%r13,%rcx,8),%xmm4
ucomisd %xmm9,%xmm4
ja     13d0 <main+0x230>
movapd %xmm8,%xmm2
jmp    13d9 <main+0x239>
nop
movapd %xmm4,%xmm2
subsd  %xmm9,%xmm2
movsd  0x8(%r13,%rcx,8),%xmm3
ucomisd %xmm9,%xmm3
jbe    1350 <main+0x1b0>
movapd %xmm3,%xmm5
subsd  %xmm9,%xmm5
jmp    1355 <main+0x1b5>
movapd %xmm2,%xmm3
subsd  %xmm9,%xmm3
movsd  0xbf6(%rip),%xmm4
addsd  %xmm3,%xmm1
movapd %xmm9,%xmm3
subsd  %xmm2,%xmm3
cmpltsd %xmm2,%xmm9
movapd %xmm9,%xmm2
andnpd %xmm3,%xmm2
andpd  %xmm4,%xmm9
orpd   %xmm2,%xmm9
addsd  %xmm9,%xmm0
minsd  %xmm1,%xmm0
lea    0xc13(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
lea    0xbf0(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
cmp    $0x1,%eax
jne    1473 <main+0x2d3>
mov    0xc(%rsp),%ebp
test   %ebp,%ebp
jne    1240 <main+0xa0>
mov    0x2b6e(%rip),%rax
mov    (%rax),%edi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rsi
lea    0xb69(%rip),%rdi
jmp    14ab <main+0x30b>
lea    0xb77(%rip),%rdi
mov    %rcx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Usage: %s INPUT_FILE\0A\0A\00"
@F_OK = global i32 0
@.str.1 = [37 x i8] c"Error: INPUT_FILE %s does not exist\0A\00"
@.str.2 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [6 x i8] c"%.2lf\00"
@.str.6 = [8 x i8] c"$%.2lf\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double*
%13 = alloca [1000 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %8
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %11
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 2
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 -1)
unreachable
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = load i32, i32* @F_OK
%27 = call i64 @access(i8* %25, i32 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %22
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %22
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = load i32, i32* @stdin
%40 = call i32 @freopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %129, %35
%42 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%43 = icmp eq i32 %42, 1
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load i32, i32* %6
%46 = icmp ne i32 %45, 0
br label %47
47: ; preds = %44, %41
%48 = phi i1 [ false, %41 ], [ %46, %44 ]
br i1 %48, label %49, label %134
49: ; preds = %47
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = mul i64 %51, 8
%53 = trunc i64 %52 to i32
%54 = call double* @malloc(i32 %53)
store double* %54, double** %12
store double 0.000000e+00, double* %8
store i32 0, i32* %7
br label %55
55: ; preds = %72, %49
%56 = load i32, i32* %7
%57 = load i32, i32* %6
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %75
59: ; preds = %55
%60 = load double*, double** %12
%61 = load i32, i32* %7
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
%64 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %63)
%65 = load double*, double** %12
%66 = load i32, i32* %7
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %65, i64 %67
%69 = load double, double* %68
%70 = load double, double* %8
%71 = fadd double %70, %69
store double %71, double* %8
br label %72
72: ; preds = %59
%73 = load i32, i32* %7
%74 = add nsw i32 %73, 1
store i32 %74, i32* %7
br label %55
75: ; preds = %55
%76 = load double, double* %8
%77 = load i32, i32* %6
%78 = sitofp i32 %77 to double
%79 = fdiv double %76, %78
store double %79, double* %9
%80 = getelementptr inbounds [1000 x i8], [1000 x i8]* %13, i64 0, i64 0
%81 = load double, double* %9
%82 = call i32 @sprintf(i8* %80, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), double %81)
%83 = getelementptr inbounds [1000 x i8], [1000 x i8]* %13, i64 0, i64 0
%84 = call i32 @sscanf(i8* %83, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %9)
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %10
store i32 0, i32* %7
br label %85
85: ; preds = %118, %75
%86 = load i32, i32* %7
%87 = load i32, i32* %6
%88 = icmp slt i32 %86, %87
br i1 %88, label %89, label %121
89: ; preds = %85
%90 = load double*, double** %12
%91 = load i32, i32* %7
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds double, double* %90, i64 %92
%94 = load double, double* %93
%95 = load double, double* %9
%96 = fcmp ogt double %94, %95
br i1 %96, label %97, label %107
97: ; preds = %89
%98 = load double*, double** %12
%99 = load i32, i32* %7
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds double, double* %98, i64 %100
%102 = load double, double* %101
%103 = load double, double* %9
%104 = fsub double %102, %103
%105 = load double, double* %11
%106 = fadd double %105, %104
store double %106, double* %11
br label %117
107: ; preds = %89
%108 = load double, double* %9
%109 = load double*, double** %12
%110 = load i32, i32* %7
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds double, double* %109, i64 %111
%113 = load double, double* %112
%114 = fsub double %108, %113
%115 = load double, double* %10
%116 = fadd double %115, %114
store double %116, double* %10
br label %117
117: ; preds = %107, %97
br label %118
118: ; preds = %117
%119 = load i32, i32* %7
%120 = add nsw i32 %119, 1
store i32 %120, i32* %7
br label %85
121: ; preds = %85
%122 = load double, double* %11
%123 = load double, double* %10
%124 = fcmp ogt double %122, %123
br i1 %124, label %125, label %127
125: ; preds = %121
%126 = load double, double* %10
br label %129
127: ; preds = %121
%128 = load double, double* %11
br label %129
129: ; preds = %127, %125
%130 = phi double [ %126, %125 ], [ %128, %127 ]
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), double %130)
%132 = load double*, double** %12
%133 = call i32 @free(double* %132)
br label %41
134: ; preds = %47
%135 = load i32, i32* @stdin
%136 = call i32 @fclose(i32 %135)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Usage: %s INPUT_FILE\0A\0A\00"
@F_OK = global i32 0
@.str.1 = [37 x i8] c"Error: INPUT_FILE %s does not exist\0A\00"
@.str.2 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [6 x i8] c"%.2lf\00"
@.str.6 = [8 x i8] c"$%.2lf\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca [1000 x i8]
%6 = bitcast i32* %3 to i8*
%7 = bitcast double* %4 to i8*
store double 0.000000e+00, double* %4
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%9 = icmp eq i32 %0, 2
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 -1)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = load i32, i32* @F_OK
%18 = tail call i64 @access(i8* %16, i32 %17)
%19 = icmp eq i64 %18, 0
%20 = load i8*, i8** %15
br i1 %19, label %24, label %21
21: ; preds = %14
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%23 = tail call i32 @exit(i32 -1)
unreachable
24: ; preds = %14
%25 = load i32, i32* @stdin
%26 = tail call i32 @freopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%28 = icmp eq i32 %27, 1
%29 = load i32, i32* %3
%30 = icmp ne i32 %29, 0
%31 = select i1 %28, i1 %30, i1 false
br i1 %31, label %32, label %120
32: ; preds = %24, %108
%33 = phi i32 [ %117, %108 ], [ %29, %24 ]
%34 = shl i32 %33, 3
%35 = call double* @malloc(i32 %34)
%36 = icmp sgt i32 %33, 0
br i1 %36, label %37, label %48
37: ; preds = %32, %37
%38 = phi i64 [ %44, %37 ], [ 0, %32 ]
%39 = phi double [ %43, %37 ], [ 0.000000e+00, %32 ]
%40 = getelementptr inbounds double, double* %35, i64 %38
%41 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %40)
%42 = load double, double* %40
%43 = fadd double %39, %42
%44 = add nuw nsw i64 %38, 1
%45 = load i32, i32* %3
%46 = sext i32 %45 to i64
%47 = icmp slt i64 %44, %46
br i1 %47, label %37, label %48
48: ; preds = %37, %32
%49 = phi double [ 0.000000e+00, %32 ], [ %43, %37 ]
%50 = phi i32 [ %33, %32 ], [ %45, %37 ]
%51 = sitofp i32 %50 to double
%52 = fdiv double %49, %51
store double %52, double* %4
%53 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), double %52)
%54 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %4)
%55 = load i32, i32* %3
%56 = icmp sgt i32 %55, 0
br i1 %56, label %57, label %108
57: ; preds = %48
%58 = load double, double* %4
%59 = zext i32 %55 to i64
%60 = and i64 %59, 1
%61 = icmp eq i32 %55, 1
br i1 %61, label %91, label %62
62: ; preds = %57
%63 = and i64 %59, 4294967294
br label %64
64: ; preds = %64, %62
%65 = phi i64 [ 0, %62 ], [ %88, %64 ]
%66 = phi double [ 0.000000e+00, %62 ], [ %87, %64 ]
%67 = phi double [ 0.000000e+00, %62 ], [ %85, %64 ]
%68 = phi i64 [ 0, %62 ], [ %89, %64 ]
%69 = getelementptr inbounds double, double* %35, i64 %65
%70 = load double, double* %69
%71 = fcmp ogt double %70, %58
%72 = fsub double %70, %58
%73 = fsub double %58, %70
%74 = select i1 %71, double -0.000000e+00, double %73
%75 = fadd double %67, %74
%76 = select i1 %71, double %72, double -0.000000e+00
%77 = fadd double %66, %76
%78 = or i64 %65, 1
%79 = getelementptr inbounds double, double* %35, i64 %78
%80 = load double, double* %79
%81 = fcmp ogt double %80, %58
%82 = fsub double %80, %58
%83 = fsub double %58, %80
%84 = select i1 %81, double -0.000000e+00, double %83
%85 = fadd double %75, %84
%86 = select i1 %81, double %82, double -0.000000e+00
%87 = fadd double %77, %86
%88 = add nuw nsw i64 %65, 2
%89 = add i64 %68, 2
%90 = icmp eq i64 %89, %63
br i1 %90, label %91, label %64
91: ; preds = %64, %57
%92 = phi double [ undef, %57 ], [ %85, %64 ]
%93 = phi double [ undef, %57 ], [ %87, %64 ]
%94 = phi i64 [ 0, %57 ], [ %88, %64 ]
%95 = phi double [ 0.000000e+00, %57 ], [ %87, %64 ]
%96 = phi double [ 0.000000e+00, %57 ], [ %85, %64 ]
%97 = icmp eq i64 %60, 0
br i1 %97, label %108, label %98
98: ; preds = %91
%99 = getelementptr inbounds double, double* %35, i64 %94
%100 = load double, double* %99
%101 = fcmp ogt double %100, %58
%102 = fsub double %100, %58
%103 = fsub double %58, %100
%104 = select i1 %101, double -0.000000e+00, double %103
%105 = fadd double %96, %104
%106 = select i1 %101, double %102, double -0.000000e+00
%107 = fadd double %95, %106
br label %108
108: ; preds = %98, %91, %48
%109 = phi double [ 0.000000e+00, %48 ], [ %92, %91 ], [ %105, %98 ]
%110 = phi double [ 0.000000e+00, %48 ], [ %93, %91 ], [ %107, %98 ]
%111 = fcmp ogt double %110, %109
%112 = select i1 %111, double %109, double %110
%113 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), double %112)
%114 = call i32 @free(double* %35)
%115 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%116 = icmp eq i32 %115, 1
%117 = load i32, i32* %3
%118 = icmp ne i32 %117, 0
%119 = select i1 %116, i1 %118, i1 false
br i1 %119, label %32, label %120
120: ; preds = %108, %24
%121 = load i32, i32* @stdin
%122 = call i32 @fclose(i32 %121)
ret i32 0
}