#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*/ print_array(float *, int);
int /*<<< orphan*/ printf(char *, float, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
float w_random(double, double);
void test3() {
  int i = 0;
  float s = 0;
  float r[11] = {0};
  srand(time(NULL));
  for (i = 0; i < 10; i++) {
    r[i] = w_random(6.0, 12.0);
    s += r[i];
    printf("i: %d, %.2f,  ", i, r[i]);
    printf("sum %.2f\n", s);
  }
  print_array(r, 10);
}


x86 assembly (clang, -O0):
<test3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x2c,%edx
call   1060 <memset@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    121d <test3+0xbd>
movsd  0xe50(%rip),%xmm0
movsd  0xe50(%rip),%xmm1
call   1040 <w_random@plt>
movslq -0x4(%rbp),%rax
movss  %xmm0,-0x40(%rbp,%rax,4)
movslq -0x4(%rbp),%rax
movss  -0x40(%rbp,%rax,4),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
cvtsi2ssl -0x4(%rbp),%xmm0
movslq -0x4(%rbp),%rax
movss  -0x40(%rbp,%rax,4),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe1b(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movss  -0x8(%rbp),%xmm0
lea    0xe17(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    119e <test3+0x3e>
lea    -0x40(%rbp),%rdi
mov    $0xa,%esi
call   1030 <print_array@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test3>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x2c(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
xor    %ebx,%ebx
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
lea    0xe85(%rip),%r14
lea    0xe8d(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0xe58(%rip),%xmm0
movsd  0xe58(%rip),%xmm1
call   1040 <w_random@plt>
movss  %xmm0,0x10(%rsp,%rbx,4)
movss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
xorps  %xmm2,%xmm2
cvtsi2ss %ebx,%xmm2
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
mov    %r14,%rdi
movaps %xmm2,%xmm0
mov    $0x2,%al
call   1050 <printf@plt>
mov    %r15,%rdi
movss  0xc(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0xa,%rbx
jne    11a0 <test3+0x50>
lea    0x10(%rsp),%rdi
mov    $0xa,%esi
call   1030 <print_array@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"i: %d, %.2f, \00"
@.str.1 = [10 x i8] c"sum %.2f\0A\00"
define void @test3() {
%1 = alloca i32
%2 = alloca float
%3 = alloca [11 x float]
store i32 0, i32* %1
store float 0.000000e+00, float* %2
%4 = bitcast [11 x float]* %3 to i8*
%5 = call i32 @time(i32* null)
%6 = call i32 @srand(i32 %5)
store i32 0, i32* %1
br label %7
7: ; preds = %31, %0
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %34
10: ; preds = %7
%11 = call float @w_random(double 6.000000e+00, double 1.200000e+01)
%12 = load i32, i32* %1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [11 x float], [11 x float]* %3, i64 0, i64 %13
store float %11, float* %14
%15 = load i32, i32* %1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [11 x float], [11 x float]* %3, i64 0, i64 %16
%18 = load float, float* %17
%19 = load float, float* %2
%20 = fadd float %19, %18
store float %20, float* %2
%21 = load i32, i32* %1
%22 = sitofp i32 %21 to float
%23 = load i32, i32* %1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [11 x float], [11 x float]* %3, i64 0, i64 %24
%26 = load float, float* %25
%27 = fpext float %26 to double
%28 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), float %22, double %27)
%29 = load float, float* %2
%30 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), float %29)
br label %31
31: ; preds = %10
%32 = load i32, i32* %1
%33 = add nsw i32 %32, 1
store i32 %33, i32* %1
br label %7
34: ; preds = %7
%35 = getelementptr inbounds [11 x float], [11 x float]* %3, i64 0, i64 0
%36 = call i32 @print_array(float* %35, i32 10)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"i: %d, %.2f, \00"
@.str.1 = [10 x i8] c"sum %.2f\0A\00"
define void @test3() {
%1 = alloca [11 x float]
%2 = bitcast [11 x float]* %1 to i8*
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
br label %5
5: ; preds = %0, %5
%6 = phi i64 [ 0, %0 ], [ %16, %5 ]
%7 = phi float [ 0.000000e+00, %0 ], [ %10, %5 ]
%8 = tail call float @w_random(double 6.000000e+00, double 1.200000e+01)
%9 = getelementptr inbounds [11 x float], [11 x float]* %1, i64 0, i64 %6
store float %8, float* %9
%10 = fadd float %7, %8
%11 = trunc i64 %6 to i32
%12 = sitofp i32 %11 to float
%13 = fpext float %8 to double
%14 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), float %12, double %13)
%15 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), float %10)
%16 = add nuw nsw i64 %6, 1
%17 = icmp eq i64 %16, 10
br i1 %17, label %18, label %5
18: ; preds = %5
%19 = getelementptr inbounds [11 x float], [11 x float]* %1, i64 0, i64 0
%20 = call i32 @print_array(float* %19, i32 10)
ret void
}