#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__ POV_RAND();
int /*<<< orphan*/ printf(char *, double);
int main() {
  int i;
  double tmp = 0.0;
  for (i = 0; i < 10; ++i) {
    tmp += POV_RAND();
  }
  if (tmp != 197643.0) {
    printf("expect:197643.000000, but got:%f\n", tmp);
    return 1;
  }
  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   $0xa,-0x8(%rbp)
jge    116c <main+0x4c>
mov    $0x0,%al
call   1040 <POV_RAND@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
movsd  0xe87(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    118e <main+0x6e>
jp     118e <main+0x6e>
jmp    11ab <main+0x8b>
movsd  -0x10(%rbp),%xmm0
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b2 <main+0x92>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <POV_RAND@plt>
cvtsi2sd %rax,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <POV_RAND@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <POV_RAND@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <POV_RAND@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <POV_RAND@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <POV_RAND@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <POV_RAND@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <POV_RAND@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <POV_RAND@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <POV_RAND@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
ucomisd 0xdd2(%rip),%xmm0
jne    1232 <main+0x112>
jnp    1243 <main+0x123>
lea    0xdcf(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [34 x i8] c"expect:197643.000000, but got:%f\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 = %12, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = call i64 (...) @POV_RAND()
%9 = sitofp i64 %8 to double
%10 = load double, double* %3
%11 = fadd double %10, %9
store double %11, double* %3
br label %12
12: ; preds = %7
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
br label %4
15: ; preds = %4
%16 = load double, double* %3
%17 = fcmp une double %16, 1.976430e+05
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load double, double* %3
%20 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), double %19)
store i32 1, i32* %1
br label %22
21: ; preds = %15
store i32 0, i32* %1
br label %22
22: ; preds = %21, %18
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [34 x i8] c"expect:197643.000000, but got:%f\0A\00"
define i32 @main() {
%1 = tail call i64 (...) @POV_RAND()
%2 = sitofp i64 %1 to double
%3 = tail call i64 (...) @POV_RAND()
%4 = sitofp i64 %3 to double
%5 = fadd double %2, %4
%6 = tail call i64 (...) @POV_RAND()
%7 = sitofp i64 %6 to double
%8 = fadd double %5, %7
%9 = tail call i64 (...) @POV_RAND()
%10 = sitofp i64 %9 to double
%11 = fadd double %8, %10
%12 = tail call i64 (...) @POV_RAND()
%13 = sitofp i64 %12 to double
%14 = fadd double %11, %13
%15 = tail call i64 (...) @POV_RAND()
%16 = sitofp i64 %15 to double
%17 = fadd double %14, %16
%18 = tail call i64 (...) @POV_RAND()
%19 = sitofp i64 %18 to double
%20 = fadd double %17, %19
%21 = tail call i64 (...) @POV_RAND()
%22 = sitofp i64 %21 to double
%23 = fadd double %20, %22
%24 = tail call i64 (...) @POV_RAND()
%25 = sitofp i64 %24 to double
%26 = fadd double %23, %25
%27 = tail call i64 (...) @POV_RAND()
%28 = sitofp i64 %27 to double
%29 = fadd double %26, %28
%30 = fcmp une double %29, 1.976430e+05
br i1 %30, label %31, label %33
31: ; preds = %0
%32 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), double %29)
br label %33
33: ; preds = %0, %31
%34 = phi i32 [ 1, %31 ], [ 0, %0 ]
ret i32 %34
}