#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 *malloc(int);
double *rep(double d, int n, double *res) {
  if (res == 0) {
    res = malloc(sizeof(double) * n);
  }
  for (int i = 0; i < n; ++i) {
    res[i] = d;
  }
  return res;
}


x86 assembly (clang, -O0):
<rep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1142 <rep+0x32>
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1175 <rep+0x65>
movsd  -0x8(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1149 <rep+0x39>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rep>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rax
mov    %edi,%ebx
test   %rsi,%rsi
jne    1133 <rep+0x23>
lea    0x0(,%rbx,8),%edi
movaps %xmm0,(%rsp)
call   1030 <malloc@plt>
movaps (%rsp),%xmm0
test   %ebx,%ebx
jle    123e <rep+0x12e>
mov    %ebx,%ecx
cmp    $0x4,%ebx
jae    1149 <rep+0x39>
xor    %edx,%edx
jmp    1230 <rep+0x120>
mov    %ecx,%edx
and    $0xfffffffc,%edx
movaps %xmm0,%xmm1
movlhps %xmm0,%xmm1
lea    -0x4(%rdx),%rbx
mov    %rbx,%rdi
shr    $0x2,%rdi
add    $0x1,%rdi
mov    %edi,%esi
and    $0x7,%esi
cmp    $0x1c,%rbx
jae    1175 <rep+0x65>
xor    %ebx,%ebx
jmp    11f1 <rep+0xe1>
and    $0xfffffffffffffff8,%rdi
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movups %xmm1,(%rax,%rbx,8)
movups %xmm1,0x10(%rax,%rbx,8)
movups %xmm1,0x20(%rax,%rbx,8)
movups %xmm1,0x30(%rax,%rbx,8)
movups %xmm1,0x40(%rax,%rbx,8)
movups %xmm1,0x50(%rax,%rbx,8)
movups %xmm1,0x60(%rax,%rbx,8)
movups %xmm1,0x70(%rax,%rbx,8)
movups %xmm1,0x80(%rax,%rbx,8)
movups %xmm1,0x90(%rax,%rbx,8)
movups %xmm1,0xa0(%rax,%rbx,8)
movups %xmm1,0xb0(%rax,%rbx,8)
movups %xmm1,0xc0(%rax,%rbx,8)
movups %xmm1,0xd0(%rax,%rbx,8)
movups %xmm1,0xe0(%rax,%rbx,8)
movups %xmm1,0xf0(%rax,%rbx,8)
add    $0x20,%rbx
add    $0xfffffffffffffff8,%rdi
jne    1180 <rep+0x70>
test   %rsi,%rsi
je     1222 <rep+0x112>
lea    (%rax,%rbx,8),%rdi
add    $0x10,%rdi
shl    $0x5,%rsi
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movups %xmm1,-0x10(%rdi,%rbx,1)
movups %xmm1,(%rdi,%rbx,1)
add    $0x20,%rbx
cmp    %rbx,%rsi
jne    1210 <rep+0x100>
cmp    %rcx,%rdx
je     123e <rep+0x12e>
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,(%rax,%rdx,8)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1230 <rep+0x120>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double* @rep(double %0, i32 %1, double* %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca double*
%7 = alloca i32
store double %0, double* %4
store i32 %1, i32* %5
store double* %2, double** %6
%8 = load double*, double** %6
%9 = icmp eq double* %8, null
br i1 %9, label %10, label %16
10: ; preds = %3
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = mul i64 8, %12
%14 = trunc i64 %13 to i32
%15 = call double* @malloc(i32 %14)
store double* %15, double** %6
br label %16
16: ; preds = %10, %3
store i32 0, i32* %7
br label %17
17: ; preds = %27, %16
%18 = load i32, i32* %7
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load double, double* %4
%23 = load double*, double** %6
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
store double %22, double* %26
br label %27
27: ; preds = %21
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %17
30: ; preds = %17
%31 = load double*, double** %6
ret double* %31
}

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