#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 */
double mean(double *, int);
int /*<<< orphan*/ printf(char *, double);
int rand();
double sd(double *, int);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  double x[100];
  srand((unsigned int)time(NULL));
  for (int i = 0; i < 100; i++)
    x[i] = rand() % 100;
  printf("mean:\t%f\n", mean(x, 100));
  printf("sd:  \t%f\n", sd(x, 100));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x334(%rbp)
cmpl   $0x64,-0x334(%rbp)
jge    11d7 <main+0x77>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movslq -0x334(%rbp),%rax
movsd  %xmm0,-0x330(%rbp,%rax,8)
ff ff
mov    -0x334(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x334(%rbp)
jmp    1193 <main+0x33>
lea    -0x330(%rbp),%rdi
mov    $0x64,%esi
call   1070 <mean@plt>
lea    0xe11(%rip),%rdi
call   1040 <printf@plt>
lea    -0x330(%rbp),%rdi
mov    $0x64,%esi
call   1030 <sd@plt>
lea    0xdfe(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x340,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x320,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1180 <main+0x20>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <mean@plt>
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1030 <sd@plt>
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x320,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"mean:\09%f\0A\00"
@.str.1 = [10 x i8] c"sd: \09%f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x double]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i64 @time(i32* null)
%9 = trunc i64 %8 to i32
%10 = call i32 @srand(i32 %9)
store i32 0, i32* %7
br label %11
11: ; preds = %21, %2
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 100
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 100
%17 = sitofp i32 %16 to double
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100 x double], [100 x double]* %6, i64 0, i64 %19
store double %17, double* %20
br label %21
21: ; preds = %14
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
br label %11
24: ; preds = %11
%25 = getelementptr inbounds [100 x double], [100 x double]* %6, i64 0, i64 0
%26 = call double @mean(double* %25, i32 100)
%27 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %26)
%28 = getelementptr inbounds [100 x double], [100 x double]* %6, i64 0, i64 0
%29 = call double @sd(double* %28, i32 100)
%30 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"mean:\09%f\0A\00"
@.str.1 = [10 x i8] c"sd: \09%f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x double]
%4 = bitcast [100 x double]* %3 to i8*
%5 = tail call i64 @time(i32* null)
%6 = trunc i64 %5 to i32
%7 = tail call i32 @srand(i32 %6)
br label %14
8: ; preds = %14
%9 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 0
%10 = call double @mean(double* %9, i32 100)
%11 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %10)
%12 = call double @sd(double* %9, i32 100)
%13 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %12)
ret i32 0
14: ; preds = %2, %14
%15 = phi i64 [ 0, %2 ], [ %20, %14 ]
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, 100
%18 = sitofp i32 %17 to double
%19 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %15
store double %18, double* %19
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, 100
br i1 %21, label %8, label %14
}