#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*/ print_char(char);
int box(int john) {
  int n;
  int tmpn;
  if (john == 1) {
    print_char('0');
    print_char('\n');
    return (0);
  } else if (john < 1) {
    return (0);
  };
  for (n = 0; n < 1;) {
    n = n + 1;
    print_char('0');
  }
  for (n = 0; n < john - 2; n = n + 1) {
    print_char('-');
  }
  print_char('0');
  print_char('\n');
  for (n = 0; n < john - 2; n = n + 1) {
    print_char('|');
    for (tmpn = 0; tmpn < john - 2; tmpn = tmpn + 1) {
      print_char(' ');
    }
    print_char('|');
    print_char('\n');
  }
  print_char('0');
  for (n = 0; n < john - 2; n = n + 1) {
    print_char('-');
  }
  print_char('0');
  print_char('\n');
  return (0);
}


x86 assembly (clang, -O0):
<box>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1145 <box+0x35>
mov    $0x30,%edi
call   1030 <print_char@plt>
mov    $0xa,%edi
call   1030 <print_char@plt>
movl   $0x0,-0x4(%rbp)
jmp    1296 <box+0x186>
cmpl   $0x1,-0x8(%rbp)
jge    115b <box+0x4b>
movl   $0x0,-0x4(%rbp)
jmp    1296 <box+0x186>
jmp    1160 <box+0x50>
movl   $0x0,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    1189 <box+0x79>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    $0x30,%edi
call   1030 <print_char@plt>
jmp    1167 <box+0x57>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    11b9 <box+0xa9>
mov    $0x2d,%edi
call   1030 <print_char@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1190 <box+0x80>
mov    $0x30,%edi
call   1030 <print_char@plt>
mov    $0xa,%edi
call   1030 <print_char@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    1241 <box+0x131>
mov    $0x7c,%edi
call   1030 <print_char@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    121f <box+0x10f>
mov    $0x20,%edi
call   1030 <print_char@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11f6 <box+0xe6>
mov    $0x7c,%edi
call   1030 <print_char@plt>
mov    $0xa,%edi
call   1030 <print_char@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d4 <box+0xc4>
mov    $0x30,%edi
call   1030 <print_char@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    127b <box+0x16b>
mov    $0x2d,%edi
call   1030 <print_char@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1252 <box+0x142>
mov    $0x30,%edi
call   1030 <print_char@plt>
mov    $0xa,%edi
call   1030 <print_char@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<box>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
je     1200 <box+0xf0>
jl     1214 <box+0x104>
mov    %edi,%r14d
mov    $0x30,%edi
call   1030 <print_char@plt>
cmp    $0x3,%r14d
jb     11e2 <box+0xd2>
lea    -0x2(%r14),%r15d
mov    %r15d,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2d,%edi
call   1030 <print_char@plt>
add    $0xffffffff,%ebx
jne    1150 <box+0x40>
mov    $0x30,%edi
call   1030 <print_char@plt>
mov    $0xa,%edi
call   1030 <print_char@plt>
cmp    $0x3,%r14d
jb     11f6 <box+0xe6>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x7c,%edi
call   1030 <print_char@plt>
mov    %r15d,%ebp
nopl   (%rax)
mov    $0x20,%edi
call   1030 <print_char@plt>
add    $0xffffffff,%ebp
jne    1190 <box+0x80>
mov    $0x7c,%edi
call   1030 <print_char@plt>
mov    $0xa,%edi
call   1030 <print_char@plt>
add    $0x1,%ebx
cmp    %r15d,%ebx
jne    1180 <box+0x70>
mov    $0x30,%edi
call   1030 <print_char@plt>
cmp    $0x3,%r14d
jb     1200 <box+0xf0>
nopl   0x0(%rax,%rax,1)
mov    $0x2d,%edi
call   1030 <print_char@plt>
add    $0xffffffff,%r15d
jne    11d0 <box+0xc0>
jmp    1200 <box+0xf0>
mov    $0x30,%edi
call   1030 <print_char@plt>
mov    $0xa,%edi
call   1030 <print_char@plt>
mov    $0x30,%edi
call   1030 <print_char@plt>
mov    $0x30,%edi
call   1030 <print_char@plt>
mov    $0xa,%edi
call   1030 <print_char@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @box(i32 %0) {
%2 = icmp eq i32 %0, 1
br i1 %2, label %42, label %3
3: ; preds = %1
%4 = icmp slt i32 %0, 1
br i1 %4, label %45, label %5
5: ; preds = %3
%6 = tail call i32 @print_char(i8 signext 48)
%7 = add nsw i32 %0, -2
%8 = icmp ugt i32 %0, 2
br i1 %8, label %9, label %17
9: ; preds = %5, %9
%10 = phi i32 [ %12, %9 ], [ 0, %5 ]
%11 = tail call i32 @print_char(i8 signext 45)
%12 = add nuw nsw i32 %10, 1
%13 = icmp eq i32 %12, %7
br i1 %13, label %14, label %9
14: ; preds = %9
%15 = tail call i32 @print_char(i8 signext 48)
%16 = tail call i32 @print_char(i8 signext 10)
br i1 %8, label %22, label %20
17: ; preds = %5
%18 = tail call i32 @print_char(i8 signext 48)
%19 = tail call i32 @print_char(i8 signext 10)
br label %20
20: ; preds = %17, %14
%21 = tail call i32 @print_char(i8 signext 48)
br label %42
22: ; preds = %14, %30
%23 = phi i32 [ %33, %30 ], [ 0, %14 ]
%24 = tail call i32 @print_char(i8 signext 124)
br label %25
25: ; preds = %22, %25
%26 = phi i32 [ %28, %25 ], [ 0, %22 ]
%27 = tail call i32 @print_char(i8 signext 32)
%28 = add nuw nsw i32 %26, 1
%29 = icmp eq i32 %28, %7
br i1 %29, label %30, label %25
30: ; preds = %25
%31 = tail call i32 @print_char(i8 signext 124)
%32 = tail call i32 @print_char(i8 signext 10)
%33 = add nuw nsw i32 %23, 1
%34 = icmp eq i32 %33, %7
br i1 %34, label %35, label %22
35: ; preds = %30
%36 = tail call i32 @print_char(i8 signext 48)
br i1 %8, label %37, label %42
37: ; preds = %35, %37
%38 = phi i32 [ %40, %37 ], [ 0, %35 ]
%39 = tail call i32 @print_char(i8 signext 45)
%40 = add nuw nsw i32 %38, 1
%41 = icmp eq i32 %40, %7
br i1 %41, label %42, label %37
42: ; preds = %37, %35, %20, %1
%43 = tail call i32 @print_char(i8 signext 48)
%44 = tail call i32 @print_char(i8 signext 10)
br label %45
45: ; preds = %42, %3
ret i32 0
}