#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*/ printf(char *, double);
scalar_t__ sqrt(int);
int main() {
  int i;
  double v = 0.0;
#pragma omp parallel for firstprivate(v) lastprivate(v)
  for (i = 0; i <= 1000000000; i++) {
    v += sqrt(i);
  }
  printf("%lf\n", v);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x3b9aca00,-0x8(%rbp)
jg     1170 <main+0x50>
mov    -0x8(%rbp),%edi
call   1040 <sqrt@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113e <main+0x1e>
movsd  -0x10(%rbp),%xmm0
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x1,%ebx
cmp    $0x3b9aca01,%ebx
je     11c5 <main+0xa5>
mov    %ebx,%edi
movsd  %xmm0,0x8(%rsp)
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
lea    0x1(%rbx),%edi
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x2(%rbx),%edi
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0x3,%ebx
jmp    1140 <main+0x20>
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%lf\0A\00"
define i32 @main() {
br label %1
1: ; preds = %9, %0
%2 = phi double [ 0.000000e+00, %0 ], [ %20, %9 ]
%3 = phi i32 [ 0, %0 ], [ %21, %9 ]
%4 = tail call i64 @sqrt(i32 %3)
%5 = sitofp i64 %4 to double
%6 = fadd double %2, %5
%7 = or i32 %3, 1
%8 = icmp eq i32 %7, 1000000001
br i1 %8, label %22, label %9
9: ; preds = %1
%10 = tail call i64 @sqrt(i32 %7)
%11 = sitofp i64 %10 to double
%12 = fadd double %6, %11
%13 = or i32 %3, 2
%14 = tail call i64 @sqrt(i32 %13)
%15 = sitofp i64 %14 to double
%16 = fadd double %12, %15
%17 = or i32 %3, 3
%18 = tail call i64 @sqrt(i32 %17)
%19 = sitofp i64 %18 to double
%20 = fadd double %16, %19
%21 = add nuw nsw i32 %3, 4
br label %1
22: ; preds = %1
%23 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %6)
ret i32 0
}