#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 */
scalar_t__ isprint(char);
char cbm_petscii2ascii_c(char Character) {
  switch (Character & 0xff) {
  case 0x0a:
  case 0x0d:
    return '\n';
  case 0x40:
  case 0x60:
    return Character;
  case 0xa0:
  case 0xe0:
    return ' ';
  default:
    switch (Character & 0xe0) {
    case 0x40:
    case 0x60:
      return (Character ^ 0x20);
    case 0xc0:
      return (Character ^ 0x80);
    }
  }
  return ((isprint(Character) ? Character : '.'));
}


x86 assembly (clang, -O0):
<cbm_petscii2ascii_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0xa,%eax
je     118c <cbm_petscii2ascii_c+0x7c>
jmp    1133 <cbm_petscii2ascii_c+0x23>
mov    -0x8(%rbp),%eax
sub    $0xd,%eax
je     118c <cbm_petscii2ascii_c+0x7c>
jmp    1144 <cbm_petscii2ascii_c+0x34>
mov    -0x8(%rbp),%eax
sub    $0x40,%eax
je     1195 <cbm_petscii2ascii_c+0x85>
jmp    1155 <cbm_petscii2ascii_c+0x45>
mov    -0x8(%rbp),%eax
sub    $0x60,%eax
je     1195 <cbm_petscii2ascii_c+0x85>
jmp    1166 <cbm_petscii2ascii_c+0x56>
mov    -0x8(%rbp),%eax
sub    $0xa0,%eax
je     11a0 <cbm_petscii2ascii_c+0x90>
jmp    1179 <cbm_petscii2ascii_c+0x69>
mov    -0x8(%rbp),%eax
sub    $0xe0,%eax
je     11a0 <cbm_petscii2ascii_c+0x90>
jmp    11a9 <cbm_petscii2ascii_c+0x99>
movb   $0xa,-0x1(%rbp)
jmp    123c <cbm_petscii2ascii_c+0x12c>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    123c <cbm_petscii2ascii_c+0x12c>
movb   $0x20,-0x1(%rbp)
jmp    123c <cbm_petscii2ascii_c+0x12c>
movzbl -0x2(%rbp),%eax
and    $0xffffffe0,%eax
mov    %eax,-0xc(%rbp)
sub    $0x40,%eax
je     11e5 <cbm_petscii2ascii_c+0xd5>
jmp    11c1 <cbm_petscii2ascii_c+0xb1>
mov    -0xc(%rbp),%eax
sub    $0x60,%eax
je     11e5 <cbm_petscii2ascii_c+0xd5>
jmp    11d2 <cbm_petscii2ascii_c+0xc2>
mov    -0xc(%rbp),%eax
sub    $0xc0,%eax
je     11f4 <cbm_petscii2ascii_c+0xe4>
jmp    1205 <cbm_petscii2ascii_c+0xf5>
movsbl -0x2(%rbp),%eax
xor    $0x20,%eax
mov    %al,-0x1(%rbp)
jmp    123c <cbm_petscii2ascii_c+0x12c>
movsbl -0x2(%rbp),%eax
xor    $0x80,%eax
mov    %al,-0x1(%rbp)
jmp    123c <cbm_petscii2ascii_c+0x12c>
jmp    120a <cbm_petscii2ascii_c+0xfa>
movsbl -0x2(%rbp),%edi
call   1030 <isprint@plt>
cmp    $0x0,%rax
je     1229 <cbm_petscii2ascii_c+0x119>
movsbl -0x2(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1236 <cbm_petscii2ascii_c+0x126>
mov    $0x2e,%eax
mov    %eax,-0x10(%rbp)
jmp    1236 <cbm_petscii2ascii_c+0x126>
mov    -0x10(%rbp),%eax
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cbm_petscii2ascii_c>:
push   %rbx
mov    %edi,%ebx
mov    $0xa,%al
cmp    $0xc,%bl
jg     112b <cbm_petscii2ascii_c+0x1b>
cmp    $0xa0,%bl
je     114f <cbm_petscii2ascii_c+0x3f>
cmp    $0xe0,%bl
je     114f <cbm_petscii2ascii_c+0x3f>
cmp    $0xa,%bl
jne    113a <cbm_petscii2ascii_c+0x2a>
pop    %rbx
ret
cmp    $0xd,%bl
je     1129 <cbm_petscii2ascii_c+0x19>
cmp    $0x60,%bl
je     1156 <cbm_petscii2ascii_c+0x46>
cmp    $0x40,%bl
je     1156 <cbm_petscii2ascii_c+0x46>
mov    %ebx,%eax
and    $0xe0,%al
cmp    $0xc0,%al
je     1153 <cbm_petscii2ascii_c+0x43>
cmp    $0x60,%al
je     114a <cbm_petscii2ascii_c+0x3a>
cmp    $0x40,%al
jne    115a <cbm_petscii2ascii_c+0x4a>
xor    $0x20,%bl
jmp    1156 <cbm_petscii2ascii_c+0x46>
mov    $0x20,%al
pop    %rbx
ret
xor    $0x80,%bl
mov    %ebx,%eax
pop    %rbx
ret
movsbl %bl,%edi
call   1030 <isprint@plt>
test   %rax,%rax
movzbl %bl,%ecx
mov    $0x2e,%eax
cmovne %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define signext i8 @cbm_petscii2ascii_c(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = and i32 %5, 255
switch i32 %6, label %11 [
i32 10, label %7
i32 13, label %7
i32 64, label %8
i32 96, label %8
i32 160, label %10
i32 224, label %10
]
7: ; preds = %1, %1
store i8 10, i8* %2
br label %37
8: ; preds = %1, %1
%9 = load i8, i8* %3
store i8 %9, i8* %2
br label %37
10: ; preds = %1, %1
store i8 32, i8* %2
br label %37
11: ; preds = %1
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = and i32 %13, 224
switch i32 %14, label %25 [
i32 64, label %15
i32 96, label %15
i32 192, label %20
]
15: ; preds = %11, %11
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = xor i32 %17, 32
%19 = trunc i32 %18 to i8
store i8 %19, i8* %2
br label %37
20: ; preds = %11
%21 = load i8, i8* %3
%22 = sext i8 %21 to i32
%23 = xor i32 %22, 128
%24 = trunc i32 %23 to i8
store i8 %24, i8* %2
br label %37
25: ; preds = %11
br label %26
26: ; preds = %25
%27 = load i8, i8* %3
%28 = call i64 @isprint(i8 signext %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i8, i8* %3
%32 = sext i8 %31 to i32
br label %34
33: ; preds = %26
br label %34
34: ; preds = %33, %30
%35 = phi i32 [ %32, %30 ], [ 46, %33 ]
%36 = trunc i32 %35 to i8
store i8 %36, i8* %2
br label %37
37: ; preds = %34, %20, %15, %10, %8, %7
%38 = load i8, i8* %2
ret i8 %38
}

LLVM IR (-O2):
define signext i8 @cbm_petscii2ascii_c(i8 signext %0) {
switch i8 %0, label %4 [
i8 10, label %14
i8 13, label %14
i8 64, label %2
i8 96, label %2
i8 -96, label %3
i8 -32, label %3
]
2: ; preds = %1, %1
br label %14
3: ; preds = %1, %1
br label %14
4: ; preds = %1
%5 = and i8 %0, -32
switch i8 %5, label %10 [
i8 64, label %6
i8 96, label %6
i8 -64, label %8
]
6: ; preds = %4, %4
%7 = xor i8 %0, 32
br label %14
8: ; preds = %4
%9 = xor i8 %0, -128
br label %14
10: ; preds = %4
%11 = tail call i64 @isprint(i8 signext %0)
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i8 46, i8 %0
br label %14
14: ; preds = %1, %1, %10, %8, %6, %3, %2
%15 = phi i8 [ %13, %10 ], [ %9, %8 ], [ %7, %6 ], [ 32, %3 ], [ %0, %2 ], [ 10, %1 ], [ 10, %1 ]
ret i8 %15
}