#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 *);
int /*<<< orphan*/ puts(char *);
char tolower(char);
char toupper(char);
int main() {
  char nam[1000];
  printf("Enter your name\n");
  gets(nam);
  printf("Your name in Uppercase:\n");
  int n = 0;
  while (nam[n] != '\0') {
    nam[n] = toupper(nam[n]);
    n++;
  }
  puts(nam);
  printf("Your name in Lowercase:\n");
  n = 0;
  while (nam[n] != '\0') {
    nam[n] = tolower(nam[n]);
    n++;
  }
  puts(nam);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
call   1050 <printf@plt>
lea    -0x3f0(%rbp),%rdi
call   1060 <gets@plt>
lea    0xe90(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x3f4(%rbp)
movslq -0x3f4(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     11e0 <main+0x90>
movslq -0x3f4(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%edi
ff
call   1030 <toupper@plt>
mov    %al,%cl
movslq -0x3f4(%rbp),%rax
mov    %cl,-0x3f0(%rbp,%rax,1)
mov    -0x3f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f4(%rbp)
jmp    1190 <main+0x40>
lea    -0x3f0(%rbp),%rdi
call   1040 <puts@plt>
lea    0xe37(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x3f4(%rbp)
movslq -0x3f4(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1252 <main+0x102>
movslq -0x3f4(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%edi
ff
call   1070 <tolower@plt>
mov    %al,%cl
movslq -0x3f4(%rbp),%rax
mov    %cl,-0x3f0(%rbp,%rax,1)
mov    -0x3f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f4(%rbp)
jmp    1202 <main+0xb2>
lea    -0x3f0(%rbp),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x3f0,%rsp
lea    0xeb1(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rdi
call   1050 <gets@plt>
lea    0xead(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%al
test   %al,%al
je     1196 <main+0x56>
lea    0x1(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1180 <main+0x40>
mov    %rsp,%rdi
call   1040 <puts@plt>
lea    0xe83(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%al
test   %al,%al
je     11d6 <main+0x96>
lea    0x1(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%edi
call   1060 <tolower@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    11c0 <main+0x80>
mov    %rsp,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
ret

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

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