#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 get_bottom_width(int);
int /*<<< orphan*/ put_section(int, int, int, int);
void sastantua(int size) {
  int i;
  int w_top;
  int w_base;
  if (size < 1)
    return;
  i = 0;
  w_top = 1;
  w_base = get_bottom_width(size - 1);
  while (i < size) {
    if (i == size - 1)
      put_section(i, w_top, w_base, 1);
    else
      put_section(i, w_top, w_base, 0);
    i++;
    w_top = w_top + (i + 1) * 2 + 2 * ((i + 1) / 2 + 2);
  }
}


x86 assembly (clang, -O0):
<sastantua>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jge    113a <sastantua+0x1a>
jmp    11d8 <sastantua+0xb8>
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
call   1030 <get_bottom_width@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d8 <sastantua+0xb8>
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    118b <sastantua+0x6b>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    $0x1,%ecx
call   1040 <put_section@plt>
jmp    119b <sastantua+0x7b>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
xor    %ecx,%ecx
call   1040 <put_section@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    $0x2,%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    1156 <sastantua+0x36>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sastantua>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11aa <sastantua+0x8a>
mov    %edi,%r12d
lea    -0x1(%r12),%edi
mov    %edi,0x4(%rsp)
call   1030 <get_bottom_width@plt>
mov    %eax,(%rsp)
neg    %r12d
mov    $0x1,%r13d
xor    %ebx,%ebx
mov    $0x8,%ebp
mov    $0x2,%r15d
jmp    1183 <sastantua+0x63>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r13d,%esi
mov    (%rsp),%edx
xor    %ecx,%ecx
call   1040 <put_section@plt>
add    $0x1,%ebx
add    %r14d,%r13d
add    $0x2,%ebp
add    $0x1,%r15d
mov    %r12d,%eax
add    %ebx,%eax
je     11aa <sastantua+0x8a>
lea    (%r12,%rbx,1),%eax
mov    %r15d,%r14d
and    $0x7ffffffe,%r14d
add    %ebp,%r14d
cmp    $0xffffffff,%eax
jne    1160 <sastantua+0x40>
mov    0x4(%rsp),%edi
mov    %r13d,%esi
mov    (%rsp),%edx
mov    $0x1,%ecx
jmp    116a <sastantua+0x4a>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @sastantua(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %9
8: ; preds = %1
br label %46
9: ; preds = %1
store i32 0, i32* %3
store i32 1, i32* %4
%10 = load i32, i32* %2
%11 = sub nsw i32 %10, 1
%12 = call i32 @get_bottom_width(i32 %11)
store i32 %12, i32* %5
br label %13
13: ; preds = %32, %9
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %46
17: ; preds = %13
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = sub nsw i32 %19, 1
%21 = icmp eq i32 %18, %20
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = call i32 @put_section(i32 %23, i32 %24, i32 %25, i32 1)
br label %32
27: ; preds = %17
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = call i32 @put_section(i32 %28, i32 %29, i32 %30, i32 0)
br label %32
32: ; preds = %27, %22
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
%35 = load i32, i32* %4
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
%38 = mul nsw i32 %37, 2
%39 = add nsw i32 %35, %38
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
%42 = sdiv i32 %41, 2
%43 = add nsw i32 %42, 2
%44 = mul nsw i32 2, %43
%45 = add nsw i32 %39, %44
store i32 %45, i32* %4
br label %13
46: ; preds = %8, %13
ret void
}

LLVM IR (-O2):
define void @sastantua(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %23, label %3
3: ; preds = %1
%4 = add nsw i32 %0, -1
%5 = tail call i32 @get_bottom_width(i32 %4)
br label %6
6: ; preds = %3, %14
%7 = phi i32 [ %15, %14 ], [ 0, %3 ]
%8 = phi i32 [ %21, %14 ], [ 1, %3 ]
%9 = icmp eq i32 %7, %4
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @put_section(i32 %4, i32 %8, i32 %5, i32 1)
br label %14
12: ; preds = %6
%13 = tail call i32 @put_section(i32 %7, i32 %8, i32 %5, i32 0)
br label %14
14: ; preds = %12, %10
%15 = add nuw nsw i32 %7, 1
%16 = add nuw nsw i32 %7, 2
%17 = shl nuw nsw i32 %16, 1
%18 = and i32 %16, 2147483646
%19 = add i32 %8, 4
%20 = add i32 %19, %17
%21 = add i32 %20, %18
%22 = icmp eq i32 %15, %0
br i1 %22, label %23, label %6
23: ; preds = %14, %1
ret void
}