#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 EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getchar();
scalar_t__ islower(int);
scalar_t__ isupper(int);
int putchar(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int tolower(int);
int toupper(int);
int main(void) {
  int c;
  while ((c = getchar()) != EOF) {
    if (isupper(c))
      c = tolower(c);
    else if (islower(c))
      c = toupper(c);
    if (putchar(c) == EOF) {
      fprintf(stderr, "output error");
      exit(1);
    }
    if (c == '\n')
      fflush(stdout);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e38(%rip),%rcx
cmp    (%rcx),%eax
je     124f <main+0xbf>
mov    -0x8(%rbp),%edi
call   10a0 <isupper@plt>
cmp    $0x0,%rax
je     11da <main+0x4a>
mov    -0x8(%rbp),%edi
call   1080 <tolower@plt>
mov    %eax,-0x8(%rbp)
jmp    11fc <main+0x6c>
mov    -0x8(%rbp),%edi
call   1040 <islower@plt>
cmp    $0x0,%rax
je     11f7 <main+0x67>
mov    -0x8(%rbp),%edi
call   1050 <toupper@plt>
mov    %eax,-0x8(%rbp)
jmp    11fc <main+0x6c>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
mov    0x2ddd(%rip),%rcx
cmp    (%rcx),%eax
jne    1232 <main+0xa2>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
lea    0xddd(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpl   $0xa,-0x8(%rbp)
jne    124a <main+0xba>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
jmp    119f <main+0xf>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e45(%rip),%r14
cmp    (%r14),%eax
jne    11af <main+0x1f>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    %eax,%ebx
mov    0x2e18(%rip),%r15
jmp    11ce <main+0x3e>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebx
cmp    (%r14),%eax
je     11a8 <main+0x18>
mov    %ebx,%edi
call   10a0 <isupper@plt>
test   %rax,%rax
je     11f0 <main+0x60>
mov    %ebx,%edi
call   1080 <tolower@plt>
jmp    1203 <main+0x73>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
call   1040 <islower@plt>
test   %rax,%rax
je     1205 <main+0x75>
mov    %ebx,%edi
call   1050 <toupper@plt>
mov    %eax,%ebx
mov    %ebx,%edi
call   1030 <putchar@plt>
cmp    (%r14),%eax
je     1220 <main+0x90>
cmp    $0xa,%ebx
jne    11c0 <main+0x30>
mov    (%r15),%edi
call   1090 <fflush@plt>
jmp    11c0 <main+0x30>
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
lea    0xdd0(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@EOF = global i32 0
@stderr = global i32 0
@.str = [13 x i8] c"output error\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %37, %0
%4 = call i32 (...) @getchar()
store i32 %4, i32* %2
%5 = load i32, i32* @EOF
%6 = icmp ne i32 %4, %5
br i1 %6, label %7, label %38
7: ; preds = %3
%8 = load i32, i32* %2
%9 = call i64 @isupper(i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i32, i32* %2
%13 = call i32 @tolower(i32 %12)
store i32 %13, i32* %2
br label %22
14: ; preds = %7
%15 = load i32, i32* %2
%16 = call i64 @islower(i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i32, i32* %2
%20 = call i32 @toupper(i32 %19)
store i32 %20, i32* %2
br label %21
21: ; preds = %18, %14
br label %22
22: ; preds = %21, %11
%23 = load i32, i32* %2
%24 = call i32 @putchar(i32 %23)
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %22
%32 = load i32, i32* %2
%33 = icmp eq i32 %32, 10
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32, i32* @stdout
%36 = call i32 @fflush(i32 %35)
br label %37
37: ; preds = %34, %31
br label %3
38: ; preds = %3
%39 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@EOF = global i32 0
@stderr = global i32 0
@.str = [13 x i8] c"output error\00"
@stdout = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %33, label %4
4: ; preds = %0, %29
%5 = phi i32 [ %30, %29 ], [ %1, %0 ]
%6 = tail call i64 @isupper(i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = tail call i32 @tolower(i32 %5)
br label %15
10: ; preds = %4
%11 = tail call i64 @islower(i32 %5)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @toupper(i32 %5)
br label %15
15: ; preds = %10, %13, %8
%16 = phi i32 [ %9, %8 ], [ %14, %13 ], [ %5, %10 ]
%17 = tail call i32 @putchar(i32 %16)
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %15
%25 = icmp eq i32 %16, 10
br i1 %25, label %26, label %29
26: ; preds = %24
%27 = load i32, i32* @stdout
%28 = tail call i32 @fflush(i32 %27)
br label %29
29: ; preds = %26, %24
%30 = tail call i32 (...) @getchar()
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %4
33: ; preds = %29, %0
%34 = tail call i32 @exit(i32 0)
unreachable
}