#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*/ angular_tower(double, double, double, double, int, double);
int irandomn(int);
double perturb(double, double);
double perturbup(double, double);
int /*<<< orphan*/ pointy_tower(double, double, double, double, int, double);
int /*<<< orphan*/ round_tower(double, double, double, double, int);
void generic_tower(double x, double y, double r, double h, int flying_allowed) {
  double origh = h;
  double origr = r;
  int flying = (irandomn(100) < 30) && flying_allowed;
  h = perturbup(h, (0.15));
  r = perturb(r, (0.5));
  switch (irandomn(20)) {
  case 0:
    angular_tower(x, y, origr, origh, flying, 90.0);
    break;
  case 1:
    angular_tower(x, y, r, h, flying, 90.0);
    break;
  case 2:
    pointy_tower(x, y, r, h, flying, 5.0);
    break;
  case 3:
    angular_tower(x, y, r, h, flying, 72.0);
    break;
  case 4:
    angular_tower(x, y, r, h, flying, 90.0);
    break;
  case 5:
    angular_tower(x, y, r, h, flying, 60.0);
    break;
  case 6:
    angular_tower(x, y, r, h, flying, 45.0);
    break;
  case 7:
    pointy_tower(x, y, r, h, flying, 72.0);
    break;
  case 8:
    pointy_tower(x, y, r, h, flying, 90.0);
    break;
  case 9:
    pointy_tower(x, y, r, h, flying, 60.0);
    break;
  case 10:
    pointy_tower(x, y, r, h, flying, 45.0);
    break;
  default:
    round_tower(x, y, r, h, flying);
    break;
  }
}


x86 assembly (clang, -O0):
<generic_tower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %edi,-0x24(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    $0x64,%edi
call   1080 <irandomn@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1e,%ecx
mov    %al,-0x3d(%rbp)
jge    11b7 <generic_tower+0x57>
cmpl   $0x0,-0x24(%rbp)
setne  %al
mov    %al,-0x3d(%rbp)
mov    -0x3d(%rbp),%al
movzbl %al,%eax
and    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe30(%rip),%xmm1
call   1030 <perturbup@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe21(%rip),%xmm1
call   1040 <perturb@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x14,%edi
call   1080 <irandomn@plt>
mov    %eax,%ecx
mov    %rcx,-0x48(%rbp)
sub    $0xa,%eax
ja     13e1 <generic_tower+0x281>
mov    -0x48(%rbp),%rax
lea    0xe23(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
mov    -0x3c(%rbp),%edi
movsd  0xde3(%rip),%xmm4
call   1050 <angular_tower@plt>
jmp    13fd <generic_tower+0x29d>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
mov    -0x3c(%rbp),%edi
movsd  0xdba(%rip),%xmm4
call   1050 <angular_tower@plt>
jmp    13fd <generic_tower+0x29d>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
mov    -0x3c(%rbp),%edi
movsd  0xda1(%rip),%xmm4
call   1070 <pointy_tower@plt>
jmp    13fd <generic_tower+0x29d>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
mov    -0x3c(%rbp),%edi
movsd  0xd70(%rip),%xmm4
call   1050 <angular_tower@plt>
jmp    13fd <generic_tower+0x29d>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
mov    -0x3c(%rbp),%edi
movsd  0xd3f(%rip),%xmm4
call   1050 <angular_tower@plt>
jmp    13fd <generic_tower+0x29d>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
mov    -0x3c(%rbp),%edi
movsd  0xd0e(%rip),%xmm4
call   1050 <angular_tower@plt>
jmp    13fd <generic_tower+0x29d>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
mov    -0x3c(%rbp),%edi
movsd  0xcdd(%rip),%xmm4
call   1050 <angular_tower@plt>
jmp    13fd <generic_tower+0x29d>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
mov    -0x3c(%rbp),%edi
movsd  0xccc(%rip),%xmm4
call   1070 <pointy_tower@plt>
jmp    13fd <generic_tower+0x29d>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
mov    -0x3c(%rbp),%edi
movsd  0xc9b(%rip),%xmm4
call   1070 <pointy_tower@plt>
jmp    13fd <generic_tower+0x29d>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
mov    -0x3c(%rbp),%edi
movsd  0xc6a(%rip),%xmm4
call   1070 <pointy_tower@plt>
jmp    13fd <generic_tower+0x29d>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
mov    -0x3c(%rbp),%edi
movsd  0xc39(%rip),%xmm4
call   1070 <pointy_tower@plt>
jmp    13fd <generic_tower+0x29d>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
mov    -0x3c(%rbp),%edi
call   1060 <round_tower@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generic_tower>:
push   %rbx
sub    $0x30,%rsp
mov    %edi,%ebx
movsd  %xmm3,0x28(%rsp)
movsd  %xmm2,0x20(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
mov    $0x64,%edi
call   1080 <irandomn@plt>
cmp    $0x1e,%eax
setl   %al
test   %ebx,%ebx
setne  %cl
and    %al,%cl
movzbl %cl,%ebx
movsd  0xe60(%rip),%xmm1
movsd  0x28(%rsp),%xmm0
call   1030 <perturbup@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0xe4f(%rip),%xmm1
movsd  0x20(%rsp),%xmm0
call   1040 <perturb@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0x14,%edi
call   1080 <irandomn@plt>
cmp    $0xa,%eax
ja     11f5 <generic_tower+0x95>
mov    %eax,%eax
lea    0xe56(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0xe2d(%rip),%xmm4
jmp    125f <generic_tower+0xff>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
mov    %ebx,%edi
add    $0x30,%rsp
pop    %rbx
jmp    1060 <round_tower@plt>
movsd  0xe00(%rip),%xmm4
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movsd  0x28(%rsp),%xmm3
jmp    1276 <generic_tower+0x116>
movsd  0xdef(%rip),%xmm4
jmp    12a8 <generic_tower+0x148>
movsd  0xddd(%rip),%xmm4
jmp    125f <generic_tower+0xff>
movsd  0xdc3(%rip),%xmm4
jmp    125f <generic_tower+0xff>
movsd  0xdb1(%rip),%xmm4
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
mov    %ebx,%edi
add    $0x30,%rsp
pop    %rbx
jmp    1050 <angular_tower@plt>
movsd  0xd9e(%rip),%xmm4
jmp    12a8 <generic_tower+0x148>
movsd  0xd8c(%rip),%xmm4
jmp    12a8 <generic_tower+0x148>
movsd  0xd7a(%rip),%xmm4
jmp    12a8 <generic_tower+0x148>
movsd  0xd68(%rip),%xmm4
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
mov    %ebx,%edi
add    $0x30,%rsp
pop    %rbx
jmp    1070 <pointy_tower@plt>

LLVM IR (-O0):
define void @generic_tower(double %0, double %1, double %2, double %3, i32 %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca i32
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store i32 %4, i32* %10
%14 = load double, double* %9
store double %14, double* %11
%15 = load double, double* %8
store double %15, double* %12
%16 = call i32 @irandomn(i32 100)
%17 = icmp slt i32 %16, 30
br i1 %17, label %18, label %21
18: ; preds = %5
%19 = load i32, i32* %10
%20 = icmp ne i32 %19, 0
br label %21
21: ; preds = %18, %5
%22 = phi i1 [ false, %5 ], [ %20, %18 ]
%23 = zext i1 %22 to i32
store i32 %23, i32* %13
%24 = load double, double* %9
%25 = call double @perturbup(double %24, double 1.500000e-01)
store double %25, double* %9
%26 = load double, double* %8
%27 = call double @perturb(double %26, double 5.000000e-01)
store double %27, double* %8
%28 = call i32 @irandomn(i32 20)
switch i32 %28, label %106 [
i32 0, label %29
i32 1, label %36
i32 2, label %43
i32 3, label %50
i32 4, label %57
i32 5, label %64
i32 6, label %71
i32 7, label %78
i32 8, label %85
i32 9, label %92
i32 10, label %99
]
29: ; preds = %21
%30 = load double, double* %6
%31 = load double, double* %7
%32 = load double, double* %12
%33 = load double, double* %11
%34 = load i32, i32* %13
%35 = call i32 @angular_tower(double %30, double %31, double %32, double %33, i32 %34, double 9.000000e+01)
br label %113
36: ; preds = %21
%37 = load double, double* %6
%38 = load double, double* %7
%39 = load double, double* %8
%40 = load double, double* %9
%41 = load i32, i32* %13
%42 = call i32 @angular_tower(double %37, double %38, double %39, double %40, i32 %41, double 9.000000e+01)
br label %113
43: ; preds = %21
%44 = load double, double* %6
%45 = load double, double* %7
%46 = load double, double* %8
%47 = load double, double* %9
%48 = load i32, i32* %13
%49 = call i32 @pointy_tower(double %44, double %45, double %46, double %47, i32 %48, double 5.000000e+00)
br label %113
50: ; preds = %21
%51 = load double, double* %6
%52 = load double, double* %7
%53 = load double, double* %8
%54 = load double, double* %9
%55 = load i32, i32* %13
%56 = call i32 @angular_tower(double %51, double %52, double %53, double %54, i32 %55, double 7.200000e+01)
br label %113
57: ; preds = %21
%58 = load double, double* %6
%59 = load double, double* %7
%60 = load double, double* %8
%61 = load double, double* %9
%62 = load i32, i32* %13
%63 = call i32 @angular_tower(double %58, double %59, double %60, double %61, i32 %62, double 9.000000e+01)
br label %113
64: ; preds = %21
%65 = load double, double* %6
%66 = load double, double* %7
%67 = load double, double* %8
%68 = load double, double* %9
%69 = load i32, i32* %13
%70 = call i32 @angular_tower(double %65, double %66, double %67, double %68, i32 %69, double 6.000000e+01)
br label %113
71: ; preds = %21
%72 = load double, double* %6
%73 = load double, double* %7
%74 = load double, double* %8
%75 = load double, double* %9
%76 = load i32, i32* %13
%77 = call i32 @angular_tower(double %72, double %73, double %74, double %75, i32 %76, double 4.500000e+01)
br label %113
78: ; preds = %21
%79 = load double, double* %6
%80 = load double, double* %7
%81 = load double, double* %8
%82 = load double, double* %9
%83 = load i32, i32* %13
%84 = call i32 @pointy_tower(double %79, double %80, double %81, double %82, i32 %83, double 7.200000e+01)
br label %113
85: ; preds = %21
%86 = load double, double* %6
%87 = load double, double* %7
%88 = load double, double* %8
%89 = load double, double* %9
%90 = load i32, i32* %13
%91 = call i32 @pointy_tower(double %86, double %87, double %88, double %89, i32 %90, double 9.000000e+01)
br label %113
92: ; preds = %21
%93 = load double, double* %6
%94 = load double, double* %7
%95 = load double, double* %8
%96 = load double, double* %9
%97 = load i32, i32* %13
%98 = call i32 @pointy_tower(double %93, double %94, double %95, double %96, i32 %97, double 6.000000e+01)
br label %113
99: ; preds = %21
%100 = load double, double* %6
%101 = load double, double* %7
%102 = load double, double* %8
%103 = load double, double* %9
%104 = load i32, i32* %13
%105 = call i32 @pointy_tower(double %100, double %101, double %102, double %103, i32 %104, double 4.500000e+01)
br label %113
106: ; preds = %21
%107 = load double, double* %6
%108 = load double, double* %7
%109 = load double, double* %8
%110 = load double, double* %9
%111 = load i32, i32* %13
%112 = call i32 @round_tower(double %107, double %108, double %109, double %110, i32 %111)
br label %113
113: ; preds = %106, %99, %92, %85, %78, %71, %64, %57, %50, %43, %36, %29
ret void
}

LLVM IR (-O2):
define void @generic_tower(double %0, double %1, double %2, double %3, i32 %4) {
%6 = tail call i32 @irandomn(i32 100)
%7 = icmp slt i32 %6, 30
%8 = icmp ne i32 %4, 0
%9 = and i1 %8, %7
%10 = zext i1 %9 to i32
%11 = tail call double @perturbup(double %3, double 1.500000e-01)
%12 = tail call double @perturb(double %2, double 5.000000e-01)
%13 = tail call i32 @irandomn(i32 20)
switch i32 %13, label %36 [
i32 0, label %14
i32 1, label %16
i32 2, label %18
i32 3, label %20
i32 4, label %22
i32 5, label %24
i32 6, label %26
i32 7, label %28
i32 8, label %30
i32 9, label %32
i32 10, label %34
]
14: ; preds = %5
%15 = tail call i32 @angular_tower(double %0, double %1, double %2, double %3, i32 %10, double 9.000000e+01)
br label %38
16: ; preds = %5
%17 = tail call i32 @angular_tower(double %0, double %1, double %12, double %11, i32 %10, double 9.000000e+01)
br label %38
18: ; preds = %5
%19 = tail call i32 @pointy_tower(double %0, double %1, double %12, double %11, i32 %10, double 5.000000e+00)
br label %38
20: ; preds = %5
%21 = tail call i32 @angular_tower(double %0, double %1, double %12, double %11, i32 %10, double 7.200000e+01)
br label %38
22: ; preds = %5
%23 = tail call i32 @angular_tower(double %0, double %1, double %12, double %11, i32 %10, double 9.000000e+01)
br label %38
24: ; preds = %5
%25 = tail call i32 @angular_tower(double %0, double %1, double %12, double %11, i32 %10, double 6.000000e+01)
br label %38
26: ; preds = %5
%27 = tail call i32 @angular_tower(double %0, double %1, double %12, double %11, i32 %10, double 4.500000e+01)
br label %38
28: ; preds = %5
%29 = tail call i32 @pointy_tower(double %0, double %1, double %12, double %11, i32 %10, double 7.200000e+01)
br label %38
30: ; preds = %5
%31 = tail call i32 @pointy_tower(double %0, double %1, double %12, double %11, i32 %10, double 9.000000e+01)
br label %38
32: ; preds = %5
%33 = tail call i32 @pointy_tower(double %0, double %1, double %12, double %11, i32 %10, double 6.000000e+01)
br label %38
34: ; preds = %5
%35 = tail call i32 @pointy_tower(double %0, double %1, double %12, double %11, i32 %10, double 4.500000e+01)
br label %38
36: ; preds = %5
%37 = tail call i32 @round_tower(double %0, double %1, double %12, double %11, i32 %10)
br label %38
38: ; preds = %36, %34, %32, %30, %28, %26, %24, %22, %20, %18, %16, %14
ret void
}