#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 /*<<< orphan*/ scanf(char *, char *);
int main() {
  char ch;
  int i, row, col;
  char a = 'A';
  scanf("%c", &ch);
  row = ch - 'A' + 1;
  for (i = 0; i < row; i++) {
    for (col = 0; col < row * 2 - 1; col++) {
      if (col < row)
        printf("%c", ch + col - row + 1);
      else
        printf("%c", ch - col + row - 1);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x41,-0x15(%rbp)
lea    0xec6(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
sub    $0x41,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11f4 <main+0xd4>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11d8 <main+0xb8>
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11aa <main+0x8a>
movsbl -0x5(%rbp),%esi
add    -0x14(%rbp),%esi
sub    -0x10(%rbp),%esi
add    $0x1,%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c5 <main+0xa5>
movsbl -0x5(%rbp),%esi
sub    -0x14(%rbp),%esi
add    -0x10(%rbp),%esi
sub    $0x1,%esi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ca <main+0xaa>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116a <main+0x4a>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1157 <main+0x37>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%rdi
lea    0x3(%rsp),%rsi
call   1040 <scanf@plt>
movsbl 0x3(%rsp),%eax
cmp    $0x41,%eax
jl     11b5 <main+0x95>
lea    -0x40(%rax),%r15d
lea    (%r15,%r15,1),%ecx
lea    -0x41(%rax),%edx
mov    %edx,0x4(%rsp)
cmp    $0x3,%ecx
mov    $0x2,%r13d
cmovge %ecx,%r13d
add    $0xffffffff,%r13d
mov    $0x41,%ebx
sub    %eax,%ebx
xor    %r12d,%r12d
mov    0x4(%rsp),%ebp
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
lea    (%rbx,%r14,1),%edi
cmp    %r15d,%r14d
movsbl 0x3(%rsp),%eax
cmovge %ebp,%edi
add    %eax,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
add    $0xffffffff,%ebp
cmp    %r14d,%r13d
jne    1180 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12d
cmp    %r15d,%r12d
jne    1170 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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