#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*/ scanf(char *, char *);
int main() {
  char c = ' ';
  int i = 0;
  int nums[30] = {0};
  int nums_index = 0;
  while (c != '$' && i < 30) {
    printf("Give character: ");
    scanf(" %c", &c);
    if (c >= 97 && c <= 122) {
      c -= 32;
      printf(" -> %c\n", c);
    } else if (c >= 65 && c <= 90) {
      c += 32;
      printf(" -> %c\n", c);
    } else if (c >= 48 && c <= 57) {
      nums[nums_index++] = c - 48;
    }
  }
  printf("Printing nums...\n");
  for (i = 0; i < nums_index; i++) {
    printf("%d", nums[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x20,-0x5(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x78,%edx
call   1040 <memset@plt>
movl   $0x0,-0x94(%rbp)
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x24,%ecx
mov    %al,-0x95(%rbp)
je     118c <main+0x5c>
cmpl   $0x1e,-0xc(%rbp)
setl   %al
mov    %al,-0x95(%rbp)
mov    -0x95(%rbp),%al
test   $0x1,%al
jne    119f <main+0x6f>
jmp    127d <main+0x14d>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5d(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jl     11f8 <main+0xc8>
movsbl -0x5(%rbp),%eax
cmp    $0x7a,%eax
jg     11f8 <main+0xc8>
movsbl -0x5(%rbp),%eax
sub    $0x20,%eax
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%esi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1278 <main+0x148>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     1233 <main+0x103>
movsbl -0x5(%rbp),%eax
cmp    $0x5a,%eax
jg     1233 <main+0x103>
movsbl -0x5(%rbp),%eax
add    $0x20,%eax
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%esi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1273 <main+0x143>
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jl     126e <main+0x13e>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
jg     126e <main+0x13e>
movsbl -0x5(%rbp),%ecx
sub    $0x30,%ecx
mov    -0x94(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x94(%rbp)
cltq
mov    %ecx,-0x90(%rbp,%rax,4)
jmp    1273 <main+0x143>
jmp    1278 <main+0x148>
jmp    116a <main+0x3a>
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x94(%rbp),%eax
jge    12c8 <main+0x198>
movslq -0xc(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%esi
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1292 <main+0x162>
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x90,%rsp
movb   $0x20,0xf(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x80(%rsp)
lea    0xe73(%rip),%r14
lea    0xe7d(%rip),%r15
lea    0xf(%rsp),%rbx
lea    0xe75(%rip),%r12
xor    %ebp,%ebp
jmp    11ca <main+0x8a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0xe0,%al
mov    %al,0xf(%rsp)
movzbl %al,%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpb   $0x24,0xf(%rsp)
je     1227 <main+0xe7>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
movsbl 0xf(%rsp),%eax
lea    -0x61(%rax),%ecx
cmp    $0x19,%cl
jbe    11b0 <main+0x70>
lea    -0x41(%rax),%ecx
cmp    $0x19,%cl
ja     1210 <main+0xd0>
movzbl %al,%esi
add    $0x20,%esi
mov    %sil,0xf(%rsp)
jmp    11b9 <main+0x79>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     11c3 <main+0x83>
add    $0xffffffd0,%eax
movslq %ebp,%rcx
add    $0x1,%ebp
mov    %eax,0x10(%rsp,%rcx,4)
jmp    11c3 <main+0x83>
lea    0xdf2(%rip),%rdi
call   1040 <puts@plt>
test   %ebp,%ebp
jle    1267 <main+0x127>
mov    %ebp,%ebp
lea    0xddd(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1250 <main+0x110>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Give character: \00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [8 x i8] c" -> %c\0A\00"
@.str.3 = [18 x i8] c"Printing nums...\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca [30 x i32]
%5 = alloca i32
store i32 0, i32* %1
store i8 32, i8* %2
store i32 0, i32* %3
%6 = bitcast [30 x i32]* %4 to i8*
store i32 0, i32* %5
br label %7
7: ; preds = %68, %0
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 36
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 30
br label %14
14: ; preds = %11, %7
%15 = phi i1 [ false, %7 ], [ %13, %11 ]
br i1 %15, label %16, label %69
16: ; preds = %14
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%19 = load i8, i8* %2
%20 = sext i8 %19 to i32
%21 = icmp sge i32 %20, 97
br i1 %21, label %22, label %34
22: ; preds = %16
%23 = load i8, i8* %2
%24 = sext i8 %23 to i32
%25 = icmp sle i32 %24, 122
br i1 %25, label %26, label %34
26: ; preds = %22
%27 = load i8, i8* %2
%28 = sext i8 %27 to i32
%29 = sub nsw i32 %28, 32
%30 = trunc i32 %29 to i8
store i8 %30, i8* %2
%31 = load i8, i8* %2
%32 = sext i8 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %32)
br label %68
34: ; preds = %22, %16
%35 = load i8, i8* %2
%36 = sext i8 %35 to i32
%37 = icmp sge i32 %36, 65
br i1 %37, label %38, label %50
38: ; preds = %34
%39 = load i8, i8* %2
%40 = sext i8 %39 to i32
%41 = icmp sle i32 %40, 90
br i1 %41, label %42, label %50
42: ; preds = %38
%43 = load i8, i8* %2
%44 = sext i8 %43 to i32
%45 = add nsw i32 %44, 32
%46 = trunc i32 %45 to i8
store i8 %46, i8* %2
%47 = load i8, i8* %2
%48 = sext i8 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %48)
br label %67
50: ; preds = %38, %34
%51 = load i8, i8* %2
%52 = sext i8 %51 to i32
%53 = icmp sge i32 %52, 48
br i1 %53, label %54, label %66
54: ; preds = %50
%55 = load i8, i8* %2
%56 = sext i8 %55 to i32
%57 = icmp sle i32 %56, 57
br i1 %57, label %58, label %66
58: ; preds = %54
%59 = load i8, i8* %2
%60 = sext i8 %59 to i32
%61 = sub nsw i32 %60, 48
%62 = load i32, i32* %5
%63 = add nsw i32 %62, 1
store i32 %63, i32* %5
%64 = sext i32 %62 to i64
%65 = getelementptr inbounds [30 x i32], [30 x i32]* %4, i64 0, i64 %64
store i32 %61, i32* %65
br label %66
66: ; preds = %58, %54, %50
br label %67
67: ; preds = %66, %42
br label %68
68: ; preds = %67, %26
br label %7
69: ; preds = %14
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %71
71: ; preds = %81, %69
%72 = load i32, i32* %3
%73 = load i32, i32* %5
%74 = icmp slt i32 %72, %73
br i1 %74, label %75, label %84
75: ; preds = %71
%76 = load i32, i32* %3
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [30 x i32], [30 x i32]* %4, i64 0, i64 %77
%79 = load i32, i32* %78
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %79)
br label %81
81: ; preds = %75
%82 = load i32, i32* %3
%83 = add nsw i32 %82, 1
store i32 %83, i32* %3
br label %71
84: ; preds = %71
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%86 = load i32, i32* %1
ret i32 %86
}

LLVM IR (-O2):
@.str = [17 x i8] c"Give character: \00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [8 x i8] c" -> %c\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@str = [17 x i8] c"Printing nums...\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca [30 x i32]
store i8 32, i8* %1
%3 = bitcast [30 x i32]* %2 to i8*
br label %4
4: ; preds = %0, %31
%5 = phi i32 [ 0, %0 ], [ %32, %31 ]
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%8 = load i8, i8* %1
%9 = sext i8 %8 to i32
%10 = add i8 %8, -97
%11 = icmp ult i8 %10, 26
br i1 %11, label %12, label %16
12: ; preds = %4
%13 = add nsw i8 %8, -32
store i8 %13, i8* %1
%14 = zext i8 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %14)
br label %31
16: ; preds = %4
%17 = add i8 %8, -65
%18 = icmp ult i8 %17, 26
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = add nuw nsw i8 %8, 32
store i8 %20, i8* %1
%21 = zext i8 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %31
23: ; preds = %16
%24 = add i8 %8, -48
%25 = icmp ult i8 %24, 10
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = add nsw i32 %9, -48
%28 = add nsw i32 %5, 1
%29 = sext i32 %5 to i64
%30 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %29
store i32 %27, i32* %30
br label %31
31: ; preds = %19, %26, %23, %12
%32 = phi i32 [ %5, %12 ], [ %5, %19 ], [ %28, %26 ], [ %5, %23 ]
%33 = load i8, i8* %1
%34 = icmp eq i8 %33, 36
br i1 %34, label %35, label %4
35: ; preds = %31
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%37 = icmp sgt i32 %32, 0
br i1 %37, label %38, label %47
38: ; preds = %35
%39 = zext i32 %32 to i64
br label %40
40: ; preds = %38, %40
%41 = phi i64 [ 0, %38 ], [ %45, %40 ]
%42 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %43)
%45 = add nuw nsw i64 %41, 1
%46 = icmp eq i64 %45, %39
br i1 %46, label %47, label %40
47: ; preds = %40, %35
%48 = call i32 @putchar(i32 10)
ret i32 0
}