#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 */
void sg_vector_scale_operation_inner(const void *restrict ctx,
                                     const size_t _offset,
                                     double *const restrict _v0,
                                     double *const restrict _v1,
                                     const size_t _num_elems) {
  size_t _i;
  (void)ctx;
  for (_i = 0; _i < _num_elems; ++_i) {
    size_t index = _offset + _i;
    double *const x = _v0 + _i;
    double *const z = _v1 + _i;
    (void)index;
    {
      {
        const double c = *(const double *)ctx;
        *z = c * *x;
      }
    }
  }
}


x86 assembly (clang, -O0):
<sg_vector_scale_operation_inner>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1193 <sg_vector_scale_operation_inner+0x93>
mov    -0x10(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
mov    -0x40(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1120 <sg_vector_scale_operation_inner+0x20>
pop    %rbp
ret

x86 assembly (clang, -O2):
<sg_vector_scale_operation_inner>:
test   %r8,%r8
je     11e7 <sg_vector_scale_operation_inner+0xe7>
movsd  (%rdi),%xmm0
cmp    $0x4,%r8
jae    111a <sg_vector_scale_operation_inner+0x1a>
xor    %eax,%eax
jmp    11d0 <sg_vector_scale_operation_inner+0xd0>
mov    %r8,%rax
and    $0xfffffffffffffffc,%rax
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%rax),%rsi
mov    %rsi,%r9
shr    $0x2,%r9
add    $0x1,%r9
test   %rsi,%rsi
je     11e8 <sg_vector_scale_operation_inner+0xe8>
mov    %r9,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
movupd (%rdx,%rsi,8),%xmm2
movupd 0x10(%rdx,%rsi,8),%xmm3
mulpd  %xmm1,%xmm2
mulpd  %xmm1,%xmm3
movupd %xmm2,(%rcx,%rsi,8)
movupd %xmm3,0x10(%rcx,%rsi,8)
movupd 0x20(%rdx,%rsi,8),%xmm2
movupd 0x30(%rdx,%rsi,8),%xmm3
mulpd  %xmm1,%xmm2
mulpd  %xmm1,%xmm3
movupd %xmm2,0x20(%rcx,%rsi,8)
movupd %xmm3,0x30(%rcx,%rsi,8)
add    $0x8,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1150 <sg_vector_scale_operation_inner+0x50>
test   $0x1,%r9b
je     11bc <sg_vector_scale_operation_inner+0xbc>
movupd (%rdx,%rsi,8),%xmm2
movupd 0x10(%rdx,%rsi,8),%xmm3
mulpd  %xmm1,%xmm2
mulpd  %xmm1,%xmm3
movupd %xmm2,(%rcx,%rsi,8)
movupd %xmm3,0x10(%rcx,%rsi,8)
cmp    %r8,%rax
je     11e7 <sg_vector_scale_operation_inner+0xe7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rdx,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rcx,%rax,8)
add    $0x1,%rax
cmp    %rax,%r8
jne    11d0 <sg_vector_scale_operation_inner+0xd0>
ret
xor    %esi,%esi
test   $0x1,%r9b
jne    119e <sg_vector_scale_operation_inner+0x9e>
jmp    11bc <sg_vector_scale_operation_inner+0xbc>

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

LLVM IR (-O2):
define void @sg_vector_scale_operation_inner(i8* noalias nocapture %0, i64 %1, double* noalias nocapture %2, double* noalias nocapture writeonly %3, i64 %4) {
%6 = icmp eq i64 %4, 0
br i1 %6, label %83, label %7
7: ; preds = %5
%8 = bitcast i8* %0 to double*
%9 = load double, double* %8
%10 = icmp ult i64 %4, 4
br i1 %10, label %73, label %11
11: ; preds = %7
%12 = and i64 %4, -4
%13 = insertelement <2 x double> poison, double %9, i64 0
%14 = shufflevector <2 x double> %13, <2 x double> poison, <2 x i32> zeroinitializer
%15 = insertelement <2 x double> poison, double %9, i64 0
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
%17 = add i64 %12, -4
%18 = lshr exact i64 %17, 2
%19 = add nuw nsw i64 %18, 1
%20 = and i64 %19, 1
%21 = icmp eq i64 %17, 0
br i1 %21, label %55, label %22
22: ; preds = %11
%23 = and i64 %19, 9223372036854775806
br label %24
24: ; preds = %24, %22
%25 = phi i64 [ 0, %22 ], [ %52, %24 ]
%26 = phi i64 [ 0, %22 ], [ %53, %24 ]
%27 = getelementptr inbounds double, double* %2, i64 %25
%28 = getelementptr inbounds double, double* %3, i64 %25
%29 = bitcast double* %27 to <2 x double>*
%30 = load <2 x double>, <2 x double>* %29
%31 = getelementptr inbounds double, double* %27, i64 2
%32 = bitcast double* %31 to <2 x double>*
%33 = load <2 x double>, <2 x double>* %32
%34 = fmul <2 x double> %14, %30
%35 = fmul <2 x double> %16, %33
%36 = bitcast double* %28 to <2 x double>*
store <2 x double> %34, <2 x double>* %36
%37 = getelementptr inbounds double, double* %28, i64 2
%38 = bitcast double* %37 to <2 x double>*
store <2 x double> %35, <2 x double>* %38
%39 = or i64 %25, 4
%40 = getelementptr inbounds double, double* %2, i64 %39
%41 = getelementptr inbounds double, double* %3, i64 %39
%42 = bitcast double* %40 to <2 x double>*
%43 = load <2 x double>, <2 x double>* %42
%44 = getelementptr inbounds double, double* %40, i64 2
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = fmul <2 x double> %14, %43
%48 = fmul <2 x double> %16, %46
%49 = bitcast double* %41 to <2 x double>*
store <2 x double> %47, <2 x double>* %49
%50 = getelementptr inbounds double, double* %41, i64 2
%51 = bitcast double* %50 to <2 x double>*
store <2 x double> %48, <2 x double>* %51
%52 = add nuw i64 %25, 8
%53 = add i64 %26, 2
%54 = icmp eq i64 %53, %23
br i1 %54, label %55, label %24
55: ; preds = %24, %11
%56 = phi i64 [ 0, %11 ], [ %52, %24 ]
%57 = icmp eq i64 %20, 0
br i1 %57, label %71, label %58
58: ; preds = %55
%59 = getelementptr inbounds double, double* %2, i64 %56
%60 = getelementptr inbounds double, double* %3, i64 %56
%61 = bitcast double* %59 to <2 x double>*
%62 = load <2 x double>, <2 x double>* %61
%63 = getelementptr inbounds double, double* %59, i64 2
%64 = bitcast double* %63 to <2 x double>*
%65 = load <2 x double>, <2 x double>* %64
%66 = fmul <2 x double> %14, %62
%67 = fmul <2 x double> %16, %65
%68 = bitcast double* %60 to <2 x double>*
store <2 x double> %66, <2 x double>* %68
%69 = getelementptr inbounds double, double* %60, i64 2
%70 = bitcast double* %69 to <2 x double>*
store <2 x double> %67, <2 x double>* %70
br label %71
71: ; preds = %55, %58
%72 = icmp eq i64 %12, %4
br i1 %72, label %83, label %73
73: ; preds = %7, %71
%74 = phi i64 [ 0, %7 ], [ %12, %71 ]
br label %75
75: ; preds = %73, %75
%76 = phi i64 [ %81, %75 ], [ %74, %73 ]
%77 = getelementptr inbounds double, double* %2, i64 %76
%78 = getelementptr inbounds double, double* %3, i64 %76
%79 = load double, double* %77
%80 = fmul double %9, %79
store double %80, double* %78
%81 = add nuw i64 %76, 1
%82 = icmp eq i64 %81, %4
br i1 %82, label %83, label %75
83: ; preds = %75, %71, %5
ret void
}