#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) {
  printf("Pls input a latter: ");
  char ch;
  scanf("%c", &ch);
  if ((ch < 'A') || (ch > 'Z')) {
    printf("we need a capital latter.\n");
    return 1;
  }
  char line;
  line = ch - 'A' + 1;
  int i, j;
  for (i = 1; i <= line; i++) {
    for (j = 0; j < line - i; j++) {
      printf(" ");
    }
    for (j = 0; j < i; j++) {
      printf("%c", 'A' + j);
    }
    for (j -= 2; j >= 0; j--) {
      printf("%c", 'A' + j);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     1167 <main+0x47>
movsbl -0x5(%rbp),%eax
cmp    $0x5a,%eax
jle    1181 <main+0x61>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1266 <main+0x146>
movsbl -0x5(%rbp),%eax
sub    $0x41,%eax
add    $0x1,%eax
mov    %al,-0x6(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
movsbl -0x6(%rbp),%ecx
cmp    %ecx,%eax
jg     125f <main+0x13f>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
movsbl -0x6(%rbp),%ecx
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    11d9 <main+0xb9>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11ab <main+0x8b>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120e <main+0xee>
mov    -0x10(%rbp),%esi
add    $0x41,%esi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11e0 <main+0xc0>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     1243 <main+0x123>
mov    -0x10(%rbp),%esi
add    $0x41,%esi
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1217 <main+0xf7>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1195 <main+0x75>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rdi
xor    %r13d,%r13d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x7(%rsp),%al
lea    -0x5b(%rax),%ecx
cmp    $0xe5,%cl
ja     118f <main+0x4f>
lea    0xe98(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
jmp    1227 <main+0xe7>
add    $0xc0,%al
movzbl %al,%r14d
mov    $0x1,%r15d
mov    %r14d,%r12d
jmp    11ba <main+0x7a>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r15),%eax
add    $0x1,%r13d
cmp    %r14d,%r15d
mov    %eax,%r15d
je     1225 <main+0xe5>
cmp    %r14d,%r15d
jae    11e2 <main+0xa2>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    %ebx,%r12d
jne    11d0 <main+0x90>
add    $0xffffffff,%r12d
mov    $0xffffffff,%ebx
mov    $0x1,%eax
mov    %eax,%ebp
lea    0x42(%rbx),%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
lea    0x1(%rbp),%eax
cmp    %ebx,%r13d
jne    11f0 <main+0xb0>
test   %ebx,%ebx
je     11a0 <main+0x60>
nopl   0x0(%rax)
lea    0x3f(%rbp),%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
jg     1210 <main+0xd0>
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Pls input a latter: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [27 x i8] c"we need a capital latter.\0A\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp slt i32 %9, 65
br i1 %10, label %15, label %11
11: ; preds = %0
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
%14 = icmp sgt i32 %13, 90
br i1 %14, label %15, label %17
15: ; preds = %11, %0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %72
17: ; preds = %11
%18 = load i8, i8* %2
%19 = sext i8 %18 to i32
%20 = sub nsw i32 %19, 65
%21 = add nsw i32 %20, 1
%22 = trunc i32 %21 to i8
store i8 %22, i8* %3
store i32 1, i32* %4
br label %23
23: ; preds = %68, %17
%24 = load i32, i32* %4
%25 = load i8, i8* %3
%26 = sext i8 %25 to i32
%27 = icmp sle i32 %24, %26
br i1 %27, label %28, label %71
28: ; preds = %23
store i32 0, i32* %5
br label %29
29: ; preds = %38, %28
%30 = load i32, i32* %5
%31 = load i8, i8* %3
%32 = sext i8 %31 to i32
%33 = load i32, i32* %4
%34 = sub nsw i32 %32, %33
%35 = icmp slt i32 %30, %34
br i1 %35, label %36, label %41
36: ; preds = %29
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %38
38: ; preds = %36
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %29
41: ; preds = %29
store i32 0, i32* %5
br label %42
42: ; preds = %50, %41
%43 = load i32, i32* %5
%44 = load i32, i32* %4
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %53
46: ; preds = %42
%47 = load i32, i32* %5
%48 = add nsw i32 65, %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %46
%51 = load i32, i32* %5
%52 = add nsw i32 %51, 1
store i32 %52, i32* %5
br label %42
53: ; preds = %42
%54 = load i32, i32* %5
%55 = sub nsw i32 %54, 2
store i32 %55, i32* %5
br label %56
56: ; preds = %63, %53
%57 = load i32, i32* %5
%58 = icmp sge i32 %57, 0
br i1 %58, label %59, label %66
59: ; preds = %56
%60 = load i32, i32* %5
%61 = add nsw i32 65, %60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %61)
br label %63
63: ; preds = %59
%64 = load i32, i32* %5
%65 = add nsw i32 %64, -1
store i32 %65, i32* %5
br label %56
66: ; preds = %56
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %68
68: ; preds = %66
%69 = load i32, i32* %4
%70 = add nsw i32 %69, 1
store i32 %70, i32* %4
br label %23
71: ; preds = %23
store i32 0, i32* %1
br label %72
72: ; preds = %71, %15
%73 = load i32, i32* %1
ret i32 %73
}

LLVM IR (-O2):
@.str = [21 x i8] c"Pls input a latter: \00"
@.str.1 = [3 x i8] c"%c\00"
@str = [26 x i8] c"we need a capital latter.\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 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 %9
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %41
9: ; preds = %0
%10 = add nsw i8 %4, -64
%11 = zext i8 %10 to i32
br label %12
12: ; preds = %9, %37
%13 = phi i32 [ %11, %9 ], [ %15, %37 ]
%14 = phi i32 [ 1, %9 ], [ %39, %37 ]
%15 = add nsw i32 %13, -1
%16 = icmp ult i32 %14, %11
br i1 %16, label %17, label %22
17: ; preds = %12, %17
%18 = phi i32 [ %20, %17 ], [ 0, %12 ]
%19 = call i32 @putchar(i32 32)
%20 = add nuw nsw i32 %18, 1
%21 = icmp eq i32 %20, %15
br i1 %21, label %22, label %17
22: ; preds = %17, %12
br label %23
23: ; preds = %22, %23
%24 = phi i32 [ %27, %23 ], [ 0, %22 ]
%25 = add nuw nsw i32 %24, 65
%26 = call i32 @putchar(i32 %25)
%27 = add nuw nsw i32 %24, 1
%28 = icmp eq i32 %27, %14
br i1 %28, label %29, label %23
29: ; preds = %23
%30 = icmp eq i32 %24, 0
br i1 %30, label %37, label %31
31: ; preds = %29, %31
%32 = phi i32 [ %33, %31 ], [ %24, %29 ]
%33 = add nsw i32 %32, -1
%34 = add nuw nsw i32 %32, 64
%35 = call i32 @putchar(i32 %34)
%36 = icmp sgt i32 %32, 1
br i1 %36, label %31, label %37
37: ; preds = %31, %29
%38 = call i32 @putchar(i32 10)
%39 = add nuw nsw i32 %14, 1
%40 = icmp eq i32 %14, %11
br i1 %40, label %41, label %12
41: ; preds = %37, %7
%42 = phi i32 [ 1, %7 ], [ 0, %37 ]
ret i32 %42
}