#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
void main() {
  char a[50];
  int i = 0;
  printf("Enter String:");
  gets(a);
  printf("\nUppercase:");
  while (a[i] != '\0') {
    a[0] = a[0] - 32;
    if (a[i] == 32)
      a[i + 1] = a[i + 1] - 32;
    printf("%c", a[i]);
    i++;
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x44(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1040 <gets@plt>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x44(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11c5 <main+0xa5>
movsbl -0x40(%rbp),%eax
sub    $0x20,%eax
mov    %al,-0x40(%rbp)
movslq -0x44(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x20,%eax
jne    11a0 <main+0x80>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x40(%rbp,%rax,1),%eax
sub    $0x20,%eax
mov    %al,%cl
mov    -0x44(%rbp),%eax
add    $0x1,%eax
cltq
mov    %cl,-0x40(%rbp,%rax,1)
movslq -0x44(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%esi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1154 <main+0x34>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rdi
call   1050 <gets@plt>
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%al
test   %al,%al
je     119b <main+0x6b>
lea    0x1(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xe0,%al
mov    %al,(%rsp)
movzbl -0x1(%rbx),%eax
cmp    $0x20,%al
jne    1184 <main+0x54>
addb   $0xe0,(%rbx)
movzbl -0x1(%rbx),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
cmpb   $0x0,(%rbx)
je     119b <main+0x6b>
movzbl (%rsp),%eax
add    $0x1,%rbx
jmp    1170 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Enter String:\00"
@.str.1 = [12 x i8] c"\0AUppercase:\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @main() {
%1 = alloca [50 x i8]
%2 = alloca i32
store i32 0, i32* %2
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%5 = call i32 @gets(i8* %4)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %40, %0
%8 = load i32, i32* %2
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %49
14: ; preds = %7
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = sub nsw i32 %17, 32
%19 = trunc i32 %18 to i8
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
store i8 %19, i8* %20
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 32
br i1 %26, label %27, label %40
27: ; preds = %14
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = sub nsw i32 %33, 32
%35 = trunc i32 %34 to i8
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %38
store i8 %35, i8* %39
br label %40
40: ; preds = %27, %14
%41 = load i32, i32* %2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %45)
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
store i32 %48, i32* %2
br label %7
49: ; preds = %7
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"Enter String:\00"
@.str.1 = [12 x i8] c"\0AUppercase:\00"
define void @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 0
br i1 %7, label %30, label %8
8: ; preds = %0, %28
%9 = phi i8 [ %29, %28 ], [ %6, %0 ]
%10 = phi i64 [ %15, %28 ], [ 0, %0 ]
%11 = phi i8* [ %25, %28 ], [ %2, %0 ]
%12 = add i8 %9, -32
store i8 %12, i8* %2
%13 = load i8, i8* %11
%14 = icmp eq i8 %13, 32
%15 = add nuw i64 %10, 1
br i1 %14, label %16, label %21
16: ; preds = %8
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %15
%18 = load i8, i8* %17
%19 = add i8 %18, -32
store i8 %19, i8* %17
%20 = load i8, i8* %11
br label %21
21: ; preds = %8, %16
%22 = phi i8 [ %20, %16 ], [ %13, %8 ]
%23 = sext i8 %22 to i32
%24 = call i32 @putchar(i32 %23)
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %15
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %21
%29 = load i8, i8* %2
br label %8
30: ; preds = %21, %0
%31 = call i32 @putchar(i32 10)
ret void
}