#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 set_doubles(double *buf, size_t count, double value) {
  for (size_t i = 0; i < (size_t)count; i++) {
    buf[i] = value;
  }
}


x86 assembly (clang, -O0):
<set_doubles>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    114a <set_doubles+0x4a>
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1119 <set_doubles+0x19>
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_doubles>:
test   %rsi,%rsi
je     120e <set_doubles+0x10e>
cmp    $0x4,%rsi
jae    1116 <set_doubles+0x16>
xor    %eax,%eax
jmp    1200 <set_doubles+0x100>
mov    %rsi,%rax
and    $0xfffffffffffffffc,%rax
movaps %xmm0,%xmm1
movlhps %xmm0,%xmm1
lea    -0x4(%rax),%rcx
mov    %rcx,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
mov    %edx,%r8d
and    $0x7,%r8d
cmp    $0x1c,%rcx
jae    1146 <set_doubles+0x46>
xor    %ecx,%ecx
jmp    11c1 <set_doubles+0xc1>
and    $0xfffffffffffffff8,%rdx
xor    %ecx,%ecx
nopl   0x0(%rax)
movups %xmm1,(%rdi,%rcx,8)
movups %xmm1,0x10(%rdi,%rcx,8)
movups %xmm1,0x20(%rdi,%rcx,8)
movups %xmm1,0x30(%rdi,%rcx,8)
movups %xmm1,0x40(%rdi,%rcx,8)
movups %xmm1,0x50(%rdi,%rcx,8)
movups %xmm1,0x60(%rdi,%rcx,8)
movups %xmm1,0x70(%rdi,%rcx,8)
movups %xmm1,0x80(%rdi,%rcx,8)
movups %xmm1,0x90(%rdi,%rcx,8)
movups %xmm1,0xa0(%rdi,%rcx,8)
movups %xmm1,0xb0(%rdi,%rcx,8)
movups %xmm1,0xc0(%rdi,%rcx,8)
movups %xmm1,0xd0(%rdi,%rcx,8)
movups %xmm1,0xe0(%rdi,%rcx,8)
movups %xmm1,0xf0(%rdi,%rcx,8)
add    $0x20,%rcx
add    $0xfffffffffffffff8,%rdx
jne    1150 <set_doubles+0x50>
test   %r8,%r8
je     11f2 <set_doubles+0xf2>
lea    (%rdi,%rcx,8),%rcx
add    $0x10,%rcx
shl    $0x5,%r8
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movups %xmm1,-0x10(%rcx,%rdx,1)
movups %xmm1,(%rcx,%rdx,1)
add    $0x20,%rdx
cmp    %rdx,%r8
jne    11e0 <set_doubles+0xe0>
cmp    %rsi,%rax
je     120e <set_doubles+0x10e>
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,(%rdi,%rax,8)
add    $0x1,%rax
cmp    %rax,%rsi
jne    1200 <set_doubles+0x100>
ret

LLVM IR (-O0):
define void @set_doubles(double* %0, i64 %1, double %2) {
%4 = alloca double*
%5 = alloca i64
%6 = alloca double
%7 = alloca i64
store double* %0, double** %4
store i64 %1, i64* %5
store double %2, double* %6
store i64 0, i64* %7
br label %8
8: ; preds = %17, %3
%9 = load i64, i64* %7
%10 = load i64, i64* %5
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = load double, double* %6
%14 = load double*, double** %4
%15 = load i64, i64* %7
%16 = getelementptr inbounds double, double* %14, i64 %15
store double %13, double* %16
br label %17
17: ; preds = %12
%18 = load i64, i64* %7
%19 = add i64 %18, 1
store i64 %19, i64* %7
br label %8
20: ; preds = %8
ret void
}

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