#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*/ ft_putchar(char);
int /*<<< orphan*/ put_row(int, int, int);
int /*<<< orphan*/ put_space(int, int);
void put_section(int i, int w_top, int w_base, int isbase) {
  int w;
  int doorsize;
  int j;
  w = w_top;
  if (isbase)
    doorsize = (i / 2) * 2 + 1;
  else
    doorsize = 0;
  j = 0;
  while (j < i + 3) {
    put_space(w, w_base);
    if (j < i + 3 - doorsize)
      put_row(w, 0, 0);
    else if (doorsize >= 5 && j == i + 2 - doorsize / 2)
      put_row(w, doorsize, 1);
    else
      put_row(w, doorsize, 0);
    ft_putchar('\\');
    ft_putchar('\n');
    w += 2;
    j++;
  }
}


x86 assembly (clang, -O0):
<put_section>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     116d <put_section+0x3d>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1174 <put_section+0x44>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    $0x3,%ecx
cmp    %ecx,%eax
jge    123e <put_section+0x10e>
mov    -0x14(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <put_space@plt>
mov    -0x1c(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    $0x3,%ecx
sub    -0x18(%rbp),%ecx
cmp    %ecx,%eax
jge    11bc <put_section+0x8c>
mov    -0x14(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1030 <put_row@plt>
jmp    1213 <put_section+0xe3>
cmpl   $0x5,-0x18(%rbp)
jl     1201 <put_section+0xd1>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%ecx
add    $0x2,%ecx
mov    -0x18(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x20(%rbp),%eax
sub    %edx,%ecx
cmp    %ecx,%eax
jne    1201 <put_section+0xd1>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x1,%edx
call   1030 <put_row@plt>
jmp    120e <put_section+0xde>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
call   1030 <put_row@plt>
jmp    1213 <put_section+0xe3>
mov    $0x5c,%edi
call   1040 <ft_putchar@plt>
mov    $0xa,%edi
call   1040 <ft_putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117b <put_section+0x4b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_section>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%ebp
test   %ecx,%ecx
je     1158 <put_section+0x28>
mov    %edi,%ebx
shr    $0x1f,%ebx
add    %edi,%ebx
or     $0x1,%ebx
cmp    $0xfffffffe,%edi
jge    1163 <put_section+0x33>
jmp    11f6 <put_section+0xc6>
xor    %ebx,%ebx
cmp    $0xfffffffe,%edi
jl     11f6 <put_section+0xc6>
mov    %rdi,%rax
mov    %rdi,%rcx
lea    0x3(%rax),%r12d
mov    %r12d,%r13d
sub    %ebx,%r13d
mov    %ebx,%eax
shr    %eax
sub    %eax,%ecx
add    $0x2,%ecx
mov    %rcx,(%rsp)
cmp    $0x2,%r12d
mov    $0x1,%eax
cmovl  %eax,%r12d
xor    %r14d,%r14d
jmp    11cb <put_section+0x9b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <put_row@plt>
mov    $0x5c,%edi
call   1040 <ft_putchar@plt>
mov    $0xa,%edi
call   1040 <ft_putchar@plt>
add    $0x2,%ebp
add    $0x1,%r14d
cmp    %r14d,%r12d
je     11f6 <put_section+0xc6>
mov    %ebp,%edi
mov    %r15d,%esi
call   1050 <put_space@plt>
cmp    %r13d,%r14d
jl     11a0 <put_section+0x70>
cmp    $0x5,%ebx
jl     11f0 <put_section+0xc0>
cmp    %r14d,(%rsp)
jne    11f0 <put_section+0xc0>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x1,%edx
jmp    11a6 <put_section+0x76>
mov    %ebp,%edi
mov    %ebx,%esi
jmp    11a4 <put_section+0x74>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @put_section(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = load i32, i32* %6
store i32 %12, i32* %9
%13 = load i32, i32* %8
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %4
%16 = load i32, i32* %5
%17 = sdiv i32 %16, 2
%18 = mul nsw i32 %17, 2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %10
br label %21
20: ; preds = %4
store i32 0, i32* %10
br label %21
21: ; preds = %20, %15
store i32 0, i32* %11
br label %22
22: ; preds = %60, %21
%23 = load i32, i32* %11
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 3
%26 = icmp slt i32 %23, %25
br i1 %26, label %27, label %67
27: ; preds = %22
%28 = load i32, i32* %9
%29 = load i32, i32* %7
%30 = call i32 @put_space(i32 %28, i32 %29)
%31 = load i32, i32* %11
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 3
%34 = load i32, i32* %10
%35 = sub nsw i32 %33, %34
%36 = icmp slt i32 %31, %35
br i1 %36, label %37, label %40
37: ; preds = %27
%38 = load i32, i32* %9
%39 = call i32 @put_row(i32 %38, i32 0, i32 0)
br label %60
40: ; preds = %27
%41 = load i32, i32* %10
%42 = icmp sge i32 %41, 5
br i1 %42, label %43, label %55
43: ; preds = %40
%44 = load i32, i32* %11
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 2
%47 = load i32, i32* %10
%48 = sdiv i32 %47, 2
%49 = sub nsw i32 %46, %48
%50 = icmp eq i32 %44, %49
br i1 %50, label %51, label %55
51: ; preds = %43
%52 = load i32, i32* %9
%53 = load i32, i32* %10
%54 = call i32 @put_row(i32 %52, i32 %53, i32 1)
br label %59
55: ; preds = %43, %40
%56 = load i32, i32* %9
%57 = load i32, i32* %10
%58 = call i32 @put_row(i32 %56, i32 %57, i32 0)
br label %59
59: ; preds = %55, %51
br label %60
60: ; preds = %59, %37
%61 = call i32 @ft_putchar(i8 signext 92)
%62 = call i32 @ft_putchar(i8 signext 10)
%63 = load i32, i32* %9
%64 = add nsw i32 %63, 2
store i32 %64, i32* %9
%65 = load i32, i32* %11
%66 = add nsw i32 %65, 1
store i32 %66, i32* %11
br label %22
67: ; preds = %22
ret void
}

LLVM IR (-O2):
define void @put_section(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br i1 %5, label %10, label %6
6: ; preds = %4
%7 = sdiv i32 %0, 2
%8 = shl nsw i32 %7, 1
%9 = or i32 %8, 1
br label %10
10: ; preds = %4, %6
%11 = phi i32 [ %9, %6 ], [ 0, %4 ]
%12 = add i32 %0, 3
%13 = icmp sgt i32 %0, -3
br i1 %13, label %14, label %41
14: ; preds = %10
%15 = sub nsw i32 %12, %11
%16 = icmp sgt i32 %11, 4
%17 = add nsw i32 %0, 2
%18 = lshr i32 %11, 1
%19 = sub nsw i32 %17, %18
%20 = call i32 @llvm.smax.i32(i32 %12, i32 1)
br label %21
21: ; preds = %14, %35
%22 = phi i32 [ 0, %14 ], [ %39, %35 ]
%23 = phi i32 [ %1, %14 ], [ %38, %35 ]
%24 = tail call i32 @put_space(i32 %23, i32 %2)
%25 = icmp slt i32 %22, %15
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = tail call i32 @put_row(i32 %23, i32 0, i32 0)
br label %35
28: ; preds = %21
%29 = icmp eq i32 %22, %19
%30 = select i1 %16, i1 %29, i1 false
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = tail call i32 @put_row(i32 %23, i32 %11, i32 1)
br label %35
33: ; preds = %28
%34 = tail call i32 @put_row(i32 %23, i32 %11, i32 0)
br label %35
35: ; preds = %31, %33, %26
%36 = tail call i32 @ft_putchar(i8 signext 92)
%37 = tail call i32 @ft_putchar(i8 signext 10)
%38 = add nsw i32 %23, 2
%39 = add nuw nsw i32 %22, 1
%40 = icmp eq i32 %39, %20
br i1 %40, label %41, label %21
41: ; preds = %35, %10
ret void
}