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

/* Variables and functions */
double atof(char *);
int exp10(double);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, double *);
scalar_t__ log10(double);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
int main(int argc, char *argv[]) {
  FILE *f1, *f2, *f3;
  int w;
  double f, g, mix, logp;
  if (argc == 4) {
    f1 = fopen(argv[1], "rb");
    f2 = fopen(argv[2], "rb");
    f3 = stdout;
    mix = atof(argv[3]);
    while (1) {
      fscanf(f1, "%lf", &f);
      if (feof(f1))
        break;
      fscanf(f2, "%lf", &g);
      f = f * mix + g * (1 - mix);
      fprintf(f3, "%E\n", f);
    }
    fclose(f1);
    fclose(f2);
    fclose(f3);
  } else {
    w = 0;
    logp = 0;
    while (1) {
      fscanf(stdin, "%lf", &f);
      if (feof(stdin))
        break;
      if (f > 0) {
        logp += log10(f);
        w++;
      }
    }
    printf("Log P: %lf\n", logp);
    printf("PPL: %lf\n", 1 / exp10(logp / w));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    12a7 <main+0x117>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe49(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe31(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    0x2df1(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe00(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   1060 <fscanf@plt>
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
je     122c <main+0x9c>
jmp    1287 <main+0xf7>
mov    -0x20(%rbp),%rdi
lea    0xdd4(%rip),%rsi
lea    -0x40(%rbp),%rdx
call   1060 <fscanf@plt>
movsd  -0x38(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
movsd  0xda9(%rip),%xmm3
subsd  -0x48(%rbp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
movsd  -0x38(%rbp),%xmm0
lea    0xd92(%rip),%rsi
call   1070 <fprintf@plt>
jmp    1200 <main+0x70>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1363 <main+0x1d3>
movl   $0x0,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    0x2d2b(%rip),%rax
mov    (%rax),%rdi
lea    0xd44(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   1060 <fscanf@plt>
mov    0x2d11(%rip),%rax
mov    (%rax),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
je     12ee <main+0x15e>
jmp    1327 <main+0x197>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1322 <main+0x192>
movsd  -0x38(%rbp),%xmm0
call   10a0 <log10@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12b6 <main+0x126>
cvttsd2si -0x50(%rbp),%esi
lea    0xce0(%rip),%rdi
call   1050 <printf@plt>
movsd  -0x50(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   10b0 <exp10@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xcc1(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x4,%edi
jne    12b2 <main+0x122>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
lea    0xe5b(%rip),%r14
mov    %r14,%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    0x10(%rbp),%rdi
mov    %r14,%rsi
call   1090 <fopen@plt>
mov    %rax,%r15
mov    0x2e02(%rip),%rax
mov    (%rax),%r14
mov    0x18(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe24(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
call   1060 <fscanf@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    1298 <main+0x108>
movsd  0xdeb(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
lea    0xdeb(%rip),%rbp
lea    0xde8(%rip),%r13
lea    0x10(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %rbp,%rsi
lea    0x20(%rsp),%rdx
call   1060 <fscanf@plt>
movsd  0x20(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r14,%rdi
mov    %r13,%rsi
call   1070 <fprintf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
call   1060 <fscanf@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %rax,%rax
je     1240 <main+0xb0>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
jmp    132d <main+0x19d>
mov    0x2d2f(%rip),%rbx
mov    (%rbx),%rdi
lea    0xd50(%rip),%rsi
lea    0x10(%rsp),%rdx
call   1060 <fscanf@plt>
mov    (%rbx),%rdi
call   1080 <feof@plt>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %r14d,%r14d
mov    $0x0,%ebp
test   %rax,%rax
je     133e <main+0x1ae>
cvttsd2si 0x8(%rsp),%esi
lea    0xd22(%rip),%rdi
call   1050 <printf@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
movsd  0x8(%rsp),%xmm0
divsd  %xmm1,%xmm0
call   10b0 <exp10@plt>
lea    0x1(%rax),%ecx
cmp    $0x3,%ecx
cmovb  %eax,%r14d
lea    0xd02(%rip),%rdi
mov    %r14d,%esi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
lea    0xccc(%rip),%r15
lea    0x10(%rsp),%r12
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    137f <main+0x1ef>
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <fscanf@plt>
mov    (%rbx),%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    12ec <main+0x15c>
movsd  0x10(%rsp),%xmm0
ucomisd 0xc7b(%rip),%xmm0
jbe    1360 <main+0x1d0>
call   10a0 <log10@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
add    $0x1,%ebp
jmp    1360 <main+0x1d0>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@stdout = global i32* null
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [4 x i8] c"%E\0A\00"
@stdin = global i32* null
@.str.3 = [12 x i8] c"Log P: %lf\0A\00"
@.str.4 = [10 x i8] c"PPL: %lf\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 i32*
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 4
br i1 %15, label %16, label %57
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %6
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %24, i32** %7
%25 = load i32*, i32** @stdout
store i32* %25, i32** %8
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
%29 = call double @atof(i8* %28)
store double %29, double* %12
br label %30
30: ; preds = %16, %37
%31 = load i32*, i32** %6
%32 = call i32 @fscanf(i32* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %10)
%33 = load i32*, i32** %6
%34 = call i64 @feof(i32* %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %30
br label %50
37: ; preds = %30
%38 = load i32*, i32** %7
%39 = call i32 @fscanf(i32* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %11)
%40 = load double, double* %10
%41 = load double, double* %12
%42 = load double, double* %11
%43 = load double, double* %12
%44 = fsub double 1.000000e+00, %43
%45 = fmul double %42, %44
%46 = call double @llvm.fmuladd.f64(double %40, double %41, double %45)
store double %46, double* %10
%47 = load i32*, i32** %8
%48 = load double, double* %10
%49 = call i32 @fprintf(i32* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %48)
br label %30
50: ; preds = %36
%51 = load i32*, i32** %6
%52 = call i32 @fclose(i32* %51)
%53 = load i32*, i32** %7
%54 = call i32 @fclose(i32* %53)
%55 = load i32*, i32** %8
%56 = call i32 @fclose(i32* %55)
br label %88
57: ; preds = %2
store i32 0, i32* %9
store double 0.000000e+00, double* %13
br label %58
58: ; preds = %57, %76
%59 = load i32*, i32** @stdin
%60 = call i32 @fscanf(i32* %59, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %10)
%61 = load i32*, i32** @stdin
%62 = call i64 @feof(i32* %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %58
br label %77
65: ; preds = %58
%66 = load double, double* %10
%67 = fcmp ogt double %66, 0.000000e+00
br i1 %67, label %68, label %76
68: ; preds = %65
%69 = load double, double* %10
%70 = call i64 @log10(double %69)
%71 = sitofp i64 %70 to double
%72 = load double, double* %13
%73 = fadd double %72, %71
store double %73, double* %13
%74 = load i32, i32* %9
%75 = add nsw i32 %74, 1
store i32 %75, i32* %9
br label %76
76: ; preds = %68, %65
br label %58
77: ; preds = %64
%78 = load double, double* %13
%79 = fptosi double %78 to i32
%80 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %79)
%81 = load double, double* %13
%82 = load i32, i32* %9
%83 = sitofp i32 %82 to double
%84 = fdiv double %81, %83
%85 = call i32 @exp10(double %84)
%86 = sdiv i32 1, %85
%87 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %86)
br label %88
88: ; preds = %77, %50
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@stdout = global i32* null
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [4 x i8] c"%E\0A\00"
@stdin = global i32* null
@.str.3 = [12 x i8] c"Log P: %lf\0A\00"
@.str.4 = [10 x i8] c"PPL: %lf\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %3 to i8*
%6 = bitcast double* %4 to i8*
%7 = icmp eq i32 %0, 4
br i1 %7, label %14, label %8
8: ; preds = %2
%9 = load i32*, i32** @stdin
%10 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%11 = load i32*, i32** @stdin
%12 = call i64 @feof(i32* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %44, label %62
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%21 = load i32*, i32** @stdout
%22 = getelementptr inbounds i8*, i8** %1, i64 3
%23 = load i8*, i8** %22
%24 = tail call double @atof(i8* %23)
%25 = call i32 @fscanf(i32* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%26 = call i64 @feof(i32* %17)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %40
28: ; preds = %14
%29 = fsub double 1.000000e+00, %24
br label %30
30: ; preds = %28, %30
%31 = call i32 @fscanf(i32* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
%32 = load double, double* %3
%33 = load double, double* %4
%34 = fmul double %29, %33
%35 = call double @llvm.fmuladd.f64(double %32, double %24, double %34)
store double %35, double* %3
%36 = call i32 @fprintf(i32* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %35)
%37 = call i32 @fscanf(i32* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%38 = call i64 @feof(i32* %17)
%39 = icmp eq i64 %38, 0
br i1 %39, label %30, label %40
40: ; preds = %30, %14
%41 = call i32 @fclose(i32* %17)
%42 = call i32 @fclose(i32* %20)
%43 = call i32 @fclose(i32* %21)
br label %74
44: ; preds = %8, %54
%45 = phi double [ %56, %54 ], [ 0.000000e+00, %8 ]
%46 = phi i32 [ %55, %54 ], [ 0, %8 ]
%47 = load double, double* %3
%48 = fcmp ogt double %47, 0.000000e+00
br i1 %48, label %49, label %54
49: ; preds = %44
%50 = call i64 @log10(double %47)
%51 = sitofp i64 %50 to double
%52 = fadd double %45, %51
%53 = add nsw i32 %46, 1
br label %54
54: ; preds = %49, %44
%55 = phi i32 [ %53, %49 ], [ %46, %44 ]
%56 = phi double [ %52, %49 ], [ %45, %44 ]
%57 = load i32*, i32** @stdin
%58 = call i32 @fscanf(i32* %57, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%59 = load i32*, i32** @stdin
%60 = call i64 @feof(i32* %59)
%61 = icmp eq i64 %60, 0
br i1 %61, label %44, label %62
62: ; preds = %54, %8
%63 = phi i32 [ 0, %8 ], [ %55, %54 ]
%64 = phi double [ 0.000000e+00, %8 ], [ %56, %54 ]
%65 = fptosi double %64 to i32
%66 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %65)
%67 = sitofp i32 %63 to double
%68 = fdiv double %64, %67
%69 = call i32 @exp10(double %68)
%70 = add i32 %69, 1
%71 = icmp ult i32 %70, 3
%72 = select i1 %71, i32 %69, i32 0
%73 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %72)
br label %74
74: ; preds = %62, %40
ret i32 0
}