#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*/ printf(char *, int);
int /*<<< orphan*/ putchar(char);
draw(int n) {
  int i, j;
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= i; ++j)
      printf("%d", i);
    putchar('\n');
  }
  for (i = n - 1; i >= 1; --i) {
    for (j = 1; j <= i; ++j)
      printf("%d", i);
    putchar('\n');
  }
}


x86 assembly (clang, -O0):
<draw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1186 <draw+0x66>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     116e <draw+0x4e>
mov    -0xc(%rbp),%esi
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1145 <draw+0x25>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1132 <draw+0x12>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jl     11e1 <draw+0xc1>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11c9 <draw+0xa9>
mov    -0xc(%rbp),%esi
lea    0xe4a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a0 <draw+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    118f <draw+0x6f>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11d5 <draw+0xb5>
mov    %edi,%r14d
lea    0x1(%r14),%r15d
mov    $0x1,%ebx
mov    $0x2,%r12d
lea    0xeb4(%rip),%r13
nopl   0x0(%rax)
mov    %ebx,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    1160 <draw+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
lea    0x1(%r12),%eax
cmp    %r15d,%r12d
mov    %eax,%r12d
jne    1150 <draw+0x30>
cmp    $0x2,%r14d
jl     11d5 <draw+0xb5>
lea    0xe6a(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
lea    -0x1(%r14),%ebp
mov    $0x1,%ebx
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    %ebx,%r14d
jne    11b0 <draw+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    $0x2,%r14d
mov    %ebp,%r14d
jg     11a0 <draw+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @draw(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 1, i32* %4
br label %6
6: ; preds = %23, %1
%7 = load i32, i32* %4
%8 = load i32, i32* %3
%9 = icmp sle i32 %7, %8
br i1 %9, label %10, label %26
10: ; preds = %6
store i32 1, i32* %5
br label %11
11: ; preds = %18, %10
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %21
15: ; preds = %11
%16 = load i32, i32* %4
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %15
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %11
21: ; preds = %11
%22 = call i32 @putchar(i8 signext 10)
br label %23
23: ; preds = %21
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %6
26: ; preds = %6
%27 = load i32, i32* %3
%28 = sub nsw i32 %27, 1
store i32 %28, i32* %4
br label %29
29: ; preds = %45, %26
%30 = load i32, i32* %4
%31 = icmp sge i32 %30, 1
br i1 %31, label %32, label %48
32: ; preds = %29
store i32 1, i32* %5
br label %33
33: ; preds = %40, %32
%34 = load i32, i32* %5
%35 = load i32, i32* %4
%36 = icmp sle i32 %34, %35
br i1 %36, label %37, label %43
37: ; preds = %33
%38 = load i32, i32* %4
%39 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %37
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %33
43: ; preds = %33
%44 = call i32 @putchar(i8 signext 10)
br label %45
45: ; preds = %43
%46 = load i32, i32* %4
%47 = add nsw i32 %46, -1
store i32 %47, i32* %4
br label %29
48: ; preds = %29
%49 = load i32, i32* %2
ret i32 %49
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @draw(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %31, label %3
3: ; preds = %1
%4 = add i32 %0, 1
br label %5
5: ; preds = %3, %15
%6 = phi i32 [ 2, %3 ], [ %18, %15 ]
%7 = phi i32 [ 1, %3 ], [ %17, %15 ]
br label %10
8: ; preds = %15
%9 = icmp sgt i32 %0, 1
br i1 %9, label %20, label %31
10: ; preds = %5, %10
%11 = phi i32 [ 1, %5 ], [ %13, %10 ]
%12 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %7)
%13 = add nuw i32 %11, 1
%14 = icmp eq i32 %13, %6
br i1 %14, label %15, label %10
15: ; preds = %10
%16 = tail call i32 @putchar(i8 signext 10)
%17 = add nuw nsw i32 %7, 1
%18 = add nuw i32 %6, 1
%19 = icmp eq i32 %6, %4
br i1 %19, label %8, label %5
20: ; preds = %8, %28
%21 = phi i32 [ %22, %28 ], [ %0, %8 ]
%22 = add nsw i32 %21, -1
br label %23
23: ; preds = %20, %23
%24 = phi i32 [ %26, %23 ], [ 1, %20 ]
%25 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %22)
%26 = add nuw nsw i32 %24, 1
%27 = icmp eq i32 %26, %21
br i1 %27, label %28, label %23
28: ; preds = %23
%29 = tail call i32 @putchar(i8 signext 10)
%30 = icmp sgt i32 %21, 2
br i1 %30, label %20, label %31
31: ; preds = %28, %1, %8
ret i32 undef
}