#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 /*<<< orphan*/ putchar(char);
main(void) {
  char ch;
  ch = getchar();
  if (ch >= 'a' && ch <= 'z')
    ch -= 32;
  else if (ch >= 'A' && ch <= 'Z')
    ch += 32;
  putchar(ch);
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jl     1172 <main+0x42>
movsbl -0x5(%rbp),%eax
cmp    $0x7a,%eax
jg     1172 <main+0x42>
movsbl -0x5(%rbp),%eax
sub    $0x20,%eax
mov    %al,-0x5(%rbp)
jmp    119b <main+0x6b>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     1196 <main+0x66>
movsbl -0x5(%rbp),%eax
cmp    $0x5a,%eax
jg     1196 <main+0x66>
movsbl -0x5(%rbp),%eax
add    $0x20,%eax
mov    %al,-0x5(%rbp)
jmp    119b <main+0x6b>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
lea    -0x61(%rax),%ecx
cmp    $0x19,%cl
ja     1134 <main+0x14>
add    $0xe0,%al
jmp    1146 <main+0x26>
lea    -0x41(%rax),%ecx
lea    0x20(%rax),%edx
cmp    $0x1a,%cl
movzbl %al,%ecx
movzbl %dl,%eax
cmovae %ecx,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = add i8 %1, -97
%3 = icmp ult i8 %2, 26
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = add nsw i8 %1, -32
br label %11
6: ; preds = %0
%7 = add i8 %1, -65
%8 = icmp ult i8 %7, 26
%9 = add i8 %1, 32
%10 = select i1 %8, i8 %9, i8 %1
br label %11
11: ; preds = %6, %4
%12 = phi i8 [ %5, %4 ], [ %10, %6 ]
%13 = tail call i32 @putchar(i8 signext %12)
%14 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
ret i32 0
}