#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 */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
double log(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, double, double, double, double);
int main(void) {
  FILE *f = NULL;
  if ((f = fopen("speedup.txt", "w")) < 0) {
    perror("fopen");
    exit(EXIT_FAILURE);
  }
  FILE *g = NULL;
  if ((g = fopen("efficiency.txt", "w")) < 0) {
    perror("fopen");
    exit(EXIT_FAILURE);
  }
  double n = 10;
  double p = 1;
  double speedUp = 0;
  double efficiency = 0;
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 8; j++) {
      speedUp = n * n / ((n * n) / p + (log(p) / log(2)));
      efficiency = n * n / (p * (n * n) / p + (log(p) / log(2)));
      fprintf(f, "%lf\t", speedUp);
      fprintf(g, "%lf\t", efficiency);
      printf("n = %lf, p = %lf, speedup = %lf, efficiency = %lf\n", n, p,
             speedUp, efficiency);
      p *= 2;
    }
    fprintf(f, "\n");
    fprintf(g, "\n");
    n *= 2;
    p = 1;
  }
  fclose(f);
  fclose(g);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jae    11c2 <main+0x52>
lea    0xe77(%rip),%rdi
call   1080 <perror@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
movq   $0x0,-0x18(%rbp)
lea    0xe5b(%rip),%rdi
lea    0xe4c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jae    1205 <main+0x95>
lea    0xe34(%rip),%rdi
call   1080 <perror@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
movsd  0xdfb(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xde6(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x6,-0x3c(%rbp)
jge    13d7 <main+0x267>
movl   $0x0,-0x40(%rbp)
cmpl   $0x8,-0x40(%rbp)
jge    1386 <main+0x216>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
cvttsd2si -0x28(%rbp),%edi
call   1060 <log@plt>
movsd  %xmm0,-0x70(%rbp)
mov    $0x2,%edi
call   1060 <log@plt>
movsd  -0x70(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
movaps %xmm0,%xmm3
movsd  -0x60(%rbp),%xmm0
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
cvttsd2si -0x28(%rbp),%edi
call   1060 <log@plt>
movsd  %xmm0,-0x58(%rbp)
mov    $0x2,%edi
call   1060 <log@plt>
movsd  -0x58(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
movaps %xmm0,%xmm3
movsd  -0x48(%rbp),%xmm0
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
movsd  -0x30(%rbp),%xmm0
lea    0xd13(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
movsd  -0x38(%rbp),%xmm0
lea    0xcfc(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
lea    0xcdf(%rip),%rdi
call   1040 <printf@plt>
movsd  0xca2(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1247 <main+0xd7>
mov    -0x10(%rbp),%rdi
lea    0xce0(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xcce(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movsd  0xc5e(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xc3c(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1236 <main+0xc6>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xe9b(%rip),%rdi
lea    0xea0(%rip),%rbx
mov    %rbx,%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe90(%rip),%rdi
mov    %rbx,%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
movsd  0xe5f(%rip),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
lea    0xe7e(%rip),%rbx
lea    0xe7c(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %eax,0xc(%rsp)
movsd  (%rsp),%xmm0
mulsd  %xmm0,%xmm0
movapd %xmm0,0x40(%rsp)
mov    $0x8,%r13d
movsd  0xe27(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movapd %xmm0,0x10(%rsp)
cvttsd2si %xmm0,%ebp
mov    %ebp,%edi
call   1070 <log@plt>
movapd %xmm0,0x30(%rsp)
mov    $0x2,%edi
call   1070 <log@plt>
movapd 0x40(%rsp),%xmm3
movapd %xmm3,%xmm1
unpcklpd 0x30(%rsp),%xmm1
movapd 0x10(%rsp),%xmm2
unpcklpd %xmm0,%xmm2
divpd  %xmm2,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm3,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x30(%rsp)
mulsd  0x10(%rsp),%xmm3
movapd %xmm3,0x20(%rsp)
mov    %ebp,%edi
call   1070 <log@plt>
movapd %xmm0,0x50(%rsp)
mov    $0x2,%edi
call   1070 <log@plt>
movapd 0x20(%rsp),%xmm2
unpcklpd 0x50(%rsp),%xmm2
movapd 0x10(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
divpd  %xmm1,%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
addsd  %xmm2,%xmm0
movapd 0x40(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  0x30(%rsp),%xmm0
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
movsd  0x20(%rsp),%xmm0
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    %r12,%rdi
movsd  (%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
call   1040 <printf@plt>
movapd 0x10(%rsp),%xmm0
addsd  %xmm0,%xmm0
add    $0xffffffff,%r13d
jne    11f0 <main+0x90>
mov    $0xa,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
mov    $0xa,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
movsd  (%rsp),%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
mov    0xc(%rsp),%eax
add    $0x1,%eax
cmp    $0x6,%eax
jne    11c0 <main+0x60>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"speedup.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [6 x i8] c"fopen\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [15 x i8] c"efficiency.txt\00"
@.str.4 = [5 x i8] c"%lf\09\00"
@.str.5 = [51 x i8] c"n = %lf, p = %lf, speedup = %lf, efficiency = %lf\0A\00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32* null, i32** %2
%10 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %2
%11 = icmp ult i32* %10, null
br i1 %11, label %12, label %16
12: ; preds = %0
%13 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %0
store i32* null, i32** %3
%17 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %3
%18 = icmp ult i32* %17, null
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %16
store double 1.000000e+01, double* %4
store double 1.000000e+00, double* %5
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %7
store i32 0, i32* %8
br label %24
24: ; preds = %87, %23
%25 = load i32, i32* %8
%26 = icmp slt i32 %25, 6
br i1 %26, label %27, label %90
27: ; preds = %24
store i32 0, i32* %9
br label %28
28: ; preds = %77, %27
%29 = load i32, i32* %9
%30 = icmp slt i32 %29, 8
br i1 %30, label %31, label %80
31: ; preds = %28
%32 = load double, double* %4
%33 = load double, double* %4
%34 = fmul double %32, %33
%35 = load double, double* %4
%36 = load double, double* %4
%37 = fmul double %35, %36
%38 = load double, double* %5
%39 = fdiv double %37, %38
%40 = load double, double* %5
%41 = fptosi double %40 to i32
%42 = call double @log(i32 %41)
%43 = call double @log(i32 2)
%44 = fdiv double %42, %43
%45 = fadd double %39, %44
%46 = fdiv double %34, %45
store double %46, double* %6
%47 = load double, double* %4
%48 = load double, double* %4
%49 = fmul double %47, %48
%50 = load double, double* %5
%51 = load double, double* %4
%52 = load double, double* %4
%53 = fmul double %51, %52
%54 = fmul double %50, %53
%55 = load double, double* %5
%56 = fdiv double %54, %55
%57 = load double, double* %5
%58 = fptosi double %57 to i32
%59 = call double @log(i32 %58)
%60 = call double @log(i32 2)
%61 = fdiv double %59, %60
%62 = fadd double %56, %61
%63 = fdiv double %49, %62
store double %63, double* %7
%64 = load i32*, i32** %2
%65 = load double, double* %6
%66 = call i32 (i32*, i8*, ...) @fprintf(i32* %64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %65)
%67 = load i32*, i32** %3
%68 = load double, double* %7
%69 = call i32 (i32*, i8*, ...) @fprintf(i32* %67, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %68)
%70 = load double, double* %4
%71 = load double, double* %5
%72 = load double, double* %6
%73 = load double, double* %7
%74 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), double %70, double %71, double %72, double %73)
%75 = load double, double* %5
%76 = fmul double %75, 2.000000e+00
store double %76, double* %5
br label %77
77: ; preds = %31
%78 = load i32, i32* %9
%79 = add nsw i32 %78, 1
store i32 %79, i32* %9
br label %28
80: ; preds = %28
%81 = load i32*, i32** %2
%82 = call i32 (i32*, i8*, ...) @fprintf(i32* %81, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%83 = load i32*, i32** %3
%84 = call i32 (i32*, i8*, ...) @fprintf(i32* %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%85 = load double, double* %4
%86 = fmul double %85, 2.000000e+00
store double %86, double* %4
store double 1.000000e+00, double* %5
br label %87
87: ; preds = %80
%88 = load i32, i32* %8
%89 = add nsw i32 %88, 1
store i32 %89, i32* %8
br label %24
90: ; preds = %24
%91 = load i32*, i32** %2
%92 = call i32 @fclose(i32* %91)
%93 = load i32*, i32** %3
%94 = call i32 @fclose(i32* %93)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"speedup.txt\00"
@.str.1 = [2 x i8] c"w\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [15 x i8] c"efficiency.txt\00"
@.str.4 = [5 x i8] c"%lf\09\00"
@.str.5 = [51 x i8] c"n = %lf, p = %lf, speedup = %lf, efficiency = %lf\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %3
3: ; preds = %0, %11
%4 = phi i32 [ 0, %0 ], [ %15, %11 ]
%5 = phi double [ 1.000000e+01, %0 ], [ %14, %11 ]
%6 = fmul double %5, %5
%7 = insertelement <2 x double> poison, double %6, i64 0
br label %17
8: ; preds = %11
%9 = tail call i32 @fclose(i32* %1)
%10 = tail call i32 @fclose(i32* %2)
ret i32 0
11: ; preds = %17
%12 = tail call i32 @fputc(i32 10, i32* %1)
%13 = tail call i32 @fputc(i32 10, i32* %2)
%14 = fmul double %5, 2.000000e+00
%15 = add nuw nsw i32 %4, 1
%16 = icmp eq i32 %15, 6
br i1 %16, label %8, label %3
17: ; preds = %3, %17
%18 = phi i32 [ 0, %3 ], [ %46, %17 ]
%19 = phi double [ 1.000000e+00, %3 ], [ %45, %17 ]
%20 = fptosi double %19 to i32
%21 = tail call double @log(i32 %20)
%22 = tail call double @log(i32 2)
%23 = insertelement <2 x double> %7, double %21, i64 1
%24 = insertelement <2 x double> poison, double %19, i64 0
%25 = insertelement <2 x double> %24, double %22, i64 1
%26 = fdiv <2 x double> %23, %25
%27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%28 = fadd <2 x double> %26, %27
%29 = extractelement <2 x double> %28, i64 0
%30 = fdiv double %6, %29
%31 = fmul double %6, %19
%32 = tail call double @log(i32 %20)
%33 = tail call double @log(i32 2)
%34 = insertelement <2 x double> poison, double %31, i64 0
%35 = insertelement <2 x double> %34, double %32, i64 1
%36 = insertelement <2 x double> %24, double %33, i64 1
%37 = fdiv <2 x double> %35, %36
%38 = shufflevector <2 x double> %37, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%39 = fadd <2 x double> %37, %38
%40 = extractelement <2 x double> %39, i64 0
%41 = fdiv double %6, %40
%42 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %30)
%43 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %41)
%44 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), double %5, double %19, double %30, double %41)
%45 = fmul double %19, 2.000000e+00
%46 = add nuw nsw i32 %18, 1
%47 = icmp eq i32 %46, 8
br i1 %47, label %11, label %17
}