#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 /*<<< orphan*/ PutCh(char);
int /*<<< orphan*/ PutChs(char *);
void EscapeWriteCh(char ch) {
  if ((ch >= ' ') && (ch < 0x7F))
    PutCh(ch);
  else if (ch == 0x7F)
    PutChs("|?");
  else if (ch > 0x7F) {
    PutChs("|!");
    EscapeWriteCh(ch - 0x80);
  } else {
    PutCh('|');
    PutCh(ch + 0x40);
  }
}


x86 assembly (clang, -O0):
<EscapeWriteCh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x20,%eax
jl     1166 <EscapeWriteCh+0x36>
movsbl -0x1(%rbp),%eax
cmp    $0x7f,%eax
jge    1166 <EscapeWriteCh+0x36>
movsbl -0x1(%rbp),%edi
call   1030 <PutCh@plt>
jmp    11d6 <EscapeWriteCh+0xa6>
movsbl -0x1(%rbp),%eax
cmp    $0x7f,%eax
jne    1184 <EscapeWriteCh+0x54>
lea    0xe86(%rip),%rdi
call   1040 <PutChs@plt>
jmp    11d1 <EscapeWriteCh+0xa1>
movsbl -0x1(%rbp),%eax
cmp    $0x7f,%eax
jle    11b3 <EscapeWriteCh+0x83>
lea    0xe6b(%rip),%rdi
call   1040 <PutChs@plt>
movsbl -0x1(%rbp),%eax
sub    $0x80,%eax
movsbl %al,%edi
call   1050 <EscapeWriteCh@plt>
jmp    11cc <EscapeWriteCh+0x9c>
mov    $0x7c,%edi
call   1030 <PutCh@plt>
movsbl -0x1(%rbp),%eax
add    $0x40,%eax
movsbl %al,%edi
call   1030 <PutCh@plt>
jmp    11d1 <EscapeWriteCh+0xa1>
jmp    11d6 <EscapeWriteCh+0xa6>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EscapeWriteCh>:
push   %rbx
mov    %edi,%ebx
lea    -0x20(%rbx),%eax
cmp    $0x5e,%al
jbe    1149 <EscapeWriteCh+0x29>
cmp    $0x7f,%bl
jne    113c <EscapeWriteCh+0x1c>
lea    0xeca(%rip),%rdi
pop    %rbx
jmp    1040 <PutChs@plt>
mov    $0x7c,%edi
call   1030 <PutCh@plt>
add    $0x40,%bl
movsbl %bl,%edi
pop    %rbx
jmp    1030 <PutCh@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"|?\00"
@.str.1 = [3 x i8] c"|!\00"
define void @EscapeWriteCh(i8 signext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = sext i8 %3 to i32
%5 = icmp sge i32 %4, 32
br i1 %5, label %6, label %13
6: ; preds = %1
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp slt i32 %8, 127
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i8, i8* %2
%12 = call i32 @PutCh(i8 signext %11)
br label %38
13: ; preds = %6, %1
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 127
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @PutChs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %37
19: ; preds = %13
%20 = load i8, i8* %2
%21 = sext i8 %20 to i32
%22 = icmp sgt i32 %21, 127
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = call i32 @PutChs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%25 = load i8, i8* %2
%26 = sext i8 %25 to i32
%27 = sub nsw i32 %26, 128
%28 = trunc i32 %27 to i8
br label %36
29: ; preds = %19
%30 = call i32 @PutCh(i8 signext 124)
%31 = load i8, i8* %2
%32 = sext i8 %31 to i32
%33 = add nsw i32 %32, 64
%34 = trunc i32 %33 to i8
%35 = call i32 @PutCh(i8 signext %34)
br label %36
36: ; preds = %29, %23
br label %37
37: ; preds = %36, %17
br label %38
38: ; preds = %37, %10
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"|?\00"
define void @EscapeWriteCh(i8 signext %0) {
%2 = add i8 %0, -32
%3 = icmp ult i8 %2, 95
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @PutCh(i8 signext %0)
br label %14
6: ; preds = %1
%7 = icmp eq i8 %0, 127
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 @PutChs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %14
10: ; preds = %6
%11 = tail call i32 @PutCh(i8 signext 124)
%12 = add nsw i8 %0, 64
%13 = tail call i32 @PutCh(i8 signext %12)
br label %14
14: ; preds = %8, %10, %4
ret void
}