#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 *malloc(int);
double omp_get_wtime();
int /*<<< orphan*/ printf(char *, double, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  srand(time(NULL));
  int i = 0;
  double *mainVector = malloc(100000000 * sizeof(double));
  double *divVector = malloc(100000000 * sizeof(double));
  double *solVector = malloc(100000000 * sizeof(double));
  double x = rand();
  printf("%lf\n", x);
  for (i = 0; i < 100000000; i++) {
    mainVector[i] = (rand() % 10000000) * 0.01;
    divVector[i] = (rand() % 1000) * 0.01;
    solVector[i] = 0;
  }
  if (0) {
    for (i = 0; i < 100000000; i++) {
      printf("  %5.2lf %1.2lf\n", mainVector[i], divVector[i]);
    }
  }
  double start = omp_get_wtime();
#pragma omp parallel for shared(mainVector, divVector, solVector) private(i)   \
    schedule(static, 10) num_threads(4)
  for (i = 0; i < 100000000; i++) {
    solVector[i] = mainVector[i] / divVector[i];
  }
  double end = omp_get_wtime();
  if (0) {
    for (i = 0; i < 100000000; i++) {
      printf("  %1.2lf\n", solVector[i]);
    }
  }
  double solTime = end - start;
  printf("Vector Division Complete - %lf Seconds\n", solTime);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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,-0x14(%rbp)
mov    $0x2faf0800,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x2faf0800,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x2faf0800,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
lea    0xe35(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x5f5e100,-0x14(%rbp)
jge    1264 <main+0x104>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x989680,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movsd  0xdf7(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movsd  0xdcb(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movslq -0x14(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e1 <main+0x81>
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x5f5e100,-0x14(%rbp)
jge    12b9 <main+0x159>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1277 <main+0x117>
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
lea    0xd2d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x2faf0800,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0x2faf0800,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    $0x2faf0800,%edi
call   1070 <malloc@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1080 <rand@plt>
cvtsi2sd %eax,%xmm0
lea    0xe59(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x6b5fca6b,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x36,%rcx
add    %edx,%ecx
imul   $0x989680,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe0c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%r14,%rbx,8)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xdce(%rip),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
movq   $0x0,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    $0x5f5e100,%rbx
jne    11c0 <main+0x60>
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,(%rsp)
mov    $0x2,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movupd -0x10(%r14,%rax,8),%xmm0
movupd -0x10(%r15,%rax,8),%xmm1
divpd  %xmm1,%xmm0
movupd %xmm0,-0x10(%r12,%rax,8)
movupd (%r14,%rax,8),%xmm0
movupd (%r15,%rax,8),%xmm1
divpd  %xmm1,%xmm0
movupd %xmm0,(%r12,%rax,8)
add    $0x4,%rax
cmp    $0x5f5e102,%rax
jne    1270 <main+0x110>
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
subsd  (%rsp),%xmm0
lea    0xd4f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lf\0A\00"
@.str.1 = [40 x i8] c"Vector Division Complete - %lf Seconds\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32 @time(i32* null)
%15 = call i32 @srand(i32 %14)
store i32 0, i32* %6
%16 = call double* @malloc(i32 800000000)
store double* %16, double** %7
%17 = call double* @malloc(i32 800000000)
store double* %17, double** %8
%18 = call double* @malloc(i32 800000000)
store double* %18, double** %9
%19 = call i32 (...) @rand()
%20 = sitofp i32 %19 to double
store double %20, double* %10
%21 = load double, double* %10
%22 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %21)
store i32 0, i32* %6
br label %23
23: ; preds = %47, %2
%24 = load i32, i32* %6
%25 = icmp slt i32 %24, 100000000
br i1 %25, label %26, label %50
26: ; preds = %23
%27 = call i32 (...) @rand()
%28 = srem i32 %27, 10000000
%29 = sitofp i32 %28 to double
%30 = fmul double %29, 1.000000e-02
%31 = load double*, double** %7
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
store double %30, double* %34
%35 = call i32 (...) @rand()
%36 = srem i32 %35, 1000
%37 = sitofp i32 %36 to double
%38 = fmul double %37, 1.000000e-02
%39 = load double*, double** %8
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
store double %38, double* %42
%43 = load double*, double** %9
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
store double 0.000000e+00, double* %46
br label %47
47: ; preds = %26
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %23
50: ; preds = %23
%51 = call double (...) @omp_get_wtime()
store double %51, double* %11
store i32 0, i32* %6
br label %52
52: ; preds = %71, %50
%53 = load i32, i32* %6
%54 = icmp slt i32 %53, 100000000
br i1 %54, label %55, label %74
55: ; preds = %52
%56 = load double*, double** %7
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
%60 = load double, double* %59
%61 = load double*, double** %8
%62 = load i32, i32* %6
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds double, double* %61, i64 %63
%65 = load double, double* %64
%66 = fdiv double %60, %65
%67 = load double*, double** %9
%68 = load i32, i32* %6
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double, double* %67, i64 %69
store double %66, double* %70
br label %71
71: ; preds = %55
%72 = load i32, i32* %6
%73 = add nsw i32 %72, 1
store i32 %73, i32* %6
br label %52
74: ; preds = %52
%75 = call double (...) @omp_get_wtime()
store double %75, double* %12
%76 = load double, double* %12
%77 = load double, double* %11
%78 = fsub double %76, %77
store double %78, double* %13
%79 = load double, double* %13
%80 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), double %79)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lf\0A\00"
@.str.1 = [40 x i8] c"Vector Division Complete - %lf Seconds\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = tail call double* @malloc(i32 800000000)
%6 = tail call double* @malloc(i32 800000000)
%7 = tail call double* @malloc(i32 800000000)
%8 = tail call i32 (...) @rand()
%9 = sitofp i32 %8 to double
%10 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %9)
br label %11
11: ; preds = %2, %11
%12 = phi i64 [ 0, %2 ], [ %24, %11 ]
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 10000000
%15 = sitofp i32 %14 to double
%16 = fmul double %15, 1.000000e-02
%17 = getelementptr inbounds double, double* %5, i64 %12
store double %16, double* %17
%18 = tail call i32 (...) @rand()
%19 = srem i32 %18, 1000
%20 = sitofp i32 %19 to double
%21 = fmul double %20, 1.000000e-02
%22 = getelementptr inbounds double, double* %6, i64 %12
store double %21, double* %22
%23 = getelementptr inbounds double, double* %7, i64 %12
store double 0.000000e+00, double* %23
%24 = add nuw nsw i64 %12, 1
%25 = icmp eq i64 %24, 100000000
br i1 %25, label %26, label %11
26: ; preds = %11
%27 = tail call double (...) @omp_get_wtime()
br label %28
28: ; preds = %28, %26
%29 = phi i64 [ 0, %26 ], [ %49, %28 ]
%30 = getelementptr inbounds double, double* %5, i64 %29
%31 = bitcast double* %30 to <2 x double>*
%32 = load <2 x double>, <2 x double>* %31
%33 = getelementptr inbounds double, double* %6, i64 %29
%34 = bitcast double* %33 to <2 x double>*
%35 = load <2 x double>, <2 x double>* %34
%36 = fdiv <2 x double> %32, %35
%37 = getelementptr inbounds double, double* %7, i64 %29
%38 = bitcast double* %37 to <2 x double>*
store <2 x double> %36, <2 x double>* %38
%39 = or i64 %29, 2
%40 = getelementptr inbounds double, double* %5, i64 %39
%41 = bitcast double* %40 to <2 x double>*
%42 = load <2 x double>, <2 x double>* %41
%43 = getelementptr inbounds double, double* %6, i64 %39
%44 = bitcast double* %43 to <2 x double>*
%45 = load <2 x double>, <2 x double>* %44
%46 = fdiv <2 x double> %42, %45
%47 = getelementptr inbounds double, double* %7, i64 %39
%48 = bitcast double* %47 to <2 x double>*
store <2 x double> %46, <2 x double>* %48
%49 = add nuw nsw i64 %29, 4
%50 = icmp eq i64 %49, 100000000
br i1 %50, label %51, label %28
51: ; preds = %28
%52 = tail call double (...) @omp_get_wtime()
%53 = fsub double %52, %27
%54 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), double %53)
ret i32 0
}