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


x86 assembly (clang, -O0):
<dscal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1150 <dscal+0x40>
jp     1150 <dscal+0x40>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
xorps  %xmm0,%xmm0
call   1030 <dset@plt>
jmp    11b1 <dscal+0xa1>
movsd  -0x10(%rbp),%xmm0
movsd  0xea3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1172 <dscal+0x62>
jp     1172 <dscal+0x62>
jmp    11ac <dscal+0x9c>
jmp    1177 <dscal+0x67>
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    -0x18(%rbp),%rax
mov    -0x4(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
cmpl   $0x0,-0x4(%rbp)
jne    1177 <dscal+0x67>
jmp    11ac <dscal+0x9c>
jmp    11b1 <dscal+0xa1>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dscal>:
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1125 <dscal+0x15>
jp     1125 <dscal+0x15>
xorpd  %xmm0,%xmm0
jmp    1030 <dset@plt>
ucomisd 0xed3(%rip),%xmm0
jne    1135 <dscal+0x25>
jnp    1236 <dscal+0x126>
cmp    $0x4,%edi
jb     120c <dscal+0xfc>
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     1237 <dscal+0x127>
mov    %r9d,%r11d
and    $0xfffffffe,%r11d
lea    -0x5(%rdi),%eax
lea    -0x1(%rdi),%edx
mov    $0x1,%r10d
nopl   0x0(%rax)
mov    %edx,%ecx
movupd -0x18(%rsi,%rcx,8),%xmm2
movupd -0x8(%rsi,%rcx,8),%xmm3
mulpd  %xmm1,%xmm3
movupd %xmm3,-0x8(%rsi,%rcx,8)
mulpd  %xmm1,%xmm2
movupd %xmm2,-0x18(%rsi,%rcx,8)
mov    %eax,%ecx
movupd -0x18(%rsi,%rcx,8),%xmm2
movupd -0x8(%rsi,%rcx,8),%xmm3
mulpd  %xmm1,%xmm3
movupd %xmm3,-0x8(%rsi,%rcx,8)
mulpd  %xmm1,%xmm2
movupd %xmm2,-0x18(%rsi,%rcx,8)
add    $0x8,%r10d
add    $0xfffffff8,%eax
add    $0xfffffff8,%edx
add    $0xfffffffe,%r11d
jne    1180 <dscal+0x70>
neg    %r10d
test   $0x1,%r9b
je     1204 <dscal+0xf4>
add    %edi,%r10d
movupd -0x18(%rsi,%r10,8),%xmm2
movupd -0x8(%rsi,%r10,8),%xmm3
mulpd  %xmm1,%xmm3
movupd %xmm3,-0x8(%rsi,%r10,8)
mulpd  %xmm1,%xmm2
movupd %xmm2,-0x18(%rsi,%r10,8)
cmp    %edi,%r8d
je     1236 <dscal+0x126>
and    $0x3,%edi
mov    %edi,%eax
neg    %eax
add    $0xffffffff,%edi
lea    (%rsi,%rdi,8),%rcx
xor    %edx,%edx
nopl   0x0(%rax)
movsd  (%rcx,%rdx,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rcx,%rdx,8)
add    $0xffffffffffffffff,%rdx
cmp    %edx,%eax
jne    1220 <dscal+0x110>
ret
mov    $0xffffffff,%r10d
test   $0x1,%r9b
jne    11dd <dscal+0xcd>
jmp    1204 <dscal+0xf4>

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

LLVM IR (-O2):
define void @dscal(i32 %0, double %1, double* %2) {
%4 = fcmp oeq double %1, 0.000000e+00
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @dset(i32 %0, double 0.000000e+00, double* %2)
br label %105
7: ; preds = %3
%8 = fcmp une double %1, 1.000000e+00
br i1 %8, label %9, label %105
9: ; preds = %7
%10 = icmp ult i32 %0, 4
br i1 %10, label %95, label %11
11: ; preds = %9
%12 = and i32 %0, -4
%13 = and i32 %0, 3
%14 = insertelement <2 x double> poison, double %1, i64 0
%15 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> zeroinitializer
%16 = insertelement <2 x double> poison, double %1, i64 0
%17 = shufflevector <2 x double> %16, <2 x double> poison, <2 x i32> zeroinitializer
%18 = add i32 %12, -4
%19 = lshr exact i32 %18, 2
%20 = add nuw nsw i32 %19, 1
%21 = and i32 %20, 1
%22 = icmp eq i32 %18, 0
br i1 %22, label %71, label %23
23: ; preds = %11
%24 = and i32 %20, 2147483646
br label %25
25: ; preds = %25, %23
%26 = phi i32 [ 0, %23 ], [ %66, %25 ]
%27 = phi i32 [ 0, %23 ], [ %67, %25 ]
%28 = xor i32 %26, -1
%29 = add i32 %28, %0
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds double, double* %2, i64 %30
%32 = getelementptr inbounds double, double* %31, i64 -1
%33 = bitcast double* %32 to <2 x double>*
%34 = load <2 x double>, <2 x double>* %33
%35 = shufflevector <2 x double> %34, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%36 = getelementptr inbounds double, double* %31, i64 -2
%37 = getelementptr inbounds double, double* %36, i64 -1
%38 = bitcast double* %37 to <2 x double>*
%39 = load <2 x double>, <2 x double>* %38
%40 = shufflevector <2 x double> %39, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%41 = fmul <2 x double> %35, %15
%42 = fmul <2 x double> %40, %17
%43 = shufflevector <2 x double> %41, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%44 = bitcast double* %32 to <2 x double>*
store <2 x double> %43, <2 x double>* %44
%45 = shufflevector <2 x double> %42, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%46 = bitcast double* %37 to <2 x double>*
store <2 x double> %45, <2 x double>* %46
%47 = sub nuw nsw i32 -5, %26
%48 = add i32 %47, %0
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds double, double* %2, i64 %49
%51 = getelementptr inbounds double, double* %50, i64 -1
%52 = bitcast double* %51 to <2 x double>*
%53 = load <2 x double>, <2 x double>* %52
%54 = shufflevector <2 x double> %53, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%55 = getelementptr inbounds double, double* %50, i64 -2
%56 = getelementptr inbounds double, double* %55, i64 -1
%57 = bitcast double* %56 to <2 x double>*
%58 = load <2 x double>, <2 x double>* %57
%59 = shufflevector <2 x double> %58, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%60 = fmul <2 x double> %54, %15
%61 = fmul <2 x double> %59, %17
%62 = shufflevector <2 x double> %60, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%63 = bitcast double* %51 to <2 x double>*
store <2 x double> %62, <2 x double>* %63
%64 = shufflevector <2 x double> %61, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%65 = bitcast double* %56 to <2 x double>*
store <2 x double> %64, <2 x double>* %65
%66 = add nuw i32 %26, 8
%67 = add i32 %27, 2
%68 = icmp eq i32 %67, %24
br i1 %68, label %69, label %25
69: ; preds = %25
%70 = sub i32 -9, %26
br label %71
71: ; preds = %69, %11
%72 = phi i32 [ -1, %11 ], [ %70, %69 ]
%73 = icmp eq i32 %21, 0
br i1 %73, label %93, label %74
74: ; preds = %71
%75 = add i32 %72, %0
%76 = zext i32 %75 to i64
%77 = getelementptr inbounds double, double* %2, i64 %76
%78 = getelementptr inbounds double, double* %77, i64 -1
%79 = bitcast double* %78 to <2 x double>*
%80 = load <2 x double>, <2 x double>* %79
%81 = shufflevector <2 x double> %80, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%82 = getelementptr inbounds double, double* %77, i64 -2
%83 = getelementptr inbounds double, double* %82, i64 -1
%84 = bitcast double* %83 to <2 x double>*
%85 = load <2 x double>, <2 x double>* %84
%86 = shufflevector <2 x double> %85, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%87 = fmul <2 x double> %81, %15
%88 = fmul <2 x double> %86, %17
%89 = shufflevector <2 x double> %87, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%90 = bitcast double* %78 to <2 x double>*
store <2 x double> %89, <2 x double>* %90
%91 = shufflevector <2 x double> %88, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%92 = bitcast double* %83 to <2 x double>*
store <2 x double> %91, <2 x double>* %92
br label %93
93: ; preds = %71, %74
%94 = icmp eq i32 %12, %0
br i1 %94, label %105, label %95
95: ; preds = %9, %93
%96 = phi i32 [ %0, %9 ], [ %13, %93 ]
br label %97
97: ; preds = %95, %97
%98 = phi i32 [ %99, %97 ], [ %96, %95 ]
%99 = add i32 %98, -1
%100 = zext i32 %99 to i64
%101 = getelementptr inbounds double, double* %2, i64 %100
%102 = load double, double* %101
%103 = fmul double %102, %1
store double %103, double* %101
%104 = icmp eq i32 %99, 0
br i1 %104, label %105, label %97
105: ; preds = %97, %93, %7, %5
ret void
}