#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 getchar();
scalar_t__ isprint(int);
int /*<<< orphan*/ putchar(int);
int main(void) {
  int orig_char, new_char;
  while ((orig_char = getchar()) != EOF) {
    new_char = orig_char ^ '&';
    if (isprint(orig_char) && isprint(new_char))
      putchar(new_char);
    else
      putchar(orig_char);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e98(%rip),%rcx
cmp    (%rcx),%eax
je     119f <main+0x6f>
mov    -0x8(%rbp),%eax
xor    $0x26,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     1192 <main+0x62>
mov    -0xc(%rbp),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     1192 <main+0x62>
mov    -0xc(%rbp),%edi
call   1030 <putchar@plt>
jmp    119a <main+0x6a>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    113f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2ea6(%rip),%r14
cmp    (%r14),%eax
jne    114e <main+0x1e>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %eax,%ebx
jmp    1177 <main+0x47>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
cmp    (%r14),%eax
je     1147 <main+0x17>
mov    %ebx,%edi
call   1050 <isprint@plt>
test   %rax,%rax
je     1160 <main+0x30>
mov    %ebx,%ebp
xor    $0x26,%ebp
mov    %ebp,%edi
call   1050 <isprint@plt>
test   %rax,%rax
jne    1162 <main+0x32>
jmp    1160 <main+0x30>

LLVM IR (-O0):
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %24, %0
%5 = call i32 (...) @getchar()
store i32 %5, i32* %2
%6 = load i32, i32* @EOF
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %25
8: ; preds = %4
%9 = load i32, i32* %2
%10 = xor i32 %9, 38
store i32 %10, i32* %3
%11 = load i32, i32* %2
%12 = call i64 @isprint(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %8
%15 = load i32, i32* %3
%16 = call i64 @isprint(i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i32, i32* %3
%20 = call i32 @putchar(i32 %19)
br label %24
21: ; preds = %14, %8
%22 = load i32, i32* %2
%23 = call i32 @putchar(i32 %22)
br label %24
24: ; preds = %21, %18
br label %4
25: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@EOF = 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 %19, label %4
4: ; preds = %0, %13
%5 = phi i32 [ %16, %13 ], [ %1, %0 ]
%6 = xor i32 %5, 38
%7 = tail call i64 @isprint(i32 %5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %4
%10 = tail call i64 @isprint(i32 %6)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9, %4
br label %13
13: ; preds = %9, %12
%14 = phi i32 [ %5, %12 ], [ %6, %9 ]
%15 = tail call i32 @putchar(i32 %14)
%16 = tail call i32 (...) @getchar()
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %4
19: ; preds = %13, %0
ret i32 0
}