#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 */
double NAN;
void nan_array(double *x, int n) {
  for (int i = 0; i < n; i++)
    x[i] = NAN;
}


x86 assembly (clang, -O0):
<nan_array>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1144 <nan_array+0x44>
mov    0x2ed3(%rip),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1112 <nan_array+0x12>
pop    %rbp
ret

x86 assembly (clang, -O2):
<nan_array>:
test   %esi,%esi
jle    125b <nan_array+0x15b>
mov    %esi,%eax
cmp    $0x4,%esi
jb     1134 <nan_array+0x34>
mov    0x2ee2(%rip),%r8
lea    0x8(%r8),%rcx
cmp    %rcx,%rdi
jae    11b5 <nan_array+0xb5>
lea    (%rdi,%rax,8),%rcx
cmp    0x2eca(%rip),%rcx
jbe    11b5 <nan_array+0xb5>
xor    %ecx,%ecx
mov    %rcx,%r8
not    %r8
add    %rax,%r8
mov    %rax,%rsi
and    $0x3,%rsi
je     1163 <nan_array+0x63>
mov    0x2ea9(%rip),%rdx
nop
movsd  (%rdx),%xmm0
movsd  %xmm0,(%rdi,%rcx,8)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rsi
jne    1150 <nan_array+0x50>
cmp    $0x3,%r8
jb     125b <nan_array+0x15b>
mov    0x2e84(%rip),%rdx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rdx),%xmm0
movsd  %xmm0,(%rdi,%rcx,8)
movsd  (%rdx),%xmm0
movsd  %xmm0,0x8(%rdi,%rcx,8)
movsd  (%rdx),%xmm0
movsd  %xmm0,0x10(%rdi,%rcx,8)
movsd  (%rdx),%xmm0
movsd  %xmm0,0x18(%rdi,%rcx,8)
add    $0x4,%rcx
cmp    %rcx,%rax
jne    1180 <nan_array+0x80>
jmp    125b <nan_array+0x15b>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rdx
mov    %rdx,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
mov    %esi,%r9d
and    $0x3,%r9d
cmp    $0xc,%rdx
jae    11da <nan_array+0xda>
xor    %edx,%edx
jmp    1221 <nan_array+0x121>
and    $0xfffffffffffffffc,%rsi
movsd  (%r8),%xmm0
movlhps %xmm0,%xmm0
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
movups %xmm0,(%rdi,%rdx,8)
movups %xmm0,0x10(%rdi,%rdx,8)
movups %xmm0,0x20(%rdi,%rdx,8)
movups %xmm0,0x30(%rdi,%rdx,8)
movups %xmm0,0x40(%rdi,%rdx,8)
movups %xmm0,0x50(%rdi,%rdx,8)
movups %xmm0,0x60(%rdi,%rdx,8)
movups %xmm0,0x70(%rdi,%rdx,8)
add    $0x10,%rdx
add    $0xfffffffffffffffc,%rsi
jne    11f0 <nan_array+0xf0>
test   %r9,%r9
je     1252 <nan_array+0x152>
movsd  (%r8),%xmm0
movlhps %xmm0,%xmm0
lea    (%rdi,%rdx,8),%rdx
add    $0x10,%rdx
shl    $0x5,%r9
xor    %esi,%esi
nopl   0x0(%rax)
movups %xmm0,-0x10(%rdx,%rsi,1)
movups %xmm0,(%rdx,%rsi,1)
add    $0x20,%rsi
cmp    %rsi,%r9
jne    1240 <nan_array+0x140>
cmp    %rax,%rcx
jne    1136 <nan_array+0x36>
ret

LLVM IR (-O0):
@NAN = global double 0.000000e+00
define void @nan_array(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %16, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %19
10: ; preds = %6
%11 = load double, double* @NAN
%12 = load double*, double** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %12, i64 %14
store double %11, double* %15
br label %16
16: ; preds = %10
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
br label %6
19: ; preds = %6
ret void
}

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