#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int tolower(char);
int toupper(char);
int main(void) {
  char s[100];
  size_t indice = 0;
  int temp;
  memset(s, 0, 100);
  puts("Inserire una riga");
  while (indice < 100 - 1 && (temp = getchar()) != '\n') {
    s[indice++] = temp;
  }
  indice = 0;
  puts("Con lettere Maiuscole: ");
  while (s[indice] != '\0') {
    printf("%c", toupper(s[indice]));
    indice++;
  }
  puts("");
  indice = 0;
  puts("Con le lettere minuscole: ");
  while (s[indice] != '\n') {
    printf("%c", tolower(s[indice]));
    indice++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1060 <memset@plt>
lea    0xe6f(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
cmpq   $0x63,-0x78(%rbp)
mov    %al,-0x7d(%rbp)
jae    11b9 <main+0x59>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %eax,-0x7c(%rbp)
cmp    $0xa,%eax
setne  %al
mov    %al,-0x7d(%rbp)
mov    -0x7d(%rbp),%al
test   $0x1,%al
jne    11c9 <main+0x69>
jmp    11e6 <main+0x86>
mov    -0x7c(%rbp),%eax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,-0x70(%rbp,%rax,1)
jmp    1196 <main+0x36>
movq   $0x0,-0x78(%rbp)
lea    0xe1d(%rip),%rdi
call   1040 <puts@plt>
mov    -0x78(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1239 <main+0xd9>
mov    -0x78(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%edi
call   1030 <toupper@plt>
mov    %eax,%esi
lea    0xe07(%rip),%rdi
call   1050 <printf@plt>
mov    -0x78(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x78(%rbp)
jmp    11fa <main+0x9a>
lea    0xde9(%rip),%rdi
call   1040 <puts@plt>
movq   $0x0,-0x78(%rbp)
lea    0xdd9(%rip),%rdi
call   1040 <puts@plt>
mov    -0x78(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     1298 <main+0x138>
mov    -0x78(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%edi
call   1080 <tolower@plt>
mov    %eax,%esi
lea    0xda8(%rip),%rdi
call   1050 <printf@plt>
mov    -0x78(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x78(%rbp)
jmp    1259 <main+0xf9>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1070 <memset@plt>
lea    0xe73(%rip),%rdi
call   1050 <puts@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1080 <getchar@plt>
cmp    $0xa,%eax
je     11b9 <main+0x49>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x63,%rbx
jne    11a0 <main+0x30>
lea    0xe52(%rip),%rdi
call   1050 <puts@plt>
mov    (%rsp),%al
test   %al,%al
je     11fd <main+0x8d>
lea    0x1(%rsp),%rbx
lea    0xe52(%rip),%r14
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1040 <toupper@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    11e0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe1f(%rip),%rdi
call   1050 <puts@plt>
mov    (%rsp),%al
cmp    $0xa,%al
je     124d <main+0xdd>
lea    0x1(%rsp),%rbx
lea    0xe04(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%edi
call   1090 <tolower@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
cmp    $0xa,%al
jne    1230 <main+0xc0>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Inserire una riga\00"
@.str.1 = [24 x i8] c"Con lettere Maiuscole: \00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [27 x i8] c"Con le lettere minuscole: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i64
%4 = alloca i32
store i32 0, i32* %1
store i64 0, i64* %3
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 100)
%7 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %16, %0
%9 = load i64, i64* %3
%10 = icmp ult i64 %9, 99
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = call i32 (...) @getchar()
store i32 %12, i32* %4
%13 = icmp ne i32 %12, 10
br label %14
14: ; preds = %11, %8
%15 = phi i1 [ false, %8 ], [ %13, %11 ]
br i1 %15, label %16, label %22
16: ; preds = %14
%17 = load i32, i32* %4
%18 = trunc i32 %17 to i8
%19 = load i64, i64* %3
%20 = add i64 %19, 1
store i64 %20, i64* %3
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %19
store i8 %18, i8* %21
br label %8
22: ; preds = %14
store i64 0, i64* %3
%23 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %30, %22
%25 = load i64, i64* %3
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %38
30: ; preds = %24
%31 = load i64, i64* %3
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = call i32 @toupper(i8 signext %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = load i64, i64* %3
%37 = add i64 %36, 1
store i64 %37, i64* %3
br label %24
38: ; preds = %24
%39 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
store i64 0, i64* %3
%40 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %41
41: ; preds = %47, %38
%42 = load i64, i64* %3
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 10
br i1 %46, label %47, label %55
47: ; preds = %41
%48 = load i64, i64* %3
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = call i32 @tolower(i8 signext %50)
%52 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %51)
%53 = load i64, i64* %3
%54 = add i64 %53, 1
store i64 %54, i64* %3
br label %41
55: ; preds = %41
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Inserire una riga\00"
@.str.1 = [24 x i8] c"Con lettere Maiuscole: \00"
@.str.2 = [3 x i8] c"%c\00"
@.str.4 = [27 x i8] c"Con le lettere minuscole: \00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 @memset(i8* %2, i32 0, i32 100)
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %0, %9
%6 = phi i64 [ 0, %0 ], [ %11, %9 ]
%7 = call i32 (...) @getchar()
%8 = icmp eq i32 %7, 10
br i1 %8, label %14, label %9
9: ; preds = %5
%10 = trunc i32 %7 to i8
%11 = add nuw nsw i64 %6, 1
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %6
store i8 %10, i8* %12
%13 = icmp eq i64 %11, 99
br i1 %13, label %14, label %5
14: ; preds = %9, %5
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%16 = load i8, i8* %2
%17 = icmp eq i8 %16, 0
br i1 %17, label %27, label %18
18: ; preds = %14, %18
%19 = phi i8 [ %25, %18 ], [ %16, %14 ]
%20 = phi i64 [ %23, %18 ], [ 0, %14 ]
%21 = call i32 @toupper(i8 signext %19)
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = add i64 %20, 1
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %18
27: ; preds = %18, %14
%28 = call i32 @putchar(i32 10)
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%30 = load i8, i8* %2
%31 = icmp eq i8 %30, 10
br i1 %31, label %41, label %32
32: ; preds = %27, %32
%33 = phi i8 [ %39, %32 ], [ %30, %27 ]
%34 = phi i64 [ %37, %32 ], [ 0, %27 ]
%35 = call i32 @tolower(i8 signext %33)
%36 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = add i64 %34, 1
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 10
br i1 %40, label %41, label %32
41: ; preds = %32, %27
ret i32 0
}