#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;
  printf("type a character: ");
  scanf("%c", &c);
  if (c >= 65 && c <= 90) {
    printf("%c <- to lowercase\n", c + 32);
  } else if (c >= 97 && c <= 122) {
    printf("%c <- to uppercase\n", c - 32);
  } else {
    printf("%c <- same\n", c);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     1181 <main+0x61>
movsbl -0x5(%rbp),%eax
cmp    $0x5a,%eax
jg     1181 <main+0x61>
movsbl -0x5(%rbp),%esi
add    $0x20,%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cc <main+0xac>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jl     11b5 <main+0x95>
movsbl -0x5(%rbp),%eax
cmp    $0x7a,%eax
jg     11b5 <main+0x95>
movsbl -0x5(%rbp),%esi
sub    $0x20,%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c7 <main+0xa7>
movsbl -0x5(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cc <main+0xac>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1040 <scanf@plt>
movsbl 0x7(%rsp),%esi
lea    -0x41(%rsi),%eax
cmp    $0x19,%al
ja     1158 <main+0x38>
add    $0x20,%esi
lea    0xec0(%rip),%rdi
jmp    1172 <main+0x52>
lea    -0x61(%rsi),%eax
cmp    $0x19,%al
ja     116b <main+0x4b>
add    $0xffffffe0,%esi
lea    0xec1(%rip),%rdi
jmp    1172 <main+0x52>
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"type a character: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [20 x i8] c"%c <- to lowercase\0A\00"
@.str.3 = [20 x i8] c"%c <- to uppercase\0A\00"
@.str.4 = [12 x i8] c"%c <- same\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = load i8, i8* %2
%6 = sext i8 %5 to i32
%7 = icmp sge i32 %6, 65
br i1 %7, label %8, label %17
8: ; preds = %0
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp sle i32 %10, 90
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = add nsw i32 %14, 32
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %35
17: ; preds = %8, %0
%18 = load i8, i8* %2
%19 = sext i8 %18 to i32
%20 = icmp sge i32 %19, 97
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load i8, i8* %2
%23 = sext i8 %22 to i32
%24 = icmp sle i32 %23, 122
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load i8, i8* %2
%27 = sext i8 %26 to i32
%28 = sub nsw i32 %27, 32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %28)
br label %34
30: ; preds = %21, %17
%31 = load i8, i8* %2
%32 = sext i8 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %30, %25
br label %35
35: ; preds = %34, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"type a character: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [20 x i8] c"%c <- to lowercase\0A\00"
@.str.3 = [20 x i8] c"%c <- to uppercase\0A\00"
@.str.4 = [12 x i8] c"%c <- same\0A\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%4 = load i8, i8* %1
%5 = sext i8 %4 to i32
%6 = add i8 %4, -65
%7 = icmp ult i8 %6, 26
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = add nsw i32 %5, 32
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %9)
br label %19
11: ; preds = %0
%12 = add i8 %4, -97
%13 = icmp ult i8 %12, 26
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = add nsw i32 %5, -32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %15)
br label %19
17: ; preds = %11
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %5)
br label %19
19: ; preds = %14, %17, %8
ret i32 0
}