#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 */
typedef int caractere;

/* Variables and functions */
int EOF;
int getc(int /*<<< orphan*/);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(void) {
  int caractere, ultimaFoiMaiuscula = 0;
  while (caractere = getc(stdin), caractere != EOF) {
    if ((((caractere) >= 'A' && (caractere) <= 'Z') ||
         ((caractere) >= 'a' && (caractere) <= 'z'))) {
      if (ultimaFoiMaiuscula) {
        putc((((caractere) >= 'A' && (caractere) <= 'Z') ? (caractere) + 0x20
                                                         : (caractere)),
             stdout);
      } else {
        putc((((caractere) >= 'a' && (caractere) <= 'z') ? (caractere)-0x20
                                                         : (caractere)),
             stdout);
      }
      ultimaFoiMaiuscula = !ultimaFoiMaiuscula;
    } else {
      putc(caractere, stdout);
    }
    if (caractere == '\n') {
      ultimaFoiMaiuscula = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0x2eab(%rip),%rax
mov    (%rax),%edi
call   1040 <getc@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e8f(%rip),%rcx
cmp    (%rcx),%eax
je     123f <main+0x11f>
cmpl   $0x41,-0x8(%rbp)
jl     116d <main+0x4d>
cmpl   $0x5a,-0x8(%rbp)
jle    1181 <main+0x61>
cmpl   $0x61,-0x8(%rbp)
jl     1218 <main+0xf8>
cmpl   $0x7a,-0x8(%rbp)
jg     1218 <main+0xf8>
cmpl   $0x0,-0xc(%rbp)
je     11c9 <main+0xa9>
cmpl   $0x41,-0x8(%rbp)
jl     11ad <main+0x8d>
cmpl   $0x5a,-0x8(%rbp)
jg     11ad <main+0x8d>
mov    -0x8(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x10(%rbp)
jmp    11b3 <main+0x93>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
call   1030 <putc@plt>
jmp    1202 <main+0xe2>
cmpl   $0x61,-0x8(%rbp)
jl     11eb <main+0xcb>
cmpl   $0x7a,-0x8(%rbp)
jg     11eb <main+0xcb>
mov    -0x8(%rbp),%eax
sub    $0x20,%eax
mov    %eax,-0x14(%rbp)
jmp    11f1 <main+0xd1>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2dd5(%rip),%rax
mov    (%rax),%esi
call   1030 <putc@plt>
cmpl   $0x0,-0xc(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
jmp    1229 <main+0x109>
mov    -0x8(%rbp),%edi
mov    0x2dae(%rip),%rax
mov    (%rax),%esi
call   1030 <putc@plt>
cmpl   $0xa,-0x8(%rbp)
jne    123a <main+0x11a>
movl   $0x0,-0xc(%rbp)
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2eb6(%rip),%r14
mov    (%r14),%edi
call   1040 <getc@plt>
mov    0x2e9f(%rip),%r15
cmp    (%r15),%eax
jne    1157 <main+0x37>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
xor    %ebp,%ebp
mov    0x2e6e(%rip),%r12
jmp    1182 <main+0x62>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14),%edi
call   1040 <getc@plt>
mov    %eax,%ebx
mov    %r13d,%ebp
cmp    (%r15),%eax
je     1146 <main+0x26>
lea    -0x41(%rbx),%eax
lea    -0x61(%rbx),%ecx
cmp    $0x1a,%eax
jb     11a0 <main+0x80>
cmp    $0x19,%ecx
jbe    11a0 <main+0x80>
mov    (%r12),%esi
mov    %ebx,%edi
call   1030 <putc@plt>
jmp    11ea <main+0xca>
nop
xor    %edx,%edx
cmp    $0x1a,%ecx
setb   %dl
xor    %ecx,%ecx
cmp    $0x1a,%eax
setb   %cl
xor    %r13d,%r13d
xor    %edi,%edi
test   %ebp,%ebp
sete   %bpl
setne  %al
cmove  %edx,%ecx
test   %cl,%cl
jne    11d0 <main+0xb0>
xor    %edi,%edi
jmp    11d9 <main+0xb9>
nopl   0x0(%rax)
mov    %al,%dil
shl    $0x6,%edi
add    $0xffffffe0,%edi
add    %ebx,%edi
mov    (%r12),%esi
call   1030 <putc@plt>
mov    %bpl,%r13b
mov    %r13d,%ebp
xor    %r13d,%r13d
cmp    $0xa,%ebx
je     1170 <main+0x50>
mov    %ebp,%r13d
jmp    1170 <main+0x50>

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i32 0
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %68, %0
%5 = load i32, i32* @stdin
%6 = call i32 @getc(i32 %5)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %69
10: ; preds = %4
%11 = load i32, i32* %2
%12 = icmp sge i32 %11, 65
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* %2
%15 = icmp sle i32 %14, 90
br i1 %15, label %22, label %16
16: ; preds = %13, %10
%17 = load i32, i32* %2
%18 = icmp sge i32 %17, 97
br i1 %18, label %19, label %60
19: ; preds = %16
%20 = load i32, i32* %2
%21 = icmp sle i32 %20, 122
br i1 %21, label %22, label %60
22: ; preds = %19, %13
%23 = load i32, i32* %3
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %40
25: ; preds = %22
%26 = load i32, i32* %2
%27 = icmp sge i32 %26, 65
br i1 %27, label %28, label %34
28: ; preds = %25
%29 = load i32, i32* %2
%30 = icmp sle i32 %29, 90
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 32
br label %36
34: ; preds = %28, %25
%35 = load i32, i32* %2
br label %36
36: ; preds = %34, %31
%37 = phi i32 [ %33, %31 ], [ %35, %34 ]
%38 = load i32, i32* @stdout
%39 = call i32 @putc(i32 %37, i32 %38)
br label %55
40: ; preds = %22
%41 = load i32, i32* %2
%42 = icmp sge i32 %41, 97
br i1 %42, label %43, label %49
43: ; preds = %40
%44 = load i32, i32* %2
%45 = icmp sle i32 %44, 122
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i32, i32* %2
%48 = sub nsw i32 %47, 32
br label %51
49: ; preds = %43, %40
%50 = load i32, i32* %2
br label %51
51: ; preds = %49, %46
%52 = phi i32 [ %48, %46 ], [ %50, %49 ]
%53 = load i32, i32* @stdout
%54 = call i32 @putc(i32 %52, i32 %53)
br label %55
55: ; preds = %51, %36
%56 = load i32, i32* %3
%57 = icmp ne i32 %56, 0
%58 = xor i1 %57, true
%59 = zext i1 %58 to i32
store i32 %59, i32* %3
br label %64
60: ; preds = %19, %16
%61 = load i32, i32* %2
%62 = load i32, i32* @stdout
%63 = call i32 @putc(i32 %61, i32 %62)
br label %64
64: ; preds = %60, %55
%65 = load i32, i32* %2
%66 = icmp eq i32 %65, 10
br i1 %66, label %67, label %68
67: ; preds = %64
store i32 0, i32* %3
br label %68
68: ; preds = %67, %64
br label %4
69: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i32 0
@stdout = global i32 0
define i32 @main() {
%1 = load i32, i32* @stdin
%2 = tail call i32 @getc(i32 %1)
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %33, label %5
5: ; preds = %0, %25
%6 = phi i32 [ %30, %25 ], [ %2, %0 ]
%7 = phi i32 [ %28, %25 ], [ 0, %0 ]
%8 = add i32 %6, -65
%9 = icmp ult i32 %8, 26
%10 = add i32 %6, -97
%11 = icmp ult i32 %10, 26
%12 = or i1 %9, %11
br i1 %12, label %13, label %22
13: ; preds = %5
%14 = icmp eq i32 %7, 0
%15 = select i1 %14, i32 -32, i32 32
%16 = select i1 %14, i1 %11, i1 %9
%17 = select i1 %16, i32 %15, i32 0
%18 = add nsw i32 %6, %17
%19 = load i32, i32* @stdout
%20 = tail call i32 @putc(i32 %18, i32 %19)
%21 = zext i1 %14 to i32
br label %25
22: ; preds = %5
%23 = load i32, i32* @stdout
%24 = tail call i32 @putc(i32 %6, i32 %23)
br label %25
25: ; preds = %22, %13
%26 = phi i32 [ %21, %13 ], [ %7, %22 ]
%27 = icmp eq i32 %6, 10
%28 = select i1 %27, i32 0, i32 %26
%29 = load i32, i32* @stdin
%30 = tail call i32 @getc(i32 %29)
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %5
33: ; preds = %25, %0
ret i32 0
}