#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 M_PI;
double cos(double);
double randomn(double);
double sin(double);
int /*<<< orphan*/ tower(double, double, double, double);
int /*<<< orphan*/ wall(double, double, double, double, double, double);
void enclosure(int npoints, double r, double height) {
  double thickness = r * (0.08);
  double angle = 2.0 * M_PI / (double)npoints;
  double ix, iy, x1, y1, x2, y2, a = 0;
  double dx, dy;
  int i;
  dx = randomn(r * (0.3) * 2.0) - r * (0.3);
  dy = randomn(r * (0.3) * 2.0) - r * (0.3);
  ix = x1 = cos(a) * r + dx;
  iy = y1 = sin(a) * r + dy;
  for (i = 0; i < npoints - 1; i++) {
    a += angle;
    dx = randomn(r * 0.3) - r * 0.15;
    dy = randomn(r * 0.3) - r * 0.15;
    x2 = cos(a) * r + dx;
    y2 = sin(a) * r + dy;
    wall(x1, y1, x2, y2, thickness, height);
    tower(x1, y1, thickness * 2.0, height * 1.25);
    x1 = x2;
    y1 = y2;
  }
  wall(x1, y1, ix, iy, thickness, height);
  tower(x1, y1, thickness * 2.0, height * 1.25);
}


x86 assembly (clang, -O0):
<enclosure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  0xea0(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe86(%rip),%xmm0
mov    0x2e5f(%rip),%rax
mulsd  (%rax),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe55(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe50(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1060 <randomn@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe18(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xe03(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xdfe(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1060 <randomn@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xdc6(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1050 <cos@plt>
movsd  -0x10(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  %xmm0,-0x30(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x10(%rbp),%xmm2
movsd  -0x70(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    13f6 <enclosure+0x2a6>
movsd  -0x28(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xd3e(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1060 <randomn@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd2d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xcf8(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1060 <randomn@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xce7(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1050 <cos@plt>
movsd  -0x10(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x10(%rbp),%xmm2
movsd  -0x70(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm4
movsd  -0x18(%rbp),%xmm5
call   1040 <wall@plt>
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xc4b(%rip),%xmm2
mulsd  -0x20(%rbp),%xmm2
movsd  0xc4e(%rip),%xmm3
mulsd  -0x18(%rbp),%xmm3
call   1070 <tower@plt>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    129a <enclosure+0x14a>
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm4
movsd  -0x18(%rbp),%xmm5
call   1040 <wall@plt>
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xbdd(%rip),%xmm2
mulsd  -0x20(%rbp),%xmm2
movsd  0xbe0(%rip),%xmm3
mulsd  -0x18(%rbp),%xmm3
call   1070 <tower@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enclosure>:
push   %rbx
sub    $0xc0,%rsp
movsd  %xmm1,0x38(%rsp)
movapd %xmm0,%xmm1
movapd %xmm0,0x40(%rsp)
mov    %edi,%ebx
movsd  0xe8e(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x30(%rsp)
mov    0x2e65(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x28(%rsp)
mulsd  0xe73(%rip),%xmm1
movapd %xmm1,0xa0(%rsp)
addsd  %xmm1,%xmm1
movapd %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
call   1060 <randomn@plt>
movapd 0xe67(%rip),%xmm2
xorpd  0x40(%rsp),%xmm2
movapd %xmm2,0x90(%rsp)
movsd  0xe38(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  %xmm1,(%rsp)
addsd  %xmm1,%xmm0
movapd %xmm0,0x80(%rsp)
movapd 0x10(%rsp),%xmm0
call   1060 <randomn@plt>
movapd 0x80(%rsp),%xmm3
addsd  (%rsp),%xmm0
movapd 0x40(%rsp),%xmm7
addsd  %xmm7,%xmm3
xorpd  %xmm2,%xmm2
mulsd  %xmm2,%xmm7
addsd  %xmm0,%xmm7
movsd  0x30(%rsp),%xmm5
addsd  %xmm5,%xmm5
movsd  0xde9(%rip),%xmm6
movsd  0x38(%rsp),%xmm0
mulsd  %xmm0,%xmm6
cmp    $0x2,%ebx
movapd %xmm3,0x80(%rsp)
movapd %xmm7,0xb0(%rsp)
movsd  %xmm6,0x68(%rsp)
movsd  %xmm5,0x60(%rsp)
jl     13a1 <enclosure+0x251>
movsd  0x28(%rsp),%xmm4
addsd  %xmm4,%xmm4
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
divsd  %xmm0,%xmm4
movsd  %xmm4,0x28(%rsp)
add    $0xffffffff,%ebx
movapd 0x90(%rsp),%xmm4
unpcklpd %xmm4,%xmm4
movaps 0x40(%rsp),%xmm0
movlhps %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
mulpd  0xd98(%rip),%xmm4
movapd %xmm4,0x90(%rsp)
movapd %xmm3,%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm7,0x70(%rsp)
movsd  %xmm0,0x78(%rsp)
addsd  0x28(%rsp),%xmm2
movsd  %xmm2,(%rsp)
movaps 0xa0(%rsp),%xmm0
call   1060 <randomn@plt>
movaps %xmm0,0x50(%rsp)
movapd 0xa0(%rsp),%xmm0
call   1060 <randomn@plt>
movapd 0x50(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
addpd  0x90(%rsp),%xmm1
movapd %xmm1,0x50(%rsp)
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
movapd 0x10(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
mulpd  0x40(%rsp),%xmm1
addpd  0x50(%rsp),%xmm1
movapd %xmm1,%xmm3
movapd %xmm1,%xmm2
movapd %xmm1,0x10(%rsp)
unpckhpd %xmm1,%xmm3
movapd %xmm3,0x50(%rsp)
movsd  0x78(%rsp),%xmm0
movsd  0x70(%rsp),%xmm1
movsd  0x30(%rsp),%xmm4
movsd  0x38(%rsp),%xmm5
call   1040 <wall@plt>
movsd  0x78(%rsp),%xmm0
movsd  0x70(%rsp),%xmm1
movsd  0x60(%rsp),%xmm2
movsd  0x68(%rsp),%xmm3
call   1070 <tower@plt>
movapd 0x10(%rsp),%xmm3
movsd  (%rsp),%xmm2
movapd %xmm3,%xmm0
movapd 0x50(%rsp),%xmm7
add    $0xffffffff,%ebx
jne    12b0 <enclosure+0x160>
jmp    13a5 <enclosure+0x255>
unpcklpd %xmm7,%xmm3
movapd %xmm3,%xmm1
unpckhpd %xmm3,%xmm1
movapd %xmm1,(%rsp)
movapd %xmm3,%xmm0
movapd %xmm3,0x10(%rsp)
movaps 0x80(%rsp),%xmm2
movaps 0xb0(%rsp),%xmm3
movsd  0x30(%rsp),%xmm4
movsd  0x38(%rsp),%xmm5
call   1040 <wall@plt>
movaps 0x10(%rsp),%xmm0
movaps (%rsp),%xmm1
movsd  0x60(%rsp),%xmm2
movsd  0x68(%rsp),%xmm3
add    $0xc0,%rsp
pop    %rbx
jmp    1070 <tower@plt>

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @enclosure(i32 %0, double %1, double %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca i32
store i32 %0, i32* %4
store double %1, double* %5
store double %2, double* %6
%19 = load double, double* %5
%20 = fmul double %19, 8.000000e-02
store double %20, double* %7
%21 = load double, double* @M_PI
%22 = fmul double 2.000000e+00, %21
%23 = load i32, i32* %4
%24 = sitofp i32 %23 to double
%25 = fdiv double %22, %24
store double %25, double* %8
store double 0.000000e+00, double* %15
%26 = load double, double* %5
%27 = fmul double %26, 3.000000e-01
%28 = fmul double %27, 2.000000e+00
%29 = call double @randomn(double %28)
%30 = load double, double* %5
%31 = fneg double %30
%32 = call double @llvm.fmuladd.f64(double %31, double 3.000000e-01, double %29)
store double %32, double* %16
%33 = load double, double* %5
%34 = fmul double %33, 3.000000e-01
%35 = fmul double %34, 2.000000e+00
%36 = call double @randomn(double %35)
%37 = load double, double* %5
%38 = fneg double %37
%39 = call double @llvm.fmuladd.f64(double %38, double 3.000000e-01, double %36)
store double %39, double* %17
%40 = load double, double* %15
%41 = call double @cos(double %40)
%42 = load double, double* %5
%43 = load double, double* %16
%44 = call double @llvm.fmuladd.f64(double %41, double %42, double %43)
store double %44, double* %11
store double %44, double* %9
%45 = load double, double* %15
%46 = call double @sin(double %45)
%47 = load double, double* %5
%48 = load double, double* %17
%49 = call double @llvm.fmuladd.f64(double %46, double %47, double %48)
store double %49, double* %12
store double %49, double* %10
store i32 0, i32* %18
br label %50
50: ; preds = %97, %3
%51 = load i32, i32* %18
%52 = load i32, i32* %4
%53 = sub nsw i32 %52, 1
%54 = icmp slt i32 %51, %53
br i1 %54, label %55, label %100
55: ; preds = %50
%56 = load double, double* %8
%57 = load double, double* %15
%58 = fadd double %57, %56
store double %58, double* %15
%59 = load double, double* %5
%60 = fmul double %59, 3.000000e-01
%61 = call double @randomn(double %60)
%62 = load double, double* %5
%63 = fneg double %62
%64 = call double @llvm.fmuladd.f64(double %63, double 1.500000e-01, double %61)
store double %64, double* %16
%65 = load double, double* %5
%66 = fmul double %65, 3.000000e-01
%67 = call double @randomn(double %66)
%68 = load double, double* %5
%69 = fneg double %68
%70 = call double @llvm.fmuladd.f64(double %69, double 1.500000e-01, double %67)
store double %70, double* %17
%71 = load double, double* %15
%72 = call double @cos(double %71)
%73 = load double, double* %5
%74 = load double, double* %16
%75 = call double @llvm.fmuladd.f64(double %72, double %73, double %74)
store double %75, double* %13
%76 = load double, double* %15
%77 = call double @sin(double %76)
%78 = load double, double* %5
%79 = load double, double* %17
%80 = call double @llvm.fmuladd.f64(double %77, double %78, double %79)
store double %80, double* %14
%81 = load double, double* %11
%82 = load double, double* %12
%83 = load double, double* %13
%84 = load double, double* %14
%85 = load double, double* %7
%86 = load double, double* %6
%87 = call i32 @wall(double %81, double %82, double %83, double %84, double %85, double %86)
%88 = load double, double* %11
%89 = load double, double* %12
%90 = load double, double* %7
%91 = fmul double %90, 2.000000e+00
%92 = load double, double* %6
%93 = fmul double %92, 1.250000e+00
%94 = call i32 @tower(double %88, double %89, double %91, double %93)
%95 = load double, double* %13
store double %95, double* %11
%96 = load double, double* %14
store double %96, double* %12
br label %97
97: ; preds = %55
%98 = load i32, i32* %18
%99 = add nsw i32 %98, 1
store i32 %99, i32* %18
br label %50
100: ; preds = %50
%101 = load double, double* %11
%102 = load double, double* %12
%103 = load double, double* %9
%104 = load double, double* %10
%105 = load double, double* %7
%106 = load double, double* %6
%107 = call i32 @wall(double %101, double %102, double %103, double %104, double %105, double %106)
%108 = load double, double* %11
%109 = load double, double* %12
%110 = load double, double* %7
%111 = fmul double %110, 2.000000e+00
%112 = load double, double* %6
%113 = fmul double %112, 1.250000e+00
%114 = call i32 @tower(double %108, double %109, double %111, double %113)
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @enclosure(i32 %0, double %1, double %2) {
%4 = fmul double %1, 8.000000e-02
%5 = load double, double* @M_PI
%6 = fmul double %5, 2.000000e+00
%7 = sitofp i32 %0 to double
%8 = fdiv double %6, %7
%9 = fmul double %1, 3.000000e-01
%10 = fmul double %9, 2.000000e+00
%11 = tail call double @randomn(double %10)
%12 = fneg double %1
%13 = tail call double @llvm.fmuladd.f64(double %12, double 3.000000e-01, double %11)
%14 = tail call double @randomn(double %10)
%15 = tail call double @llvm.fmuladd.f64(double %12, double 3.000000e-01, double %14)
%16 = fadd double %13, %1
%17 = tail call double @llvm.fmuladd.f64(double %1, double 0.000000e+00, double %15)
%18 = add i32 %0, -1
%19 = icmp sgt i32 %0, 1
%20 = fmul double %4, 2.000000e+00
%21 = fmul double %2, 1.250000e+00
%22 = insertelement <2 x double> poison, double %16, i64 0
%23 = insertelement <2 x double> %22, double %17, i64 1
br i1 %19, label %24, label %51
24: ; preds = %3
%25 = insertelement <2 x double> poison, double %12, i64 0
%26 = shufflevector <2 x double> %25, <2 x double> poison, <2 x i32> zeroinitializer
%27 = insertelement <2 x double> poison, double %1, i64 0
%28 = shufflevector <2 x double> %27, <2 x double> poison, <2 x i32> zeroinitializer
br label %29
29: ; preds = %24, %29
%30 = phi i32 [ %49, %29 ], [ 0, %24 ]
%31 = phi double [ %34, %29 ], [ 0.000000e+00, %24 ]
%32 = phi double [ %45, %29 ], [ %16, %24 ]
%33 = phi double [ %46, %29 ], [ %17, %24 ]
%34 = fadd double %8, %31
%35 = tail call double @randomn(double %9)
%36 = tail call double @randomn(double %9)
%37 = insertelement <2 x double> poison, double %35, i64 0
%38 = insertelement <2 x double> %37, double %36, i64 1
%39 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %26, <2 x double> <double 1.500000e-01, double 1.500000e-01>, <2 x double> %38)
%40 = tail call double @cos(double %34)
%41 = tail call double @sin(double %34)
%42 = insertelement <2 x double> poison, double %40, i64 0
%43 = insertelement <2 x double> %42, double %41, i64 1
%44 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %43, <2 x double> %28, <2 x double> %39)
%45 = extractelement <2 x double> %44, i64 0
%46 = extractelement <2 x double> %44, i64 1
%47 = tail call i32 @wall(double %32, double %33, double %45, double %46, double %4, double %2)
%48 = tail call i32 @tower(double %32, double %33, double %20, double %21)
%49 = add nuw nsw i32 %30, 1
%50 = icmp eq i32 %49, %18
br i1 %50, label %51, label %29
51: ; preds = %29, %3
%52 = phi <2 x double> [ %23, %3 ], [ %44, %29 ]
%53 = extractelement <2 x double> %52, i64 0
%54 = extractelement <2 x double> %52, i64 1
%55 = tail call i32 @wall(double %53, double %54, double %16, double %17, double %4, double %2)
%56 = tail call i32 @tower(double %53, double %54, double %20, double %21)
ret void
}