#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*/ fprintf(int /*<<< orphan*/, char *, unsigned char);
int /*<<< orphan*/ isascii(char const);
scalar_t__ iseseq(char const *, int);
int /*<<< orphan*/ isprint(char const);
int /*<<< orphan*/ putchar(char const);
int /*<<< orphan*/ stdout;
void encode(const char *s) {
  while (*s) {
    if (iseseq(s, false) || !isprint(*s) || !isascii(*s))
      fprintf(stdout, "\\#%03o", (unsigned char)*s);
    else
      putchar(*s);
    s++;
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11e6 <encode+0x96>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1040 <iseseq@plt>
cmp    $0x0,%rax
jne    11a8 <encode+0x58>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isprint@plt>
cmp    $0x0,%eax
je     11a8 <encode+0x58>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isascii@plt>
cmp    $0x0,%eax
jne    11c9 <encode+0x79>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
lea    0xe44(%rip),%rsi
movzbl (%rax),%edx
call   1050 <fprintf@plt>
jmp    11d5 <encode+0x85>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    115c <encode+0xc>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode>:
push   %r15
push   %r14
push   %rbx
cmpb   $0x0,(%rdi)
je     11b9 <encode+0x69>
mov    %rdi,%rbx
mov    0x2e7c(%rip),%r15
lea    0xe95(%rip),%r14
jmp    1188 <encode+0x38>
nopl   (%rax)
mov    (%r15),%edi
movzbl (%rbx),%edx
mov    %r14,%rsi
call   1050 <fprintf@plt>
cmpb   $0x0,0x1(%rbx)
lea    0x1(%rbx),%rbx
je     11b9 <encode+0x69>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <iseseq@plt>
test   %rax,%rax
jne    1170 <encode+0x20>
movsbl (%rbx),%edi
call   1060 <isprint@plt>
test   %eax,%eax
je     1170 <encode+0x20>
movsbl (%rbx),%edi
call   1070 <isascii@plt>
test   %eax,%eax
je     1170 <encode+0x20>
movsbl (%rbx),%edi
call   1030 <putchar@plt>
jmp    117e <encode+0x2e>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@stdout = global i32 0
@.str = [7 x i8] c"\\#%03o\00"
define void @encode(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %27, label %4
4: ; preds = %1, %23
%5 = phi i8* [ %24, %23 ], [ %0, %1 ]
%6 = tail call i64 @iseseq(i8* %5, i32 0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %4
%9 = load i8, i8* %5
%10 = tail call i32 @isprint(i8 signext %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = load i8, i8* %5
%14 = tail call i32 @isascii(i8 signext %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12, %8, %4
%17 = load i32, i32* @stdout
%18 = load i8, i8* %5
%19 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 zeroext %18)
br label %23
20: ; preds = %12
%21 = load i8, i8* %5
%22 = tail call i32 @putchar(i8 signext %21)
br label %23
23: ; preds = %20, %16
%24 = getelementptr inbounds i8, i8* %5, i64 1
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %4
27: ; preds = %23, %1
%28 = tail call i32 @putchar(i8 signext 10)
ret void
}