#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 /*<<< orphan*/ string;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ isalpha(char);
scalar_t__ islower(char);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ stdin;
int strlen(char *);
int tolower(char);
int toupper(char);
int main(void) {
  int i;
  char string[1200];
  fgets(string, sizeof(string), stdin);
  for (i = 0; i < strlen(string); i++) {
    if (isalpha(string[i])) {
      if (islower(string[i])) {
        printf("%c", toupper(string[i]));
      } else {
        printf("%c", tolower(string[i]));
      }
    } else {
      printf("%c", string[i]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4d0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x4c0(%rbp),%rdi
mov    0x2e58(%rip),%rax
mov    (%rax),%edx
mov    $0x4b0,%esi
call   1070 <fgets@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4c4(%rbp)
lea    -0x4c0(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x4c4(%rbp),%eax
cmp    %ecx,%eax
jge    1273 <main+0x103>
movslq -0x8(%rbp),%rax
movsbl -0x4c0(%rbp,%rax,1),%edi
ff
call   1090 <isalpha@plt>
cmp    $0x0,%rax
je     1248 <main+0xd8>
movslq -0x8(%rbp),%rax
movsbl -0x4c0(%rbp,%rax,1),%edi
ff
call   1030 <islower@plt>
cmp    $0x0,%rax
je     1223 <main+0xb3>
movslq -0x8(%rbp),%rax
movsbl -0x4c0(%rbp,%rax,1),%edi
ff
call   1040 <toupper@plt>
lea    0xdea(%rip),%rdi
movsbl %al,%esi
call   1060 <printf@plt>
jmp    1243 <main+0xd3>
movslq -0x8(%rbp),%rax
movsbl -0x4c0(%rbp,%rax,1),%edi
ff
call   1080 <tolower@plt>
lea    0xdc5(%rip),%rdi
movsbl %al,%esi
call   1060 <printf@plt>
jmp    1260 <main+0xf0>
movslq -0x8(%rbp),%rax
lea    0xdad(%rip),%rdi
movsbl -0x4c0(%rbp,%rax,1),%esi
ff
call   1060 <printf@plt>
jmp    1265 <main+0xf5>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a3 <main+0x33>
xor    %eax,%eax
add    $0x4d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x4b0,%rsp
mov    0x2e65(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x4b0,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1203 <main+0x93>
xor    %ebx,%ebx
lea    0xe56(%rip),%r14
mov    %rsp,%r15
jmp    11d3 <main+0x63>
nop
call   1080 <tolower@plt>
movsbl %al,%esi
mov    %r14,%rdi
call   1060 <printf@plt>
add    $0x1,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1203 <main+0x93>
movsbl (%rsp,%rbx,1),%edi
call   1090 <isalpha@plt>
mov    %rax,%rcx
movzbl (%rsp,%rbx,1),%eax
test   %rcx,%rcx
je     11b5 <main+0x45>
movsbl %al,%edi
call   1030 <islower@plt>
movzbl (%rsp,%rbx,1),%ecx
movsbl %cl,%edi
test   %rax,%rax
je     11b0 <main+0x40>
call   1040 <toupper@plt>
jmp    11b5 <main+0x45>
xor    %eax,%eax
add    $0x4b0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1200 x i8]
store i32 0, i32* %1
%4 = getelementptr inbounds [1200 x i8], [1200 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %4, i32 1200, i32 %5)
store i32 0, i32* %2
br label %7
7: ; preds = %50, %0
%8 = load i32, i32* %2
%9 = getelementptr inbounds [1200 x i8], [1200 x i8]* %3, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %53
12: ; preds = %7
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [1200 x i8], [1200 x i8]* %3, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = call i64 @isalpha(i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %43
19: ; preds = %12
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [1200 x i8], [1200 x i8]* %3, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = call i64 @islower(i8 signext %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %34
26: ; preds = %19
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [1200 x i8], [1200 x i8]* %3, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = call i32 @toupper(i8 signext %30)
%32 = trunc i32 %31 to i8
%33 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %32)
br label %42
34: ; preds = %19
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [1200 x i8], [1200 x i8]* %3, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = call i32 @tolower(i8 signext %38)
%40 = trunc i32 %39 to i8
%41 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %40)
br label %42
42: ; preds = %34, %26
br label %49
43: ; preds = %12
%44 = load i32, i32* %2
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [1200 x i8], [1200 x i8]* %3, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %47)
br label %49
49: ; preds = %43, %42
br label %50
50: ; preds = %49
%51 = load i32, i32* %2
%52 = add nsw i32 %51, 1
store i32 %52, i32* %2
br label %7
53: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca [1200 x i8]
%2 = getelementptr inbounds [1200 x i8], [1200 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32 @fgets(i8* %2, i32 1200, i32 %3)
%5 = call i32 @strlen(i8* %2)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %31
7: ; preds = %0, %24
%8 = phi i64 [ %27, %24 ], [ 0, %0 ]
%9 = getelementptr inbounds [1200 x i8], [1200 x i8]* %1, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = call i64 @isalpha(i8 signext %10)
%12 = icmp eq i64 %11, 0
%13 = load i8, i8* %9
br i1 %12, label %24, label %14
14: ; preds = %7
%15 = call i64 @islower(i8 signext %13)
%16 = icmp eq i64 %15, 0
%17 = load i8, i8* %9
br i1 %16, label %21, label %18
18: ; preds = %14
%19 = call i32 @toupper(i8 signext %17)
%20 = trunc i32 %19 to i8
br label %24
21: ; preds = %14
%22 = call i32 @tolower(i8 signext %17)
%23 = trunc i32 %22 to i8
br label %24
24: ; preds = %7, %21, %18
%25 = phi i8 [ %23, %21 ], [ %20, %18 ], [ %13, %7 ]
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %25)
%27 = add nuw nsw i64 %8, 1
%28 = call i32 @strlen(i8* %2)
%29 = sext i32 %28 to i64
%30 = icmp slt i64 %27, %29
br i1 %30, label %7, label %31
31: ; preds = %24, %0
ret i32 0
}