#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*/ printf(char *, unsigned char);
int /*<<< orphan*/ putchar(unsigned char);
int printname(unsigned char *p) {
  int len = 0;
  for (; *p; ++p) {
    if ((*p >= ' ' && *p <= '~') || (*p >= 0200 && *p <= 0377)) {
      putchar(*p);
      ++len;
    } else {
      printf("\\%03o", *p);
      len += 4;
    }
  }
  return (len);
}


x86 assembly (clang, -O0):
<printname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11d0 <printname+0xb0>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x20,%eax
jl     1160 <printname+0x40>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x7e,%eax
jle    1184 <printname+0x64>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x80,%eax
jl     119e <printname+0x7e>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xff,%eax
jg     119e <printname+0x7e>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ba <printname+0x9a>
mov    -0x8(%rbp),%rax
lea    0xe57(%rip),%rdi
movzbl (%rax),%esi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
jmp    11bf <printname+0x9f>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1133 <printname+0x13>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printname>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1175 <printname+0x55>
mov    %rdi,%rbx
add    $0x1,%rbx
xor    %ebp,%ebp
lea    0xec6(%rip),%r14
jmp    1159 <printname+0x39>
nopl   0x0(%rax)
mov    %esi,%edi
call   1030 <putchar@plt>
mov    $0x1,%eax
add    %eax,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1177 <printname+0x57>
movzbl %al,%esi
test   %al,%al
js     1140 <printname+0x20>
add    $0xe0,%al
cmp    $0x5e,%al
jbe    1140 <printname+0x20>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    $0x4,%eax
jmp    114c <printname+0x2c>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"\\%03o\00"
define i32 @printname(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %41, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %44
8: ; preds = %4
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = icmp sge i32 %11, 32
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = icmp sle i32 %16, 126
br i1 %17, label %28, label %18
18: ; preds = %13, %8
%19 = load i8*, i8** %2
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = icmp sge i32 %21, 128
br i1 %22, label %23, label %34
23: ; preds = %18
%24 = load i8*, i8** %2
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = icmp sle i32 %26, 255
br i1 %27, label %28, label %34
28: ; preds = %23, %13
%29 = load i8*, i8** %2
%30 = load i8, i8* %29
%31 = call i32 @putchar(i8 zeroext %30)
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %40
34: ; preds = %23, %18
%35 = load i8*, i8** %2
%36 = load i8, i8* %35
%37 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 zeroext %36)
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 4
store i32 %39, i32* %3
br label %40
40: ; preds = %34, %28
br label %41
41: ; preds = %40
%42 = load i8*, i8** %2
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %2
br label %4
44: ; preds = %4
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [6 x i8] c"\\%03o\00"
define i32 @printname(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %22, label %4
4: ; preds = %1, %16
%5 = phi i8 [ %20, %16 ], [ %2, %1 ]
%6 = phi i32 [ %18, %16 ], [ 0, %1 ]
%7 = phi i8* [ %19, %16 ], [ %0, %1 ]
%8 = add i8 %5, -32
%9 = icmp ult i8 %8, 95
%10 = icmp slt i8 %5, 0
%11 = or i1 %10, %9
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = tail call i32 @putchar(i8 zeroext %5)
br label %16
14: ; preds = %4
%15 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 zeroext %5)
br label %16
16: ; preds = %12, %14
%17 = phi i32 [ 1, %12 ], [ 4, %14 ]
%18 = add nuw nsw i32 %6, %17
%19 = getelementptr inbounds i8, i8* %7, i64 1
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %4
22: ; preds = %16, %1
%23 = phi i32 [ 0, %1 ], [ %18, %16 ]
ret i32 %23
}