#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char ch;
  printf("Please input a char:\n");
  ch = getchar();
  if (ch >= 'A' && ch <= 'Z')
    ch += 32;
  else if (ch >= 'a' && ch <= 'z')
    ch -= 32;
  else
    ;
  printf("ch=%c\n", ch);
  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>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     1170 <main+0x50>
movsbl -0x5(%rbp),%eax
cmp    $0x5a,%eax
jg     1170 <main+0x50>
movsbl -0x5(%rbp),%eax
add    $0x20,%eax
mov    %al,-0x5(%rbp)
jmp    11a3 <main+0x83>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jl     1199 <main+0x79>
movsbl -0x5(%rbp),%eax
cmp    $0x7a,%eax
jg     1199 <main+0x79>
movsbl -0x5(%rbp),%eax
sub    $0x20,%eax
mov    %al,-0x5(%rbp)
jmp    119e <main+0x7e>
jmp    119e <main+0x7e>
jmp    11a3 <main+0x83>
movsbl -0x5(%rbp),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    -0x41(%rax),%ecx
cmp    $0x19,%cl
ja     1150 <main+0x20>
add    $0x20,%al
jmp    1162 <main+0x32>
lea    -0x61(%rax),%ecx
lea    -0x20(%rax),%edx
cmp    $0x1a,%cl
movzbl %al,%ecx
movzbl %dl,%eax
cmovae %ecx,%eax
movsbl %al,%esi
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Please input a char:\0A\00"
@.str.1 = [7 x i8] c"ch=%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = call signext i8 (...) @getchar()
store i8 %4, 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 = trunc i32 %15 to i8
store i8 %16, i8* %2
br label %32
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 = trunc i32 %28 to i8
store i8 %29, i8* %2
br label %31
30: ; preds = %21, %17
br label %31
31: ; preds = %30, %25
br label %32
32: ; preds = %31, %12
%33 = load i8, i8* %2
%34 = sext i8 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"ch=%c\0A\00"
@str = [21 x i8] c"Please input a char:\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%2 = tail call signext i8 (...) @getchar()
%3 = add i8 %2, -65
%4 = icmp ult i8 %3, 26
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = add nuw nsw i8 %2, 32
br label %12
7: ; preds = %0
%8 = add i8 %2, -97
%9 = icmp ult i8 %8, 26
%10 = add i8 %2, -32
%11 = select i1 %9, i8 %10, i8 %2
br label %12
12: ; preds = %7, %5
%13 = phi i8 [ %6, %5 ], [ %11, %7 ]
%14 = sext i8 %13 to i32
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %14)
ret i32 0
}