#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 getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(int /*<<< orphan*/);
int /*<<< orphan*/ toupper(char);
int main() {
  char str[10];
  int ch, n = 0;
  printf("\n Enter a letter or 1 to exit -->\n");
  while ((ch = getchar()) && n < 1 && ch >= 'a' && ch <= 'z' ||
         (ch = getchar()) && n < 1 && ch >= 'A' && ch <= 'Z') {
    str[n] = ch;
    ++n;
    for (int i = 0; i < n; ++i)
      putchar(toupper(str[i]));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xea3(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     1198 <main+0x58>
cmpl   $0x1,-0x18(%rbp)
jge    1198 <main+0x58>
cmpl   $0x61,-0x14(%rbp)
jl     1198 <main+0x58>
mov    $0x1,%al
cmpl   $0x7a,-0x14(%rbp)
mov    %al,-0x1d(%rbp)
jle    11e0 <main+0xa0>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1e(%rbp)
je     11da <main+0x9a>
xor    %eax,%eax
cmpl   $0x1,-0x18(%rbp)
mov    %al,-0x1e(%rbp)
jge    11da <main+0x9a>
xor    %eax,%eax
cmpl   $0x41,-0x14(%rbp)
mov    %al,-0x1e(%rbp)
jl     11da <main+0x9a>
cmpl   $0x5a,-0x14(%rbp)
setle  %al
mov    %al,-0x1e(%rbp)
mov    -0x1e(%rbp),%al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11f0 <main+0xb0>
jmp    1241 <main+0x101>
mov    -0x14(%rbp),%eax
mov    %al,%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0xe(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    123c <main+0xfc>
movslq -0x1c(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    120d <main+0xcd>
jmp    1162 <main+0x22>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb0(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%r15d
xor    %r14d,%r14d
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0x7a,%eax
jg     1176 <main+0x36>
cmp    $0x61,%eax
jl     1176 <main+0x36>
test   %r14,%r14
je     118c <main+0x4c>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0x5a,%eax
jg     11c4 <main+0x84>
cmp    $0x41,%eax
jl     11c4 <main+0x84>
test   %r14,%r14
jne    11c4 <main+0x84>
mov    %al,0x6(%rsp,%r14,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl 0x6(%rsp,%rbx,1),%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11a0 <main+0x60>
add    $0x1,%r14
add    $0x1,%r15
jmp    1160 <main+0x20>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [35 x i8] c"\0A Enter a letter or 1 to exit -->\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%6 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %57, %0
%8 = call i32 (...) @getchar()
store i32 %8, i32* %3
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 1
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = load i32, i32* %3
%15 = icmp sge i32 %14, 97
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* %3
%18 = icmp sle i32 %17, 122
br i1 %18, label %33, label %19
19: ; preds = %16, %13, %10, %7
%20 = call i32 (...) @getchar()
store i32 %20, i32* %3
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %31
22: ; preds = %19
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 1
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = load i32, i32* %3
%27 = icmp sge i32 %26, 65
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32, i32* %3
%30 = icmp sle i32 %29, 90
br label %31
31: ; preds = %28, %25, %22, %19
%32 = phi i1 [ false, %25 ], [ false, %22 ], [ false, %19 ], [ %30, %28 ]
br label %33
33: ; preds = %31, %16
%34 = phi i1 [ true, %16 ], [ %32, %31 ]
br i1 %34, label %35, label %58
35: ; preds = %33
%36 = load i32, i32* %3
%37 = trunc i32 %36 to i8
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %39
store i8 %37, i8* %40
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
store i32 0, i32* %5
br label %43
43: ; preds = %54, %35
%44 = load i32, i32* %5
%45 = load i32, i32* %4
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %57
47: ; preds = %43
%48 = load i32, i32* %5
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = call i32 @toupper(i8 signext %51)
%53 = call i32 @putchar(i32 %52)
br label %54
54: ; preds = %47
%55 = load i32, i32* %5
%56 = add nsw i32 %55, 1
store i32 %56, i32* %5
br label %43
57: ; preds = %43
br label %7
58: ; preds = %33
ret i32 0
}

LLVM IR (-O2):
@str = [34 x i8] c"\0A Enter a letter or 1 to exit -->\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %7
4: ; preds = %26
%5 = add nuw i64 %8, 1
%6 = add nuw i64 %9, 1
br label %7
7: ; preds = %4, %0
%8 = phi i64 [ %5, %4 ], [ 0, %0 ]
%9 = phi i64 [ %6, %4 ], [ 1, %0 ]
%10 = tail call i32 (...) @getchar()
%11 = icmp eq i64 %8, 0
%12 = icmp sgt i32 %10, 96
%13 = select i1 %12, i1 %11, i1 false
%14 = icmp slt i32 %10, 123
%15 = and i1 %14, %13
br i1 %15, label %22, label %16
16: ; preds = %7
%17 = tail call i32 (...) @getchar()
%18 = icmp sgt i32 %17, 64
%19 = select i1 %18, i1 %11, i1 false
%20 = icmp slt i32 %17, 91
%21 = and i1 %20, %19
br i1 %21, label %22, label %34
22: ; preds = %7, %16
%23 = phi i32 [ %10, %7 ], [ %17, %16 ]
%24 = trunc i32 %23 to i8
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %8
store i8 %24, i8* %25
br label %26
26: ; preds = %22, %26
%27 = phi i64 [ 0, %22 ], [ %32, %26 ]
%28 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = tail call i32 @toupper(i8 signext %29)
%31 = tail call i32 @putchar(i32 %30)
%32 = add nuw nsw i64 %27, 1
%33 = icmp eq i64 %32, %9
br i1 %33, label %4, label %26
34: ; preds = %16
ret i32 0
}