#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 */
typedef int int64_t;

/* Variables and functions */
void __attribute__((noipa))
test_double_four(double *__restrict x, double *__restrict y,
                 int64_t *__restrict pred, int n) {
  for (int i = 0; i < n; ++i)
    x[i] = pred[i] != 1 ? y[i] * (double)4.0 : 0;
}


x86 assembly (clang, -O0):
<test_double_four>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1184 <test_double_four+0x84>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
je     1157 <test_double_four+0x57>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  0xeb8(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1164 <test_double_four+0x64>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1164 <test_double_four+0x64>
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    111a <test_double_four+0x1a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_double_four>:
test   %ecx,%ecx
jle    1130 <test_double_four+0x30>
mov    %ecx,%r8d
cmp    $0x1,%ecx
jne    1131 <test_double_four+0x31>
xor    %eax,%eax
test   $0x1,%r8b
je     1130 <test_double_four+0x30>
xorpd  %xmm0,%xmm0
cmpl   $0x1,(%rdx,%rax,4)
je     112b <test_double_four+0x2b>
movsd  (%rsi,%rax,8),%xmm0
mulsd  0xed5(%rip),%xmm0
movsd  %xmm0,(%rdi,%rax,8)
ret
mov    %r8d,%ecx
and    $0xfffffffe,%ecx
xor    %eax,%eax
movsd  0xebf(%rip),%xmm0
jmp    115f <test_double_four+0x5f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm1,0x8(%rdi,%rax,8)
add    $0x2,%rax
cmp    %rax,%rcx
je     110e <test_double_four+0xe>
xorpd  %xmm1,%xmm1
cmpl   $0x1,(%rdx,%rax,4)
xorpd  %xmm2,%xmm2
je     1176 <test_double_four+0x76>
movsd  (%rsi,%rax,8),%xmm2
mulsd  %xmm0,%xmm2
movsd  %xmm2,(%rdi,%rax,8)
cmpl   $0x1,0x4(%rdx,%rax,4)
je     1150 <test_double_four+0x50>
movsd  0x8(%rsi,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
jmp    1150 <test_double_four+0x50>

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

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