#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 */
double jiecheng(int);
int /*<<< orphan*/ printf(char *, double);
void main() {
  int num = 1;
  double sum = 0;
  for (; num <= 20; num++) {
    sum = sum + jiecheng(num);
  }
  printf("%f\n", sum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x14,-0x4(%rbp)
jg     1172 <main+0x52>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <jiecheng@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1137 <main+0x17>
movsd  -0x10(%rbp),%xmm0
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x1,%edi
call   1030 <jiecheng@plt>
xorpd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
mov    $0x2,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x3,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x4,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x5,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x6,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x7,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x8,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x9,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xb,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xc,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xd,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xe,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xf,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x10,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x11,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x12,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x13,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x14,%edi
call   1030 <jiecheng@plt>
addsd  (%rsp),%xmm0
lea    0xd4a(%rip),%rdi
pop    %rax
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%f\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca double
store i32 1, i32* %1
store double 0.000000e+00, double* %2
br label %3
3: ; preds = %11, %0
%4 = load i32, i32* %1
%5 = icmp sle i32 %4, 20
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = load double, double* %2
%8 = load i32, i32* %1
%9 = call double @jiecheng(i32 %8)
%10 = fadd double %7, %9
store double %10, double* %2
br label %11
11: ; preds = %6
%12 = load i32, i32* %1
%13 = add nsw i32 %12, 1
store i32 %13, i32* %1
br label %3
14: ; preds = %3
%15 = load double, double* %2
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %15)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%f\0A\00"
define void @main() {
%1 = tail call double @jiecheng(i32 1)
%2 = fadd double %1, 0.000000e+00
%3 = tail call double @jiecheng(i32 2)
%4 = fadd double %2, %3
%5 = tail call double @jiecheng(i32 3)
%6 = fadd double %4, %5
%7 = tail call double @jiecheng(i32 4)
%8 = fadd double %6, %7
%9 = tail call double @jiecheng(i32 5)
%10 = fadd double %8, %9
%11 = tail call double @jiecheng(i32 6)
%12 = fadd double %10, %11
%13 = tail call double @jiecheng(i32 7)
%14 = fadd double %12, %13
%15 = tail call double @jiecheng(i32 8)
%16 = fadd double %14, %15
%17 = tail call double @jiecheng(i32 9)
%18 = fadd double %16, %17
%19 = tail call double @jiecheng(i32 10)
%20 = fadd double %18, %19
%21 = tail call double @jiecheng(i32 11)
%22 = fadd double %20, %21
%23 = tail call double @jiecheng(i32 12)
%24 = fadd double %22, %23
%25 = tail call double @jiecheng(i32 13)
%26 = fadd double %24, %25
%27 = tail call double @jiecheng(i32 14)
%28 = fadd double %26, %27
%29 = tail call double @jiecheng(i32 15)
%30 = fadd double %28, %29
%31 = tail call double @jiecheng(i32 16)
%32 = fadd double %30, %31
%33 = tail call double @jiecheng(i32 17)
%34 = fadd double %32, %33
%35 = tail call double @jiecheng(i32 18)
%36 = fadd double %34, %35
%37 = tail call double @jiecheng(i32 19)
%38 = fadd double %36, %37
%39 = tail call double @jiecheng(i32 20)
%40 = fadd double %38, %39
%41 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %40)
ret void
}