#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 */
int __builtin_fmaxf64(double, int);
void __attribute__((noipa))
test_double_one(double *__restrict x, double *__restrict y,
                int64_t *__restrict pred, int n) {
  for (int i = 0; i < n; ++i)
    x[i] = pred[i] != 1 ? __builtin_fmaxf64(y[i], 1) : 4;
}


x86 assembly (clang, -O0):
<test_double_one>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
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    119a <test_double_one+0x8a>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
je     116b <test_double_one+0x5b>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    $0x1,%edi
call   1030 <__builtin_fmaxf64@plt>
mov    %eax,-0x24(%rbp)
jmp    1178 <test_double_one+0x68>
mov    $0x4,%eax
mov    %eax,-0x24(%rbp)
jmp    1178 <test_double_one+0x68>
mov    -0x24(%rbp),%eax
cvtsi2sd %eax,%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    112e <test_double_one+0x1e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_double_one>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %ecx,%ecx
jle    1164 <test_double_one+0x54>
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
mov    %ecx,%r13d
xor    %ebx,%ebx
jmp    1146 <test_double_one+0x36>
nopl   (%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
je     1164 <test_double_one+0x54>
mov    $0x4,%eax
cmpl   $0x1,(%r15,%rbx,4)
je     1130 <test_double_one+0x20>
movsd  (%r14,%rbx,8),%xmm0
mov    $0x1,%edi
call   1030 <__builtin_fmaxf64@plt>
jmp    1130 <test_double_one+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @test_double_one(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 = %36, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %8
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %39
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 = call i32 @__builtin_fmaxf64(double %26, i32 1)
br label %29
28: ; preds = %14
br label %29
29: ; preds = %28, %21
%30 = phi i32 [ %27, %21 ], [ 4, %28 ]
%31 = sitofp i32 %30 to double
%32 = load double*, double** %5
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
store double %31, double* %35
br label %36
36: ; preds = %29
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
store i32 %38, i32* %9
br label %10
39: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @test_double_one(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 %8
6: ; preds = %4
%7 = zext i32 %3 to i64
br label %9
8: ; preds = %18, %4
ret void
9: ; preds = %6, %18
%10 = phi i64 [ 0, %6 ], [ %22, %18 ]
%11 = getelementptr inbounds i32, i32* %2, i64 %10
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, 1
br i1 %13, label %18, label %14
14: ; preds = %9
%15 = getelementptr inbounds double, double* %1, i64 %10
%16 = load double, double* %15
%17 = tail call i32 @__builtin_fmaxf64(double %16, i32 1)
br label %18
18: ; preds = %9, %14
%19 = phi i32 [ %17, %14 ], [ 4, %9 ]
%20 = sitofp i32 %19 to double
%21 = getelementptr inbounds double, double* %0, i64 %10
store double %20, double* %21
%22 = add nuw nsw i64 %10, 1
%23 = icmp eq i64 %22, %7
br i1 %23, label %8, label %9
}