#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(void) {
  char cap;
  int line;
  int i, space, words;
  printf("Enter a capital alphabet (A~Z):");
  scanf("%c", &cap);
  line = cap - 'A' + 1;
  for (i = 1; i <= line; i++) {
    for (space = line - i + 1; space > 0; space--)
      printf(" ");
    for (words = 0; words < i; words++)
      printf("%c", 'A' + words);
    for (words--; words > 0; words--)
      printf("%c", 'A' + words - 1);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
sub    $0x41,%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1228 <main+0x108>
mov    -0xc(%rbp),%eax
sub    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    119f <main+0x7f>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1179 <main+0x59>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d4 <main+0xb4>
mov    -0x18(%rbp),%esi
add    $0x41,%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a6 <main+0x86>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    120c <main+0xec>
mov    -0x18(%rbp),%esi
add    $0x41,%esi
sub    $0x1,%esi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    11dd <main+0xbd>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1161 <main+0x41>
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    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed0(%rip),%rdi
lea    0x3(%rsp),%rsi
call   1050 <scanf@plt>
movzbl 0x3(%rsp),%eax
cmp    $0x41,%al
jge    1174 <main+0x44>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0xffffffc1,%eax
mov    $0x1,%r12d
mov    $0xffffffff,%ebp
mov    $0x40,%r13d
mov    %eax,%r15d
mov    %eax,0x4(%rsp)
jmp    11c2 <main+0x92>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12d
add    $0xffffffff,%r15d
add    $0xffffffff,%ebp
add    $0x1,%r13d
mov    0x4(%rsp),%eax
cmp    %eax,%r12d
je     1163 <main+0x33>
mov    %r15d,%ebx
cmp    %r12d,%eax
jle    11e2 <main+0xb2>
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     11d0 <main+0xa0>
mov    $0x41,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
add    $0x1,%ebx
add    %ebp,%eax
add    $0x1,%eax
cmp    $0x41,%eax
jne    11f0 <main+0xc0>
mov    %r13d,%r14d
cmp    $0x42,%ebx
je     11a0 <main+0x70>
xchg   %ax,%ax
mov    %r14d,%edi
call   1030 <putchar@plt>
lea    -0x1(%r14),%eax
add    $0xffffffc1,%r14d
cmp    $0x2,%r14d
mov    %eax,%r14d
jg     1210 <main+0xe0>
jmp    11a0 <main+0x70>

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

LLVM IR (-O2):
@.str = [32 x i8] c"Enter a capital alphabet (A~Z):\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 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 = icmp slt i8 %4, 65
br i1 %5, label %37, label %6
6: ; preds = %0
%7 = zext i8 %4 to i32
%8 = add nsw i32 %7, -63
br label %9
9: ; preds = %6, %33
%10 = phi i32 [ 1, %6 ], [ %35, %33 ]
%11 = sub nsw i32 %8, %10
%12 = icmp sgt i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %14, %9
br label %21
14: ; preds = %9, %14
%15 = phi i32 [ %17, %14 ], [ %11, %9 ]
%16 = call i32 @putchar(i32 32)
%17 = add nsw i32 %15, -1
%18 = icmp ugt i32 %15, 1
br i1 %18, label %14, label %13
19: ; preds = %21
%20 = icmp eq i32 %22, 0
br i1 %20, label %33, label %27
21: ; preds = %13, %21
%22 = phi i32 [ %25, %21 ], [ 0, %13 ]
%23 = add nuw nsw i32 %22, 65
%24 = call i32 @putchar(i32 %23)
%25 = add nuw nsw i32 %22, 1
%26 = icmp eq i32 %25, %10
br i1 %26, label %19, label %21
27: ; preds = %19, %27
%28 = phi i32 [ %29, %27 ], [ %10, %19 ]
%29 = add nsw i32 %28, -1
%30 = add nuw nsw i32 %28, 63
%31 = call i32 @putchar(i32 %30)
%32 = icmp sgt i32 %28, 2
br i1 %32, label %27, label %33
33: ; preds = %27, %19
%34 = call i32 @putchar(i32 10)
%35 = add nuw nsw i32 %10, 1
%36 = icmp eq i32 %35, %8
br i1 %36, label %37, label %9
37: ; preds = %33, %0
ret i32 0
}