#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);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
double *barnsley(int n_iter) {
  int i;
  int test;
  double *points = malloc(2 * n_iter * sizeof(double));
  points[0] = 0.0;
  points[1] = 0.0;
  srand(time(NULL));
  for (i = 2; i < (2 * n_iter); i += 2) {
    test = rand() % 100;
    if (test < 0) {
      points[i] = 0.0;
      points[i + 1] = 0.16 * points[i - 1];
    } else if (test < 86) {
      points[i] = 0.85 * points[i - 2] + 0.04 * points[i - 1];
      points[i + 1] = -0.04 * points[i - 2] + 0.85 * points[i - 1] + 1.6;
    } else if (test < 93) {
      points[i] = 0.20 * points[i - 2] - 0.26 * points[i - 1];
      points[i + 1] = 0.23 * points[i - 2] + 0.22 * points[i - 1] + 1.6;
    } else {
      points[i] = -0.15 * points[i - 2] + 0.28 * points[i - 1];
      points[i + 1] = 0.26 * points[i - 2] + 0.24 * points[i - 1] + 0.44;
    }
  }
  return points;
}


x86 assembly (clang, -O0):
<barnsley>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    1439 <barnsley+0x2f9>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11fe <barnsley+0xbe>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xe7e(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1426 <barnsley+0x2e6>
cmpl   $0x56,-0xc(%rbp)
jge    12b0 <barnsley+0x170>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xe29(%rip),%xmm1
mulsd  (%rax,%rcx,8),%xmm1
movsd  0xe14(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xdd8(%rip),%xmm1
mulsd  (%rax,%rcx,8),%xmm1
movsd  0xdc3(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd93(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1421 <barnsley+0x2e1>
cmpl   $0x5d,-0xc(%rbp)
jge    1379 <barnsley+0x239>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xd27(%rip),%xmm1
mulsd  (%rax,%rcx,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xd3b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xcf7(%rip),%xmm1
mulsd  (%rax,%rcx,8),%xmm1
movsd  0xce2(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xcca(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    141c <barnsley+0x2dc>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xc80(%rip),%xmm1
mulsd  (%rax,%rcx,8),%xmm1
movsd  0xc6b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xc27(%rip),%xmm1
mulsd  (%rax,%rcx,8),%xmm1
movsd  0xc12(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xbfa(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1421 <barnsley+0x2e1>
jmp    1426 <barnsley+0x2e6>
jmp    142b <barnsley+0x2eb>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    1190 <barnsley+0x50>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<barnsley>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebp
shl    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
xorpd  %xmm0,%xmm0
movupd %xmm0,(%rax)
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
cmp    $0x2,%ebp
jl     12e9 <barnsley+0x1a9>
add    %ebp,%ebp
movslq %ebp,%r14
xorpd  %xmm2,%xmm2
mov    $0x1,%ebp
jmp    11c4 <barnsley+0x84>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movq   $0x0,0x8(%rbx,%rbp,8)
movsd  (%rbx,%rbp,8),%xmm0
mulsd  0xec2(%rip),%xmm0
xorpd  %xmm2,%xmm2
movsd  %xmm0,0x10(%rbx,%rbp,8)
lea    0x2(%rbp),%rax
add    $0x3,%rbp
cmp    %r14,%rbp
mov    %rax,%rbp
jge    12e9 <barnsley+0x1a9>
movsd  %xmm2,0x8(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
js     1190 <barnsley+0x50>
cmp    $0x55,%eax
ja     1250 <barnsley+0x110>
movsd  (%rbx,%rbp,8),%xmm0
movapd %xmm0,%xmm1
mulsd  0xe4c(%rip),%xmm1
movsd  0x8(%rsp),%xmm4
movapd %xmm4,%xmm2
movsd  0xe42(%rip),%xmm3
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rbx,%rbp,8)
mulsd  %xmm3,%xmm0
mulsd  0xe30(%rip),%xmm4
addsd  %xmm0,%xmm4
addsd  0xe0c(%rip),%xmm4
movapd %xmm4,%xmm0
jmp    11aa <barnsley+0x6a>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rbx,%rbp,8),%xmm0
movapd %xmm0,%xmm1
cmp    $0x5c,%eax
ja     12a0 <barnsley+0x160>
mulsd  0xdc2(%rip),%xmm1
movsd  0x8(%rsp),%xmm3
movapd %xmm3,%xmm2
mulsd  0xdb8(%rip),%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rbx,%rbp,8)
mulsd  0xdae(%rip),%xmm0
mulsd  0xdae(%rip),%xmm3
addsd  %xmm0,%xmm3
addsd  0xdaa(%rip),%xmm3
jmp    12e0 <barnsley+0x1a0>
mulsd  0xd58(%rip),%xmm1
movsd  0x8(%rsp),%xmm3
movapd %xmm3,%xmm2
mulsd  0xd4e(%rip),%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rbx,%rbp,8)
mulsd  0xd44(%rip),%xmm0
mulsd  0xd44(%rip),%xmm3
addsd  %xmm0,%xmm3
addsd  0xd40(%rip),%xmm3
movapd %xmm3,%xmm0
jmp    11aa <barnsley+0x6a>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double* @barnsley(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double*
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = mul nsw i32 2, %6
%8 = sext i32 %7 to i64
%9 = mul i64 %8, 8
%10 = trunc i64 %9 to i32
%11 = call double* @malloc(i32 %10)
store double* %11, double** %5
%12 = load double*, double** %5
%13 = getelementptr inbounds double, double* %12, i64 0
store double 0.000000e+00, double* %13
%14 = load double*, double** %5
%15 = getelementptr inbounds double, double* %14, i64 1
store double 0.000000e+00, double* %15
%16 = call i32 @time(i32* null)
%17 = call i32 @srand(i32 %16)
store i32 2, i32* %3
br label %18
18: ; preds = %172, %1
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = mul nsw i32 2, %20
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %175
23: ; preds = %18
%24 = call i32 (...) @rand()
%25 = srem i32 %24, 100
store i32 %25, i32* %4
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %45
28: ; preds = %23
%29 = load double*, double** %5
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
store double 0.000000e+00, double* %32
%33 = load double*, double** %5
%34 = load i32, i32* %3
%35 = sub nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %33, i64 %36
%38 = load double, double* %37
%39 = fmul double 1.600000e-01, %38
%40 = load double*, double** %5
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %40, i64 %43
store double %39, double* %44
br label %171
45: ; preds = %23
%46 = load i32, i32* %4
%47 = icmp slt i32 %46, 86
br i1 %47, label %48, label %87
48: ; preds = %45
%49 = load double*, double** %5
%50 = load i32, i32* %3
%51 = sub nsw i32 %50, 2
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %49, i64 %52
%54 = load double, double* %53
%55 = load double*, double** %5
%56 = load i32, i32* %3
%57 = sub nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %55, i64 %58
%60 = load double, double* %59
%61 = fmul double 4.000000e-02, %60
%62 = call double @llvm.fmuladd.f64(double 8.500000e-01, double %54, double %61)
%63 = load double*, double** %5
%64 = load i32, i32* %3
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %63, i64 %65
store double %62, double* %66
%67 = load double*, double** %5
%68 = load i32, i32* %3
%69 = sub nsw i32 %68, 2
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %67, i64 %70
%72 = load double, double* %71
%73 = load double*, double** %5
%74 = load i32, i32* %3
%75 = sub nsw i32 %74, 1
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double, double* %73, i64 %76
%78 = load double, double* %77
%79 = fmul double 8.500000e-01, %78
%80 = call double @llvm.fmuladd.f64(double -4.000000e-02, double %72, double %79)
%81 = fadd double %80, 1.600000e+00
%82 = load double*, double** %5
%83 = load i32, i32* %3
%84 = add nsw i32 %83, 1
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %82, i64 %85
store double %81, double* %86
br label %170
87: ; preds = %45
%88 = load i32, i32* %4
%89 = icmp slt i32 %88, 93
br i1 %89, label %90, label %130
90: ; preds = %87
%91 = load double*, double** %5
%92 = load i32, i32* %3
%93 = sub nsw i32 %92, 2
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds double, double* %91, i64 %94
%96 = load double, double* %95
%97 = load double*, double** %5
%98 = load i32, i32* %3
%99 = sub nsw i32 %98, 1
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds double, double* %97, i64 %100
%102 = load double, double* %101
%103 = fmul double 2.600000e-01, %102
%104 = fneg double %103
%105 = call double @llvm.fmuladd.f64(double 2.000000e-01, double %96, double %104)
%106 = load double*, double** %5
%107 = load i32, i32* %3
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds double, double* %106, i64 %108
store double %105, double* %109
%110 = load double*, double** %5
%111 = load i32, i32* %3
%112 = sub nsw i32 %111, 2
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds double, double* %110, i64 %113
%115 = load double, double* %114
%116 = load double*, double** %5
%117 = load i32, i32* %3
%118 = sub nsw i32 %117, 1
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds double, double* %116, i64 %119
%121 = load double, double* %120
%122 = fmul double 2.200000e-01, %121
%123 = call double @llvm.fmuladd.f64(double 2.300000e-01, double %115, double %122)
%124 = fadd double %123, 1.600000e+00
%125 = load double*, double** %5
%126 = load i32, i32* %3
%127 = add nsw i32 %126, 1
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds double, double* %125, i64 %128
store double %124, double* %129
br label %169
130: ; preds = %87
%131 = load double*, double** %5
%132 = load i32, i32* %3
%133 = sub nsw i32 %132, 2
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds double, double* %131, i64 %134
%136 = load double, double* %135
%137 = load double*, double** %5
%138 = load i32, i32* %3
%139 = sub nsw i32 %138, 1
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds double, double* %137, i64 %140
%142 = load double, double* %141
%143 = fmul double 2.800000e-01, %142
%144 = call double @llvm.fmuladd.f64(double -1.500000e-01, double %136, double %143)
%145 = load double*, double** %5
%146 = load i32, i32* %3
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds double, double* %145, i64 %147
store double %144, double* %148
%149 = load double*, double** %5
%150 = load i32, i32* %3
%151 = sub nsw i32 %150, 2
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds double, double* %149, i64 %152
%154 = load double, double* %153
%155 = load double*, double** %5
%156 = load i32, i32* %3
%157 = sub nsw i32 %156, 1
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds double, double* %155, i64 %158
%160 = load double, double* %159
%161 = fmul double 2.400000e-01, %160
%162 = call double @llvm.fmuladd.f64(double 2.600000e-01, double %154, double %161)
%163 = fadd double %162, 4.400000e-01
%164 = load double*, double** %5
%165 = load i32, i32* %3
%166 = add nsw i32 %165, 1
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds double, double* %164, i64 %167
store double %163, double* %168
br label %169
169: ; preds = %130, %90
br label %170
170: ; preds = %169, %48
br label %171
171: ; preds = %170, %28
br label %172
172: ; preds = %171
%173 = load i32, i32* %3
%174 = add nsw i32 %173, 2
store i32 %174, i32* %3
br label %18
175: ; preds = %18
%176 = load double*, double** %5
ret double* %176
}

LLVM IR (-O2):
define noalias double* @barnsley(i32 %0) {
%2 = shl i32 %0, 4
%3 = tail call double* @malloc(i32 %2)
%4 = bitcast double* %3 to i8*
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %61
8: ; preds = %1
%9 = shl nuw nsw i32 %0, 1
%10 = sext i32 %9 to i64
br label %11
11: ; preds = %8, %54
%12 = phi double [ 0.000000e+00, %8 ], [ %56, %54 ]
%13 = phi i64 [ 2, %8 ], [ %59, %54 ]
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, 100
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %11
%18 = getelementptr inbounds double, double* %3, i64 %13
store double 0.000000e+00, double* %18
%19 = add nsw i64 %13, -1
%20 = getelementptr inbounds double, double* %3, i64 %19
%21 = load double, double* %20
%22 = fmul double %21, 1.600000e-01
br label %54
23: ; preds = %11
%24 = icmp ult i32 %15, 86
br i1 %24, label %25, label %35
25: ; preds = %23
%26 = add nsw i64 %13, -1
%27 = getelementptr inbounds double, double* %3, i64 %26
%28 = load double, double* %27
%29 = fmul double %28, 4.000000e-02
%30 = tail call double @llvm.fmuladd.f64(double %12, double 8.500000e-01, double %29)
%31 = getelementptr inbounds double, double* %3, i64 %13
store double %30, double* %31
%32 = fmul double %28, 8.500000e-01
%33 = tail call double @llvm.fmuladd.f64(double %12, double -4.000000e-02, double %32)
%34 = fadd double %33, 1.600000e+00
br label %54
35: ; preds = %23
%36 = icmp ult i32 %15, 93
%37 = add nsw i64 %13, -1
%38 = getelementptr inbounds double, double* %3, i64 %37
%39 = load double, double* %38
br i1 %36, label %40, label %47
40: ; preds = %35
%41 = fmul double %39, -2.600000e-01
%42 = tail call double @llvm.fmuladd.f64(double %12, double 2.000000e-01, double %41)
%43 = getelementptr inbounds double, double* %3, i64 %13
store double %42, double* %43
%44 = fmul double %39, 2.200000e-01
%45 = tail call double @llvm.fmuladd.f64(double %12, double 2.300000e-01, double %44)
%46 = fadd double %45, 1.600000e+00
br label %54
47: ; preds = %35
%48 = fmul double %39, 2.800000e-01
%49 = tail call double @llvm.fmuladd.f64(double %12, double -1.500000e-01, double %48)
%50 = getelementptr inbounds double, double* %3, i64 %13
store double %49, double* %50
%51 = fmul double %39, 2.400000e-01
%52 = tail call double @llvm.fmuladd.f64(double %12, double 2.600000e-01, double %51)
%53 = fadd double %52, 4.400000e-01
br label %54
54: ; preds = %17, %40, %47, %25
%55 = phi double [ %22, %17 ], [ %46, %40 ], [ %53, %47 ], [ %34, %25 ]
%56 = phi double [ 0.000000e+00, %17 ], [ %42, %40 ], [ %49, %47 ], [ %30, %25 ]
%57 = or i64 %13, 1
%58 = getelementptr inbounds double, double* %3, i64 %57
store double %55, double* %58
%59 = add nuw nsw i64 %13, 2
%60 = icmp slt i64 %59, %10
br i1 %60, label %11, label %61
61: ; preds = %54, %1
ret double* %3
}