#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 */
scalar_t__ function_a(long);
scalar_t__ function_b(long);
double function_F(long a) {
  double r = 0;
  for (long i = 0; i < a; i++)
    r += function_a(i) + function_b(i);
  return r;
}


x86 assembly (clang, -O0):
<function_F>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    118a <function_F+0x6a>
mov    -0x18(%rbp),%rdi
call   1040 <function_a@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <function_b@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
add    %rcx,%rax
cvtsi2sd %rax,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    113c <function_F+0x1c>
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<function_F>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
jle    1185 <function_F+0x65>
mov    %rdi,%r14
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <function_a@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <function_b@plt>
add    %r15,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1140 <function_F+0x20>
jmp    1188 <function_F+0x68>
xorps  %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @function_F(i64 %0) {
%2 = alloca i64
%3 = alloca double
%4 = alloca i64
store i64 %0, i64* %2
store double 0.000000e+00, double* %3
store i64 0, i64* %4
br label %5
5: ; preds = %18, %1
%6 = load i64, i64* %4
%7 = load i64, i64* %2
%8 = icmp slt i64 %6, %7
br i1 %8, label %9, label %21
9: ; preds = %5
%10 = load i64, i64* %4
%11 = call i64 @function_a(i64 %10)
%12 = load i64, i64* %4
%13 = call i64 @function_b(i64 %12)
%14 = add nsw i64 %11, %13
%15 = sitofp i64 %14 to double
%16 = load double, double* %3
%17 = fadd double %16, %15
store double %17, double* %3
br label %18
18: ; preds = %9
%19 = load i64, i64* %4
%20 = add nsw i64 %19, 1
store i64 %20, i64* %4
br label %5
21: ; preds = %5
%22 = load double, double* %3
ret double %22
}

LLVM IR (-O2):
define double @function_F(i64 %0) {
%2 = icmp sgt i64 %0, 0
br i1 %2, label %5, label %3
3: ; preds = %5, %1
%4 = phi double [ 0.000000e+00, %1 ], [ %12, %5 ]
ret double %4
5: ; preds = %1, %5
%6 = phi i64 [ %13, %5 ], [ 0, %1 ]
%7 = phi double [ %12, %5 ], [ 0.000000e+00, %1 ]
%8 = tail call i64 @function_a(i64 %6)
%9 = tail call i64 @function_b(i64 %6)
%10 = add nsw i64 %9, %8
%11 = sitofp i64 %10 to double
%12 = fadd double %7, %11
%13 = add nuw nsw i64 %6, 1
%14 = icmp eq i64 %13, %0
br i1 %14, label %3, label %5
}