#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__ dos_char_to_printable(char **, unsigned char);
void put_char(char **p, unsigned char c) {
  if (dos_char_to_printable(p, c))
    return;
  if ((c >= ' ' && c < 0x7f) || c >= 0xa0)
    *(*p)++ = c;
  else {
    *(*p)++ = '\\';
    *(*p)++ = '0' + (c >> 6);
    *(*p)++ = '0' + ((c >> 3) & 7);
    *(*p)++ = '0' + (c & 7);
  }
}


x86 assembly (clang, -O0):
<put_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
movzbl -0x9(%rbp),%esi
call   1030 <dos_char_to_printable@plt>
cmp    $0x0,%rax
je     113e <put_char+0x2e>
jmp    11f6 <put_char+0xe6>
movzbl -0x9(%rbp),%eax
cmp    $0x20,%eax
jl     1158 <put_char+0x48>
movzbl -0x9(%rbp),%eax
cmp    $0x7f,%eax
jl     1167 <put_char+0x57>
movzbl -0x9(%rbp),%eax
cmp    $0xa0,%eax
jl     1182 <put_char+0x72>
mov    -0x9(%rbp),%cl
mov    -0x8(%rbp),%rdx
mov    (%rdx),%rax
mov    %rax,%rsi
add    $0x1,%rsi
mov    %rsi,(%rdx)
mov    %cl,(%rax)
jmp    11f6 <put_char+0xe6>
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
movb   $0x5c,(%rax)
movzbl -0x9(%rbp),%eax
sar    $0x6,%eax
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rdx
mov    (%rdx),%rax
mov    %rax,%rsi
add    $0x1,%rsi
mov    %rsi,(%rdx)
mov    %cl,(%rax)
movzbl -0x9(%rbp),%eax
sar    $0x3,%eax
and    $0x7,%eax
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rdx
mov    (%rdx),%rax
mov    %rax,%rsi
add    $0x1,%rsi
mov    %rsi,(%rdx)
mov    %cl,(%rax)
movzbl -0x9(%rbp),%eax
and    $0x7,%eax
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rdx
mov    (%rdx),%rax
mov    %rax,%rsi
add    $0x1,%rsi
mov    %rsi,(%rdx)
mov    %cl,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_char>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
call   1030 <dos_char_to_printable@plt>
test   %rax,%rax
jne    1177 <put_char+0x67>
mov    (%r14),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%r14)
cmp    $0x9f,%bl
ja     1175 <put_char+0x65>
lea    -0x20(%rbx),%ecx
cmp    $0x5e,%cl
jbe    1175 <put_char+0x65>
movb   $0x5c,(%rax)
mov    %ebx,%eax
shr    $0x6,%al
or     $0x30,%al
mov    (%r14),%rcx
lea    0x1(%rcx),%rdx
mov    %rdx,(%r14)
mov    %al,(%rcx)
mov    %ebx,%eax
shr    $0x3,%al
and    $0x7,%al
or     $0x30,%al
mov    (%r14),%rcx
lea    0x1(%rcx),%rdx
mov    %rdx,(%r14)
mov    %al,(%rcx)
and    $0x7,%bl
or     $0x30,%bl
mov    (%r14),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%r14)
mov    %bl,(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @put_char(i8** %0, i8 zeroext %1) {
%3 = alloca i8**
%4 = alloca i8
store i8** %0, i8*** %3
store i8 %1, i8* %4
%5 = load i8**, i8*** %3
%6 = load i8, i8* %4
%7 = call i64 @dos_char_to_printable(i8** %5, i8 zeroext %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
br label %56
10: ; preds = %2
%11 = load i8, i8* %4
%12 = zext i8 %11 to i32
%13 = icmp sge i32 %12, 32
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i8, i8* %4
%16 = zext i8 %15 to i32
%17 = icmp slt i32 %16, 127
br i1 %17, label %22, label %18
18: ; preds = %14, %10
%19 = load i8, i8* %4
%20 = zext i8 %19 to i32
%21 = icmp sge i32 %20, 160
br i1 %21, label %22, label %27
22: ; preds = %18, %14
%23 = load i8, i8* %4
%24 = load i8**, i8*** %3
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %24
store i8 %23, i8* %25
br label %56
27: ; preds = %18
%28 = load i8**, i8*** %3
%29 = load i8*, i8** %28
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %28
store i8 92, i8* %29
%31 = load i8, i8* %4
%32 = zext i8 %31 to i32
%33 = ashr i32 %32, 6
%34 = add nsw i32 48, %33
%35 = trunc i32 %34 to i8
%36 = load i8**, i8*** %3
%37 = load i8*, i8** %36
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %36
store i8 %35, i8* %37
%39 = load i8, i8* %4
%40 = zext i8 %39 to i32
%41 = ashr i32 %40, 3
%42 = and i32 %41, 7
%43 = add nsw i32 48, %42
%44 = trunc i32 %43 to i8
%45 = load i8**, i8*** %3
%46 = load i8*, i8** %45
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %45
store i8 %44, i8* %46
%48 = load i8, i8* %4
%49 = zext i8 %48 to i32
%50 = and i32 %49, 7
%51 = add nsw i32 48, %50
%52 = trunc i32 %51 to i8
%53 = load i8**, i8*** %3
%54 = load i8*, i8** %53
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %53
store i8 %52, i8* %54
br label %56
56: ; preds = %9, %27, %22
ret void
}

LLVM IR (-O2):
define void @put_char(i8** %0, i8 zeroext %1) {
%3 = tail call i64 @dos_char_to_printable(i8** %0, i8 zeroext %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %27
5: ; preds = %2
%6 = add i8 %1, -32
%7 = icmp ult i8 %6, 95
%8 = icmp ugt i8 %1, -97
%9 = or i1 %8, %7
%10 = load i8*, i8** %0
%11 = getelementptr inbounds i8, i8* %10, i64 1
store i8* %11, i8** %0
br i1 %9, label %12, label %13
12: ; preds = %5
store i8 %1, i8* %10
br label %27
13: ; preds = %5
store i8 92, i8* %10
%14 = lshr i8 %1, 6
%15 = or i8 %14, 48
%16 = load i8*, i8** %0
%17 = getelementptr inbounds i8, i8* %16, i64 1
store i8* %17, i8** %0
store i8 %15, i8* %16
%18 = lshr i8 %1, 3
%19 = and i8 %18, 7
%20 = or i8 %19, 48
%21 = load i8*, i8** %0
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8* %22, i8** %0
store i8 %20, i8* %21
%23 = and i8 %1, 7
%24 = or i8 %23, 48
%25 = load i8*, i8** %0
%26 = getelementptr inbounds i8, i8* %25, i64 1
store i8* %26, i8** %0
store i8 %24, i8* %25
br label %27
27: ; preds = %2, %13, %12
ret void
}