#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)
jge    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
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,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)
lea    0x3(%rbx),%edi
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x4(%rbx),%edi
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x5,%ebx
cmp    $0x3b9aca00,%ebx
jne    1130 <main+0x10>
lea    0xe2f(%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 slt 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 = %1, %0
%2 = phi double [ 0.000000e+00, %0 ], [ %22, %1 ]
%3 = phi i32 [ 0, %0 ], [ %23, %1 ]
%4 = tail call i64 @sqrt(i32 %3)
%5 = sitofp i64 %4 to double
%6 = fadd double %2, %5
%7 = add nuw nsw i32 %3, 1
%8 = tail call i64 @sqrt(i32 %7)
%9 = sitofp i64 %8 to double
%10 = fadd double %6, %9
%11 = add nuw nsw i32 %3, 2
%12 = tail call i64 @sqrt(i32 %11)
%13 = sitofp i64 %12 to double
%14 = fadd double %10, %13
%15 = add nuw nsw i32 %3, 3
%16 = tail call i64 @sqrt(i32 %15)
%17 = sitofp i64 %16 to double
%18 = fadd double %14, %17
%19 = add nuw nsw i32 %3, 4
%20 = tail call i64 @sqrt(i32 %19)
%21 = sitofp i64 %20 to double
%22 = fadd double %18, %21
%23 = add nuw nsw i32 %3, 5
%24 = icmp eq i32 %23, 1000000000
br i1 %24, label %25, label %1
25: ; preds = %1
%26 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %22)
ret i32 0
}