#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*/ cube(double, double, double, int);
int /*<<< orphan*/ endrotate();
int /*<<< orphan*/ endxlate();
int /*<<< orphan*/ rotate(int, int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ scadinline(char *, int);
int /*<<< orphan*/ xlate(double, int /*<<< orphan*/, double);
void crenelation_array(double width, double length, double height,
                       double thickness, int n) {
  int i;
  double x;
  double spacing;
  spacing = (width - thickness * 2) / (double)n;
  scadinline("/* n = %d */\n", n);
  x = -(spacing * (n - 1)) / 2.0;
  xlate(0, 0, height / 2.0);
  for (i = 0; i < n; i++) {
    xlate(x, 0, 0);
    rotate(90, 0, 0, 1);
    cube(length * 1.1, thickness, height, 1);
    endrotate();
    endxlate();
    x += spacing;
  }
  endxlate();
}


x86 assembly (clang, -O0):
<crenelation_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %edi,-0x24(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe50(%rip),%rdi
call   1040 <scadinline@plt>
movsd  -0x38(%rbp),%xmm0
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe09(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  0xdf3(%rip),%xmm0
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
xor    %edi,%edi
call   1030 <xlate@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    129c <crenelation_array+0x13c>
movsd  -0x30(%rbp),%xmm0
xor    %edi,%edi
xorps  %xmm1,%xmm1
call   1030 <xlate@plt>
mov    $0x5a,%edi
xor    %edx,%edx
mov    $0x1,%ecx
mov    %edx,%esi
call   1050 <rotate@plt>
movsd  0xdb0(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
mov    $0x1,%edi
call   1080 <cube@plt>
mov    $0x0,%al
call   1060 <endrotate@plt>
mov    $0x0,%al
call   1070 <endxlate@plt>
movsd  -0x38(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1222 <crenelation_array+0xc2>
mov    $0x0,%al
call   1070 <endxlate@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crenelation_array>:
push   %rbx
sub    $0x30,%rsp
mov    %edi,%ebx
movsd  %xmm3,0x18(%rsp)
movsd  %xmm2,0x20(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
lea    0xe92(%rip),%rdi
mov    %ebx,%esi
call   1040 <scadinline@plt>
movsd  0xe6b(%rip),%xmm1
mulsd  0x20(%rsp),%xmm1
xorpd  %xmm0,%xmm0
xor    %edi,%edi
call   1030 <xlate@plt>
test   %ebx,%ebx
jle    1263 <crenelation_array+0x103>
movsd  0x18(%rsp),%xmm0
addsd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
divsd  %xmm0,%xmm1
lea    -0x1(%rbx),%eax
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
movsd  %xmm1,0x8(%rsp)
mulsd  %xmm1,%xmm2
mulsd  0xe1f(%rip),%xmm2
movsd  0x10(%rsp),%xmm0
mulsd  0xe19(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
nopl   (%rax)
movsd  %xmm2,0x28(%rsp)
xorpd  %xmm1,%xmm1
movapd %xmm2,%xmm0
xor    %edi,%edi
call   1030 <xlate@plt>
mov    $0x5a,%edi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x1,%ecx
call   1050 <rotate@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
mov    $0x1,%edi
call   1080 <cube@plt>
xor    %eax,%eax
call   1060 <endrotate@plt>
xor    %eax,%eax
call   1070 <endxlate@plt>
movsd  0x28(%rsp),%xmm2
addsd  0x8(%rsp),%xmm2
add    $0xffffffff,%ebx
jne    1200 <crenelation_array+0xa0>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
jmp    1070 <endxlate@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"/* n = %d */\0A\00"
define void @crenelation_array(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 i32
%12 = alloca double
%13 = alloca double
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* %6
%15 = load double, double* %9
%16 = fneg double %15
%17 = call double @llvm.fmuladd.f64(double %16, double 2.000000e+00, double %14)
%18 = load i32, i32* %10
%19 = sitofp i32 %18 to double
%20 = fdiv double %17, %19
store double %20, double* %13
%21 = load i32, i32* %10
%22 = call i32 @scadinline(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load double, double* %13
%24 = load i32, i32* %10
%25 = sub nsw i32 %24, 1
%26 = sitofp i32 %25 to double
%27 = fmul double %23, %26
%28 = fneg double %27
%29 = fdiv double %28, 2.000000e+00
store double %29, double* %12
%30 = load double, double* %8
%31 = fdiv double %30, 2.000000e+00
%32 = call i32 @xlate(double 0.000000e+00, i32 0, double %31)
store i32 0, i32* %11
br label %33
33: ; preds = %51, %5
%34 = load i32, i32* %11
%35 = load i32, i32* %10
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %54
37: ; preds = %33
%38 = load double, double* %12
%39 = call i32 @xlate(double %38, i32 0, double 0.000000e+00)
%40 = call i32 @rotate(i32 90, i32 0, i32 0, i32 1)
%41 = load double, double* %7
%42 = fmul double %41, 1.100000e+00
%43 = load double, double* %9
%44 = load double, double* %8
%45 = call i32 @cube(double %42, double %43, double %44, i32 1)
%46 = call i32 (...) @endrotate()
%47 = call i32 (...) @endxlate()
%48 = load double, double* %13
%49 = load double, double* %12
%50 = fadd double %49, %48
store double %50, double* %12
br label %51
51: ; preds = %37
%52 = load i32, i32* %11
%53 = add nsw i32 %52, 1
store i32 %53, i32* %11
br label %33
54: ; preds = %33
%55 = call i32 (...) @endxlate()
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"/* n = %d */\0A\00"
define void @crenelation_array(double %0, double %1, double %2, double %3, i32 %4) {
%6 = fneg double %3
%7 = tail call double @llvm.fmuladd.f64(double %6, double 2.000000e+00, double %0)
%8 = sitofp i32 %4 to double
%9 = fdiv double %7, %8
%10 = tail call i32 @scadinline(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %4)
%11 = fmul double %2, 5.000000e-01
%12 = tail call i32 @xlate(double 0.000000e+00, i32 0, double %11)
%13 = icmp sgt i32 %4, 0
br i1 %13, label %14, label %32
14: ; preds = %5
%15 = fneg double %9
%16 = add nsw i32 %4, -1
%17 = sitofp i32 %16 to double
%18 = fmul double %15, %17
%19 = fmul double %18, 5.000000e-01
%20 = fmul double %1, 1.100000e+00
br label %21
21: ; preds = %14, %21
%22 = phi i32 [ 0, %14 ], [ %30, %21 ]
%23 = phi double [ %19, %14 ], [ %29, %21 ]
%24 = tail call i32 @xlate(double %23, i32 0, double 0.000000e+00)
%25 = tail call i32 @rotate(i32 90, i32 0, i32 0, i32 1)
%26 = tail call i32 @cube(double %20, double %3, double %2, i32 1)
%27 = tail call i32 (...) @endrotate()
%28 = tail call i32 (...) @endxlate()
%29 = fadd double %9, %23
%30 = add nuw nsw i32 %22, 1
%31 = icmp eq i32 %30, %4
br i1 %31, label %32, label %21
32: ; preds = %21, %5
%33 = tail call i32 (...) @endxlate()
ret void
}