#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*/ memset(char *, int, int);
void dfill(double *a, int alen, double dval) {
  register int i;
  double d;
  if (dval == 0.0) {
    memset((char *)&d, 0x0, sizeof(double));
    if (d == 0.0) {
      memset((char *)a, 0x0, sizeof(double) * alen);
      return;
    }
  }
  for (i = 0; i < alen; i++)
    a[i] = dval;
}


x86 assembly (clang, -O0):
<dfill>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1183 <dfill+0x73>
jp     1183 <dfill+0x73>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    117e <dfill+0x6e>
jp     117e <dfill+0x6e>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
jmp    11b6 <dfill+0xa6>
jmp    1183 <dfill+0x73>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b6 <dfill+0xa6>
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118a <dfill+0x7a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dfill>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    116a <dfill+0x5a>
jp     116a <dfill+0x5a>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
movapd %xmm0,0x10(%rsp)
call   1030 <memset@plt>
movapd 0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd 0xeae(%rip),%xmm1
jne    116a <dfill+0x5a>
jp     116a <dfill+0x5a>
shl    $0x3,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1030 <memset@plt>
jmp    128e <dfill+0x17e>
test   %ebp,%ebp
jle    128e <dfill+0x17e>
mov    %ebp,%eax
cmp    $0x4,%ebp
jae    1180 <dfill+0x70>
xor    %ecx,%ecx
jmp    1280 <dfill+0x170>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%rcx),%rdi
mov    %rdi,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
mov    %esi,%edx
and    $0x7,%edx
cmp    $0x1c,%rdi
jae    11ae <dfill+0x9e>
xor    %edi,%edi
jmp    1245 <dfill+0x135>
and    $0xfffffffffffffff8,%rsi
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movupd %xmm1,(%rbx,%rdi,8)
movupd %xmm1,0x10(%rbx,%rdi,8)
movupd %xmm1,0x20(%rbx,%rdi,8)
movupd %xmm1,0x30(%rbx,%rdi,8)
movupd %xmm1,0x40(%rbx,%rdi,8)
movupd %xmm1,0x50(%rbx,%rdi,8)
movupd %xmm1,0x60(%rbx,%rdi,8)
movupd %xmm1,0x70(%rbx,%rdi,8)
movupd %xmm1,0x80(%rbx,%rdi,8)
movupd %xmm1,0x90(%rbx,%rdi,8)
movupd %xmm1,0xa0(%rbx,%rdi,8)
movupd %xmm1,0xb0(%rbx,%rdi,8)
movupd %xmm1,0xc0(%rbx,%rdi,8)
movupd %xmm1,0xd0(%rbx,%rdi,8)
movupd %xmm1,0xe0(%rbx,%rdi,8)
movupd %xmm1,0xf0(%rbx,%rdi,8)
add    $0x20,%rdi
add    $0xfffffffffffffff8,%rsi
jne    11c0 <dfill+0xb0>
test   %rdx,%rdx
je     1274 <dfill+0x164>
lea    (%rbx,%rdi,8),%rsi
add    $0x10,%rsi
shl    $0x5,%rdx
xor    %edi,%edi
nopl   0x0(%rax,%rax,1)
movupd %xmm1,-0x10(%rsi,%rdi,1)
movupd %xmm1,(%rsi,%rdi,1)
add    $0x20,%rdi
cmp    %rdi,%rdx
jne    1260 <dfill+0x150>
cmp    %rax,%rcx
je     128e <dfill+0x17e>
nopl   0x0(%rax)
movsd  %xmm0,(%rbx,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1280 <dfill+0x170>
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

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

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