#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ conf_char_to_escape(unsigned int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputc(char const, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
void man_print_strval(const char *v, FILE *out) {
  for (; *v; v++) {
    if (*v < ' ' || *v & 0x80) {
      fputc('\\', out);
      conf_char_to_escape((unsigned int)*v, out);
      continue;
    }
    if (*v == '"')
      fputs("\\(rq", out);
    else if (*v == '\\')
      fputs("\\\\", out);
    else if (*v == '-')
      fputs("\\-", out);
    else
      fputc(*v, out);
  }
}


x86 assembly (clang, -O0):
<man_print_strval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1236 <man_print_strval+0x106>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jl     1172 <man_print_strval+0x42>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1195 <man_print_strval+0x65>
mov    -0x10(%rbp),%rsi
mov    $0x5c,%edi
call   1040 <fputc@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
mov    -0x10(%rbp),%rsi
call   1050 <conf_char_to_escape@plt>
jmp    1225 <man_print_strval+0xf5>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    11ba <man_print_strval+0x8a>
mov    -0x10(%rbp),%rsi
lea    0xe50(%rip),%rdi
call   1030 <fputs@plt>
jmp    1220 <man_print_strval+0xf0>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11df <man_print_strval+0xaf>
mov    -0x10(%rbp),%rsi
lea    0xe30(%rip),%rdi
call   1030 <fputs@plt>
jmp    121b <man_print_strval+0xeb>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1204 <man_print_strval+0xd4>
mov    -0x10(%rbp),%rsi
lea    0xe0e(%rip),%rdi
call   1030 <fputs@plt>
jmp    1216 <man_print_strval+0xe6>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1040 <fputc@plt>
jmp    121b <man_print_strval+0xeb>
jmp    1220 <man_print_strval+0xf0>
jmp    1225 <man_print_strval+0xf5>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1140 <man_print_strval+0x10>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<man_print_strval>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     11e6 <man_print_strval+0xb6>
mov    %rsi,%r14
mov    %rdi,%rbx
add    $0x1,%rbx
lea    0xeb1(%rip),%r15
lea    0xead(%rip),%r12
lea    0xe9e(%rip),%r13
jmp    1194 <man_print_strval+0x64>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x5c,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
movsbl -0x1(%rbx),%edi
mov    %r14,%rsi
call   1050 <conf_char_to_escape@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11e6 <man_print_strval+0xb6>
cmp    $0x1f,%al
jle    1170 <man_print_strval+0x40>
cmp    $0x5c,%al
je     11c2 <man_print_strval+0x92>
cmp    $0x2d,%al
je     11b3 <man_print_strval+0x83>
cmp    $0x22,%al
jne    11d9 <man_print_strval+0xa9>
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r13,%rdi
jmp    11cf <man_print_strval+0x9f>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rdi
jmp    11cf <man_print_strval+0x9f>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %r14,%rcx
call   1040 <fwrite@plt>
jmp    1189 <man_print_strval+0x59>
movsbl %al,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
jmp    1189 <man_print_strval+0x59>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"\\(rq\00"
@.str.1 = [3 x i8] c"\\\\\00"
@.str.2 = [3 x i8] c"\\-\00"
define void @man_print_strval(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %3
store i32* %1, i32** %4
br label %5
5: ; preds = %60, %2
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %63
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp slt i32 %12, 32
br i1 %13, label %20, label %14
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = and i32 %17, 128
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %14, %9
%21 = load i32*, i32** %4
%22 = call i32 @fputc(i8 signext 92, i32* %21)
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = load i32*, i32** %4
%27 = call i32 @conf_char_to_escape(i32 %25, i32* %26)
br label %60
28: ; preds = %14
%29 = load i8*, i8** %3
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 34
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = load i32*, i32** %4
%35 = call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %34)
br label %59
36: ; preds = %28
%37 = load i8*, i8** %3
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 92
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = load i32*, i32** %4
%43 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %42)
br label %58
44: ; preds = %36
%45 = load i8*, i8** %3
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 45
br i1 %48, label %49, label %52
49: ; preds = %44
%50 = load i32*, i32** %4
%51 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %50)
br label %57
52: ; preds = %44
%53 = load i8*, i8** %3
%54 = load i8, i8* %53
%55 = load i32*, i32** %4
%56 = call i32 @fputc(i8 signext %54, i32* %55)
br label %57
57: ; preds = %52, %49
br label %58
58: ; preds = %57, %41
br label %59
59: ; preds = %58, %33
br label %60
60: ; preds = %59, %20
%61 = load i8*, i8** %3
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %3
br label %5
63: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"\\(rq\00"
@.str.1 = [3 x i8] c"\\\\\00"
@.str.2 = [3 x i8] c"\\-\00"
define void @man_print_strval(i8* nocapture %0, i32* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %27, label %5
5: ; preds = %2, %23
%6 = phi i8 [ %25, %23 ], [ %3, %2 ]
%7 = phi i8* [ %24, %23 ], [ %0, %2 ]
%8 = icmp slt i8 %6, 32
br i1 %8, label %9, label %14
9: ; preds = %5
%10 = tail call i32 @fputc(i8 signext 92, i32* %1)
%11 = load i8, i8* %7
%12 = sext i8 %11 to i32
%13 = tail call i32 @conf_char_to_escape(i32 %12, i32* %1)
br label %23
14: ; preds = %5
switch i8 %6, label %21 [
i8 34, label %15
i8 92, label %17
i8 45, label %19
]
15: ; preds = %14
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 4, i64 1, i32* %1)
br label %23
17: ; preds = %14
%18 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 2, i64 1, i32* %1)
br label %23
19: ; preds = %14
%20 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 2, i64 1, i32* %1)
br label %23
21: ; preds = %14
%22 = tail call i32 @fputc(i8 signext %6, i32* %1)
br label %23
23: ; preds = %15, %19, %21, %17, %9
%24 = getelementptr inbounds i8, i8* %7, i64 1
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %5
27: ; preds = %23, %2
ret void
}