#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*/ dcopy(unsigned int, double const *, double *);
int /*<<< orphan*/ dset(unsigned int, double, double *);
void dvcal(unsigned int n, const double da, const double *dx, double *dy) {
  if (da == 1.0) {
    dcopy(n, dx, dy);
  } else if (da == 0.0) {
    dset(n, 0.0, dy);
  } else {
    do {
      --n;
      dy[n] = da * dx[n];
    } while (n);
  }
}


x86 assembly (clang, -O0):
<dvcal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xebb(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    116a <dvcal+0x4a>
jp     116a <dvcal+0x4a>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <dcopy@plt>
jmp    11d5 <dvcal+0xb5>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1196 <dvcal+0x76>
jp     1196 <dvcal+0x76>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rsi
xorps  %xmm0,%xmm0
call   1030 <dset@plt>
jmp    11d0 <dvcal+0xb0>
jmp    119b <dvcal+0x7b>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x4(%rbp),%ecx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x4(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
cmpl   $0x0,-0x4(%rbp)
jne    119b <dvcal+0x7b>
jmp    11d0 <dvcal+0xb0>
jmp    11d5 <dvcal+0xb5>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dvcal>:
push   %rbx
ucomisd 0xed7(%rip),%xmm0
jne    1133 <dvcal+0x13>
jp     1133 <dvcal+0x13>
pop    %rbx
jmp    1040 <dcopy@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    114c <dvcal+0x2c>
jp     114c <dvcal+0x2c>
xorpd  %xmm0,%xmm0
mov    %rdx,%rsi
pop    %rbx
jmp    1030 <dset@plt>
cmp    $0x4,%edi
jb     1245 <dvcal+0x125>
lea    -0x1(%rdi),%r11d
lea    (%rsi,%r11,8),%rax
add    $0x8,%rax
cmp    %rdx,%rax
jbe    1177 <dvcal+0x57>
lea    (%rdx,%r11,8),%rax
add    $0x8,%rax
cmp    %rsi,%rax
ja     1245 <dvcal+0x125>
mov    %edi,%r8d
and    $0xfffffffc,%r8d
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%r8),%eax
mov    %eax,%r9d
shr    $0x2,%r9d
add    $0x1,%r9d
shufpd $0x1,%xmm1,%xmm1
test   %eax,%eax
je     120a <dvcal+0xea>
mov    %r9d,%eax
and    $0xfffffffe,%eax
lea    -0x5(%rdi),%ecx
mov    $0x1,%r10d
nopl   (%rax)
mov    %r11d,%ebx
movupd -0x18(%rsi,%rbx,8),%xmm2
movupd -0x8(%rsi,%rbx,8),%xmm3
mulpd  %xmm1,%xmm3
movupd %xmm3,-0x8(%rdx,%rbx,8)
mulpd  %xmm1,%xmm2
movupd %xmm2,-0x18(%rdx,%rbx,8)
mov    %ecx,%ebx
movupd -0x18(%rsi,%rbx,8),%xmm2
movupd -0x8(%rsi,%rbx,8),%xmm3
mulpd  %xmm1,%xmm3
movupd %xmm3,-0x8(%rdx,%rbx,8)
mulpd  %xmm1,%xmm2
movupd %xmm2,-0x18(%rdx,%rbx,8)
add    $0x8,%r10d
add    $0xfffffff8,%ecx
add    $0xfffffff8,%r11d
add    $0xfffffffe,%eax
jne    11b0 <dvcal+0x90>
neg    %r10d
jmp    1210 <dvcal+0xf0>
mov    $0xffffffff,%r10d
test   $0x1,%r9b
je     123d <dvcal+0x11d>
add    %edi,%r10d
movupd -0x18(%rsi,%r10,8),%xmm2
movupd -0x8(%rsi,%r10,8),%xmm3
mulpd  %xmm1,%xmm3
movupd %xmm3,-0x8(%rdx,%r10,8)
mulpd  %xmm1,%xmm2
movupd %xmm2,-0x18(%rdx,%r10,8)
cmp    %edi,%r8d
je     12bb <dvcal+0x19b>
and    $0x3,%edi
lea    -0x1(%rdi),%eax
mov    %edi,%ecx
and    $0x3,%ecx
je     1266 <dvcal+0x146>
nop
add    $0xffffffff,%edi
movsd  (%rsi,%rdi,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx,%rdi,8)
add    $0xffffffff,%ecx
jne    1250 <dvcal+0x130>
cmp    $0x3,%eax
jb     12bb <dvcal+0x19b>
add    $0xfffffffe,%edi
xchg   %ax,%ax
lea    0x1(%rdi),%eax
movsd  (%rsi,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx,%rax,8)
mov    %edi,%eax
movsd  (%rsi,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx,%rax,8)
lea    -0x1(%rdi),%eax
movsd  (%rsi,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx,%rax,8)
lea    -0x2(%rdi),%eax
movsd  (%rsi,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx,%rax,8)
add    $0xfffffffc,%edi
cmp    $0xfffffffe,%edi
jne    1270 <dvcal+0x150>
pop    %rbx
ret

LLVM IR (-O0):
define void @dvcal(i32 %0, double %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca double
%7 = alloca double*
%8 = alloca double*
store i32 %0, i32* %5
store double %1, double* %6
store double* %2, double** %7
store double* %3, double** %8
%9 = load double, double* %6
%10 = fcmp oeq double %9, 1.000000e+00
br i1 %10, label %11, label %16
11: ; preds = %4
%12 = load i32, i32* %5
%13 = load double*, double** %7
%14 = load double*, double** %8
%15 = call i32 @dcopy(i32 %12, double* %13, double* %14)
br label %43
16: ; preds = %4
%17 = load double, double* %6
%18 = fcmp oeq double %17, 0.000000e+00
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* %5
%21 = load double*, double** %8
%22 = call i32 @dset(i32 %20, double 0.000000e+00, double* %21)
br label %42
23: ; preds = %16
br label %24
24: ; preds = %38, %23
%25 = load i32, i32* %5
%26 = add i32 %25, -1
store i32 %26, i32* %5
%27 = load double, double* %6
%28 = load double*, double** %7
%29 = load i32, i32* %5
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
%32 = load double, double* %31
%33 = fmul double %27, %32
%34 = load double*, double** %8
%35 = load i32, i32* %5
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
store double %33, double* %37
br label %38
38: ; preds = %24
%39 = load i32, i32* %5
%40 = icmp ne i32 %39, 0
br i1 %40, label %24, label %41
41: ; preds = %38
br label %42
42: ; preds = %41, %19
br label %43
43: ; preds = %42, %11
ret void
}

LLVM IR (-O2):
define void @dvcal(i32 %0, double %1, double* %2, double* %3) {
%5 = fcmp oeq double %1, 1.000000e+00
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 @dcopy(i32 %0, double* %2, double* %3)
br label %165
8: ; preds = %4
%9 = fcmp oeq double %1, 0.000000e+00
br i1 %9, label %136, label %10
10: ; preds = %8
%11 = icmp ult i32 %0, 4
br i1 %11, label %117, label %12
12: ; preds = %10
%13 = add i32 %0, -1
%14 = zext i32 %13 to i64
%15 = add nuw nsw i64 %14, 1
%16 = getelementptr double, double* %3, i64 %15
%17 = getelementptr double, double* %2, i64 %15
%18 = icmp ugt double* %17, %3
%19 = icmp ugt double* %16, %2
%20 = and i1 %18, %19
br i1 %20, label %117, label %21
21: ; preds = %12
%22 = and i32 %0, -4
%23 = and i32 %0, 3
%24 = insertelement <2 x double> poison, double %1, i64 0
%25 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> zeroinitializer
%26 = insertelement <2 x double> poison, double %1, i64 0
%27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
%28 = add i32 %22, -4
%29 = lshr exact i32 %28, 2
%30 = add nuw nsw i32 %29, 1
%31 = and i32 %30, 1
%32 = icmp eq i32 %28, 0
br i1 %32, label %89, label %33
33: ; preds = %21
%34 = and i32 %30, 2147483646
br label %35
35: ; preds = %35, %33
%36 = phi i32 [ 0, %33 ], [ %84, %35 ]
%37 = phi i32 [ 0, %33 ], [ %85, %35 ]
%38 = xor i32 %36, -1
%39 = add i32 %38, %0
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds double, double* %2, i64 %40
%42 = getelementptr inbounds double, double* %41, i64 -1
%43 = bitcast double* %42 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = shufflevector <2 x double> %44, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%46 = getelementptr inbounds double, double* %41, i64 -2
%47 = getelementptr inbounds double, double* %46, i64 -1
%48 = bitcast double* %47 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = shufflevector <2 x double> %49, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%51 = fmul <2 x double> %45, %25
%52 = fmul <2 x double> %50, %27
%53 = getelementptr inbounds double, double* %3, i64 %40
%54 = shufflevector <2 x double> %51, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%55 = getelementptr inbounds double, double* %53, i64 -1
%56 = bitcast double* %55 to <2 x double>*
store <2 x double> %54, <2 x double>* %56
%57 = shufflevector <2 x double> %52, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%58 = getelementptr inbounds double, double* %53, i64 -2
%59 = getelementptr inbounds double, double* %58, i64 -1
%60 = bitcast double* %59 to <2 x double>*
store <2 x double> %57, <2 x double>* %60
%61 = sub nuw nsw i32 -5, %36
%62 = add i32 %61, %0
%63 = zext i32 %62 to i64
%64 = getelementptr inbounds double, double* %2, i64 %63
%65 = getelementptr inbounds double, double* %64, i64 -1
%66 = bitcast double* %65 to <2 x double>*
%67 = load <2 x double>, <2 x double>* %66
%68 = shufflevector <2 x double> %67, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%69 = getelementptr inbounds double, double* %64, i64 -2
%70 = getelementptr inbounds double, double* %69, i64 -1
%71 = bitcast double* %70 to <2 x double>*
%72 = load <2 x double>, <2 x double>* %71
%73 = shufflevector <2 x double> %72, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%74 = fmul <2 x double> %68, %25
%75 = fmul <2 x double> %73, %27
%76 = getelementptr inbounds double, double* %3, i64 %63
%77 = shufflevector <2 x double> %74, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%78 = getelementptr inbounds double, double* %76, i64 -1
%79 = bitcast double* %78 to <2 x double>*
store <2 x double> %77, <2 x double>* %79
%80 = shufflevector <2 x double> %75, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%81 = getelementptr inbounds double, double* %76, i64 -2
%82 = getelementptr inbounds double, double* %81, i64 -1
%83 = bitcast double* %82 to <2 x double>*
store <2 x double> %80, <2 x double>* %83
%84 = add nuw i32 %36, 8
%85 = add i32 %37, 2
%86 = icmp eq i32 %85, %34
br i1 %86, label %87, label %35
87: ; preds = %35
%88 = sub i32 -9, %36
br label %89
89: ; preds = %87, %21
%90 = phi i32 [ -1, %21 ], [ %88, %87 ]
%91 = icmp eq i32 %31, 0
br i1 %91, label %115, label %92
92: ; preds = %89
%93 = add i32 %90, %0
%94 = zext i32 %93 to i64
%95 = getelementptr inbounds double, double* %2, i64 %94
%96 = getelementptr inbounds double, double* %95, i64 -1
%97 = bitcast double* %96 to <2 x double>*
%98 = load <2 x double>, <2 x double>* %97
%99 = shufflevector <2 x double> %98, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%100 = getelementptr inbounds double, double* %95, i64 -2
%101 = getelementptr inbounds double, double* %100, i64 -1
%102 = bitcast double* %101 to <2 x double>*
%103 = load <2 x double>, <2 x double>* %102
%104 = shufflevector <2 x double> %103, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%105 = fmul <2 x double> %99, %25
%106 = fmul <2 x double> %104, %27
%107 = getelementptr inbounds double, double* %3, i64 %94
%108 = shufflevector <2 x double> %105, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%109 = getelementptr inbounds double, double* %107, i64 -1
%110 = bitcast double* %109 to <2 x double>*
store <2 x double> %108, <2 x double>* %110
%111 = shufflevector <2 x double> %106, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%112 = getelementptr inbounds double, double* %107, i64 -2
%113 = getelementptr inbounds double, double* %112, i64 -1
%114 = bitcast double* %113 to <2 x double>*
store <2 x double> %111, <2 x double>* %114
br label %115
115: ; preds = %89, %92
%116 = icmp eq i32 %22, %0
br i1 %116, label %165, label %117
117: ; preds = %12, %10, %115
%118 = phi i32 [ %0, %12 ], [ %0, %10 ], [ %23, %115 ]
%119 = add i32 %118, -1
%120 = and i32 %118, 3
%121 = icmp eq i32 %120, 0
br i1 %121, label %133, label %122
122: ; preds = %117, %122
%123 = phi i32 [ %125, %122 ], [ %118, %117 ]
%124 = phi i32 [ %131, %122 ], [ 0, %117 ]
%125 = add i32 %123, -1
%126 = zext i32 %125 to i64
%127 = getelementptr inbounds double, double* %2, i64 %126
%128 = load double, double* %127
%129 = fmul double %128, %1
%130 = getelementptr inbounds double, double* %3, i64 %126
store double %129, double* %130
%131 = add i32 %124, 1
%132 = icmp eq i32 %131, %120
br i1 %132, label %133, label %122
133: ; preds = %122, %117
%134 = phi i32 [ %118, %117 ], [ %125, %122 ]
%135 = icmp ult i32 %119, 3
br i1 %135, label %165, label %138
136: ; preds = %8
%137 = tail call i32 @dset(i32 %0, double 0.000000e+00, double* %3)
br label %165
138: ; preds = %133, %138
%139 = phi i32 [ %158, %138 ], [ %134, %133 ]
%140 = add i32 %139, -1
%141 = zext i32 %140 to i64
%142 = getelementptr inbounds double, double* %2, i64 %141
%143 = load double, double* %142
%144 = fmul double %143, %1
%145 = getelementptr inbounds double, double* %3, i64 %141
store double %144, double* %145
%146 = add i32 %139, -2
%147 = zext i32 %146 to i64
%148 = getelementptr inbounds double, double* %2, i64 %147
%149 = load double, double* %148
%150 = fmul double %149, %1
%151 = getelementptr inbounds double, double* %3, i64 %147
store double %150, double* %151
%152 = add i32 %139, -3
%153 = zext i32 %152 to i64
%154 = getelementptr inbounds double, double* %2, i64 %153
%155 = load double, double* %154
%156 = fmul double %155, %1
%157 = getelementptr inbounds double, double* %3, i64 %153
store double %156, double* %157
%158 = add i32 %139, -4
%159 = zext i32 %158 to i64
%160 = getelementptr inbounds double, double* %2, i64 %159
%161 = load double, double* %160
%162 = fmul double %161, %1
%163 = getelementptr inbounds double, double* %3, i64 %159
store double %162, double* %163
%164 = icmp eq i32 %158, 0
br i1 %164, label %165, label %138
165: ; preds = %133, %138, %115, %136, %6
ret void
}