#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  char letter;
  int deep;
  int start;
  int end;
  int i, j;
  i = 0;
  printf("Please input letter <A-Z>:\n");
  scanf("%c", &letter);
  if (letter < 65 || letter > 90) {
    exit(EXIT_FAILURE);
  }
  deep = letter - 65;
  while (i <= deep) {
    for (j = 0; j <= i; j++) {
      printf("%c", 65 + j);
    }
    if (j > 1) {
      j -= 2;
      for (; j >= 0; j--) {
        printf("%c", 65 + j);
      }
    }
    printf("\n");
    i++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     117e <main+0x4e>
movsbl -0x5(%rbp),%eax
cmp    $0x5a,%eax
jle    118c <main+0x5c>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movsbl -0x5(%rbp),%eax
sub    $0x41,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1237 <main+0x107>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11d7 <main+0xa7>
mov    -0x1c(%rbp),%esi
add    $0x41,%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a9 <main+0x79>
cmpl   $0x1,-0x1c(%rbp)
jle    121b <main+0xeb>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     1216 <main+0xe6>
mov    -0x1c(%rbp),%esi
add    $0x41,%esi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ea <main+0xba>
jmp    121b <main+0xeb>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1196 <main+0x66>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeb0(%rip),%rdi
call   1040 <puts@plt>
lea    0xea1(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1050 <scanf@plt>
movzbl 0xf(%rsp),%r14d
lea    -0x5b(%r14),%eax
cmp    $0xe5,%al
jbe    1201 <main+0xc1>
add    $0xffffffc1,%r14d
mov    $0x1,%r15d
xor    %r12d,%r12d
jmp    11a7 <main+0x67>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15d
add    $0x1,%r12d
cmp    %r14d,%r15d
je     11f2 <main+0xb2>
mov    $0xffffffff,%ebx
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %eax,%ebp
lea    0x42(%rbx),%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
lea    0x1(%rbp),%eax
cmp    %ebx,%r12d
jne    11c0 <main+0x80>
test   %ebx,%ebx
je     1190 <main+0x50>
nopl   0x0(%rax)
lea    0x3f(%rbp),%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
jg     11e0 <main+0xa0>
jmp    1190 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"Please input letter <A-Z>:\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [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 i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = icmp slt i32 %11, 65
br i1 %12, label %17, label %13
13: ; preds = %0
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
%16 = icmp sgt i32 %15, 90
br i1 %16, label %17, label %20
17: ; preds = %13, %0
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %13
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = sub nsw i32 %22, 65
store i32 %23, i32* %3
br label %24
24: ; preds = %57, %20
%25 = load i32, i32* %6
%26 = load i32, i32* %3
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %61
28: ; preds = %24
store i32 0, i32* %7
br label %29
29: ; preds = %37, %28
%30 = load i32, i32* %7
%31 = load i32, i32* %6
%32 = icmp sle i32 %30, %31
br i1 %32, label %33, label %40
33: ; preds = %29
%34 = load i32, i32* %7
%35 = add nsw i32 65, %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %33
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %29
40: ; preds = %29
%41 = load i32, i32* %7
%42 = icmp sgt i32 %41, 1
br i1 %42, label %43, label %57
43: ; preds = %40
%44 = load i32, i32* %7
%45 = sub nsw i32 %44, 2
store i32 %45, i32* %7
br label %46
46: ; preds = %53, %43
%47 = load i32, i32* %7
%48 = icmp sge i32 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %46
%50 = load i32, i32* %7
%51 = add nsw i32 65, %50
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %49
%54 = load i32, i32* %7
%55 = add nsw i32 %54, -1
store i32 %55, i32* %7
br label %46
56: ; preds = %46
br label %57
57: ; preds = %56, %40
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%59 = load i32, i32* %6
%60 = add nsw i32 %59, 1
store i32 %60, i32* %6
br label %24
61: ; preds = %24
%62 = load i32, i32* %1
ret i32 %62
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%c\00"
@EXIT_FAILURE = global i32 0
@str = [27 x i8] c"Please input letter <A-Z>:\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%4 = load i8, i8* %1
%5 = add i8 %4, -91
%6 = icmp ult i8 %5, -26
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* @EXIT_FAILURE
%9 = call i32 @exit(i32 %8)
unreachable
10: ; preds = %0
%11 = zext i8 %4 to i32
%12 = add nsw i32 %11, -63
br label %13
13: ; preds = %10, %29
%14 = phi i32 [ 1, %10 ], [ %31, %29 ]
br label %15
15: ; preds = %13, %15
%16 = phi i32 [ 0, %13 ], [ %19, %15 ]
%17 = add nuw nsw i32 %16, 65
%18 = call i32 @putchar(i32 %17)
%19 = add nuw nsw i32 %16, 1
%20 = icmp eq i32 %19, %14
br i1 %20, label %21, label %15
21: ; preds = %15
%22 = icmp eq i32 %16, 0
br i1 %22, label %29, label %23
23: ; preds = %21, %23
%24 = phi i32 [ %25, %23 ], [ %16, %21 ]
%25 = add nsw i32 %24, -1
%26 = add nuw nsw i32 %24, 64
%27 = call i32 @putchar(i32 %26)
%28 = icmp sgt i32 %24, 1
br i1 %28, label %23, label %29
29: ; preds = %23, %21
%30 = call i32 @putchar(i32 10)
%31 = add nuw nsw i32 %14, 1
%32 = icmp eq i32 %31, %12
br i1 %32, label %33, label %13
33: ; preds = %29
ret i32 0
}