#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 */
char getchar();
int mytoupper(char);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char c;
  printf("Input a string\n");
  while ((c = getchar()) != '\n') {
    if ('a' <= c && c <= 'z') {
      printf("%c", mytoupper(c));
    } else {
      printf("%c", c);
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     11b6 <main+0x86>
movsbl -0x5(%rbp),%ecx
mov    $0x61,%eax
cmp    %ecx,%eax
jg     119f <main+0x6f>
movsbl -0x5(%rbp),%eax
cmp    $0x7a,%eax
jg     119f <main+0x6f>
movsbl -0x5(%rbp),%edi
call   1050 <mytoupper@plt>
mov    %eax,%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b1 <main+0x81>
movsbl -0x5(%rbp),%esi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114d <main+0x1d>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
jmp    1155 <main+0x15>
nop
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     1174 <main+0x34>
lea    -0x61(%rax),%ecx
movsbl %al,%edi
cmp    $0x19,%cl
ja     1150 <main+0x10>
call   1060 <mytoupper@plt>
mov    %eax,%edi
jmp    1150 <main+0x10>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Input a string\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %24, %0
%5 = call signext i8 (...) @getchar()
store i8 %5, i8* %2
%6 = sext i8 %5 to i32
%7 = icmp ne i32 %6, 10
br i1 %7, label %8, label %25
8: ; preds = %4
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp sle i32 97, %10
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = icmp sle i32 %14, 122
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i8, i8* %2
%18 = call i32 @mytoupper(i8 signext %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %24
20: ; preds = %12, %8
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %20, %16
br label %4
25: ; preds = %4
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [15 x i8] c"Input a string\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%2 = tail call signext i8 (...) @getchar()
%3 = icmp eq i8 %2, 10
br i1 %3, label %17, label %4
4: ; preds = %0, %12
%5 = phi i8 [ %15, %12 ], [ %2, %0 ]
%6 = add i8 %5, -97
%7 = icmp ult i8 %6, 26
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @mytoupper(i8 signext %5)
br label %12
10: ; preds = %4
%11 = sext i8 %5 to i32
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ %11, %10 ], [ %9, %8 ]
%14 = tail call i32 @putchar(i32 %13)
%15 = tail call signext i8 (...) @getchar()
%16 = icmp eq i8 %15, 10
br i1 %16, label %17, label %4
17: ; preds = %12, %0
%18 = tail call i32 @putchar(i32 10)
ret i32 0
}