#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*/ random_doubles(int, double *);
void generate_errors(int nbt, double *err) {
  int i;
  random_doubles(nbt, err);
  for (i = 0; i < nbt; i++)
    err[i] = err[i] / 1000.0;
}


x86 assembly (clang, -O0):
<generate_errors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <random_doubles@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1172 <generate_errors+0x62>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xead(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1132 <generate_errors+0x22>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_errors>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
call   1030 <random_doubles@plt>
test   %ebp,%ebp
jle    11c7 <generate_errors+0xb7>
mov    %ebp,%eax
cmp    $0x1,%ebp
jne    1130 <generate_errors+0x20>
xor    %ecx,%ecx
jmp    11a4 <generate_errors+0x94>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
lea    -0x2(%rcx),%rsi
mov    %rsi,%rdx
shr    %rdx
add    $0x1,%rdx
test   %rsi,%rsi
je     11ce <generate_errors+0xbe>
mov    %rdx,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
movapd 0xea3(%rip),%xmm0
nopl   (%rax)
movupd (%rbx,%rsi,8),%xmm1
movupd 0x10(%rbx,%rsi,8),%xmm2
divpd  %xmm0,%xmm1
movupd %xmm1,(%rbx,%rsi,8)
divpd  %xmm0,%xmm2
movupd %xmm2,0x10(%rbx,%rsi,8)
add    $0x4,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1160 <generate_errors+0x50>
test   $0x1,%dl
je     119f <generate_errors+0x8f>
movupd (%rbx,%rsi,8),%xmm0
divpd  0xe66(%rip),%xmm0
movupd %xmm0,(%rbx,%rsi,8)
cmp    %rax,%rcx
je     11c7 <generate_errors+0xb7>
movsd  0xe64(%rip),%xmm0
nopl   0x0(%rax)
movsd  (%rbx,%rcx,8),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    11b0 <generate_errors+0xa0>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %esi,%esi
test   $0x1,%dl
jne    118d <generate_errors+0x7d>
jmp    119f <generate_errors+0x8f>

LLVM IR (-O0):
define void @generate_errors(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca i32
store i32 %0, i32* %3
store double* %1, double** %4
%6 = load i32, i32* %3
%7 = load double*, double** %4
%8 = call i32 @random_doubles(i32 %6, double* %7)
store i32 0, i32* %5
br label %9
9: ; preds = %24, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %27
13: ; preds = %9
%14 = load double*, double** %4
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %14, i64 %16
%18 = load double, double* %17
%19 = fdiv double %18, 1.000000e+03
%20 = load double*, double** %4
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
store double %19, double* %23
br label %24
24: ; preds = %13
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %9
27: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @generate_errors(i32 %0, double* %1) {
%3 = tail call i32 @random_doubles(i32 %0, double* %1)
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %54
5: ; preds = %2
%6 = zext i32 %0 to i64
%7 = icmp eq i32 %0, 1
br i1 %7, label %45, label %8
8: ; preds = %5
%9 = and i64 %6, 4294967294
%10 = add nsw i64 %9, -2
%11 = lshr exact i64 %10, 1
%12 = add nuw i64 %11, 1
%13 = and i64 %12, 1
%14 = icmp eq i64 %10, 0
br i1 %14, label %34, label %15
15: ; preds = %8
%16 = and i64 %12, -2
br label %17
17: ; preds = %17, %15
%18 = phi i64 [ 0, %15 ], [ %31, %17 ]
%19 = phi i64 [ 0, %15 ], [ %32, %17 ]
%20 = getelementptr inbounds double, double* %1, i64 %18
%21 = bitcast double* %20 to <2 x double>*
%22 = load <2 x double>, <2 x double>* %21
%23 = fdiv <2 x double> %22, <double 1.000000e+03, double 1.000000e+03>
%24 = bitcast double* %20 to <2 x double>*
store <2 x double> %23, <2 x double>* %24
%25 = or i64 %18, 2
%26 = getelementptr inbounds double, double* %1, i64 %25
%27 = bitcast double* %26 to <2 x double>*
%28 = load <2 x double>, <2 x double>* %27
%29 = fdiv <2 x double> %28, <double 1.000000e+03, double 1.000000e+03>
%30 = bitcast double* %26 to <2 x double>*
store <2 x double> %29, <2 x double>* %30
%31 = add nuw i64 %18, 4
%32 = add nuw i64 %19, 2
%33 = icmp eq i64 %32, %16
br i1 %33, label %34, label %17
34: ; preds = %17, %8
%35 = phi i64 [ 0, %8 ], [ %31, %17 ]
%36 = icmp eq i64 %13, 0
br i1 %36, label %43, label %37
37: ; preds = %34
%38 = getelementptr inbounds double, double* %1, i64 %35
%39 = bitcast double* %38 to <2 x double>*
%40 = load <2 x double>, <2 x double>* %39
%41 = fdiv <2 x double> %40, <double 1.000000e+03, double 1.000000e+03>
%42 = bitcast double* %38 to <2 x double>*
store <2 x double> %41, <2 x double>* %42
br label %43
43: ; preds = %34, %37
%44 = icmp eq i64 %9, %6
br i1 %44, label %54, label %45
45: ; preds = %5, %43
%46 = phi i64 [ 0, %5 ], [ %9, %43 ]
br label %47
47: ; preds = %45, %47
%48 = phi i64 [ %52, %47 ], [ %46, %45 ]
%49 = getelementptr inbounds double, double* %1, i64 %48
%50 = load double, double* %49
%51 = fdiv double %50, 1.000000e+03
store double %51, double* %49
%52 = add nuw nsw i64 %48, 1
%53 = icmp eq i64 %52, %6
br i1 %53, label %54, label %47
54: ; preds = %47, %43, %2
ret void
}