#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__ isascii(int);
scalar_t__ isprint(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(int);
void putch(int c, int strip) {
  if (isascii(c) && (isprint(c) || c == '\n' || c == '\t' || c == ' ')) {
    putchar(c);
  } else if (!strip) {
    printf("\\%03o", c);
  }
}


x86 assembly (clang, -O0):
<putch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <isascii@plt>
cmp    $0x0,%rax
je     119d <putch+0x5d>
mov    -0x4(%rbp),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
jne    1190 <putch+0x50>
cmpl   $0xa,-0x4(%rbp)
je     1190 <putch+0x50>
cmpl   $0x9,-0x4(%rbp)
je     1190 <putch+0x50>
cmpl   $0x20,-0x4(%rbp)
jne    119d <putch+0x5d>
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
jmp    11bb <putch+0x7b>
cmpl   $0x0,-0x8(%rbp)
jne    11b6 <putch+0x76>
mov    -0x4(%rbp),%esi
lea    0xe4f(%rip),%rdi
call   1040 <printf@plt>
jmp    11bb <putch+0x7b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putch>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
call   1060 <isascii@plt>
test   %rax,%rax
je     1181 <putch+0x41>
mov    %ebx,%edi
call   1050 <isprint@plt>
test   %rax,%rax
jne    1174 <putch+0x34>
cmp    $0x20,%ebx
ja     1181 <putch+0x41>
mov    %ebx,%eax
movabs $0x100000600,%rcx
bt     %rax,%rcx
jae    1181 <putch+0x41>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>
test   %ebp,%ebp
je     118c <putch+0x4c>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe6d(%rip),%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"\\%03o\00"
define void @putch(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = call i64 @isascii(i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %24
8: ; preds = %2
%9 = load i32, i32* %3
%10 = call i64 @isprint(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %21, label %12
12: ; preds = %8
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 10
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 9
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, 32
br i1 %20, label %21, label %24
21: ; preds = %18, %15, %12, %8
%22 = load i32, i32* %3
%23 = call i32 @putchar(i32 %22)
br label %31
24: ; preds = %18, %2
%25 = load i32, i32* %4
%26 = icmp ne i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = load i32, i32* %3
%29 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %24
br label %31
31: ; preds = %30, %21
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"\\%03o\00"
define void @putch(i32 %0, i32 %1) {
%3 = tail call i64 @isascii(i32 %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = tail call i64 @isprint(i32 %0)
%7 = freeze i64 %6
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %5
switch i32 %0, label %12 [
i32 32, label %10
i32 10, label %10
i32 9, label %10
]
10: ; preds = %9, %9, %9, %5
%11 = tail call i32 @putchar(i32 %0)
br label %16
12: ; preds = %9, %2
%13 = icmp eq i32 %1, 0
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %16
16: ; preds = %12, %14, %10
ret void
}