#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*/ putchar(int /*<<< orphan*/);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ toupper(char);
int main(int argc, const char *argv[]) {
  int i = 0;
  char name[256];
  printf("===== Exercise 13 =====\n");
  printf("Capital Letters!\n");
  printf("Enter name for returning capital letters: \n");
  scanf("%s", name);
  while (name[i]) {
    putchar(toupper(name[i]));
    i++;
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe99(%rip),%rdi
call   1050 <printf@plt>
lea    0xea6(%rip),%rdi
call   1050 <printf@plt>
lea    0xeac(%rip),%rdi
call   1050 <printf@plt>
lea    -0x120(%rbp),%rsi
lea    0xec5(%rip),%rdi
call   1060 <scanf@plt>
movslq -0x14(%rbp),%rax
cmpb   $0x0,-0x120(%rbp,%rax,1)
je     11cf <main+0x8f>
movslq -0x14(%rbp),%rax
movsbl -0x120(%rbp,%rax,1),%edi
ff
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1197 <main+0x57>
lea    0xe7f(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x100,%rsp
lea    0xeb4(%rip),%rdi
call   1050 <puts@plt>
lea    0xec0(%rip),%rdi
call   1050 <puts@plt>
lea    0xec5(%rip),%rdi
call   1050 <puts@plt>
lea    0xe8d(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%al
test   %al,%al
je     11aa <main+0x6a>
lea    0x1(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1190 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"===== Exercise 13 =====\0A\00"
@.str.1 = [18 x i8] c"Capital Letters!\0A\00"
@.str.2 = [44 x i8] c"Enter name for returning capital letters: \0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %19, %2
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %13
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = call i32 @toupper(i8 signext %23)
%25 = call i32 @putchar(i32 %24)
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %13
28: ; preds = %13
%29 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [3 x i8] c"%s\00"
@str = [24 x i8] c"===== Exercise 13 =====\00"
@str.5 = [17 x i8] c"Capital Letters!\00"
@str.6 = [43 x i8] c"Enter name for returning capital letters: \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.5, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.6, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%9 = load i8, i8* %4
%10 = icmp eq i8 %9, 0
br i1 %10, label %20, label %11
11: ; preds = %2, %11
%12 = phi i64 [ %16, %11 ], [ 0, %2 ]
%13 = phi i8 [ %18, %11 ], [ %9, %2 ]
%14 = call i32 @toupper(i8 signext %13)
%15 = call i32 @putchar(i32 %14)
%16 = add nuw i64 %12, 1
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %11
20: ; preds = %11, %2
%21 = call i32 @putchar(i32 10)
ret i32 0
}