#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*/ fputc(char, int /*<<< orphan*/ *);
scalar_t__ isprint(char);
int /*<<< orphan*/ print_hex(char, int /*<<< orphan*/ *);
void print_string_char(char c, FILE *output) {
  if (isprint(c)) {
    fputc(c, output);
  } else {
    fputc('\\', output);
    switch (c) {
    case '\n':
      fputc('n', output);
      break;
    case '\t':
      fputc('t', output);
      break;
    case '\a':
      fputc('a', output);
      break;
    case '\r':
      fputc('r', output);
      break;
    default:
      fputc('x', output);
      print_hex(c, output);
    }
  }
}


x86 assembly (clang, -O0):
<print_string_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
movsbl -0x1(%rbp),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     1169 <print_string_char+0x39>
mov    -0x1(%rbp),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
jmp    120f <print_string_char+0xdf>
mov    -0x10(%rbp),%rsi
mov    $0x5c,%edi
call   1030 <fputc@plt>
movsbl -0x1(%rbp),%eax
add    $0xfffffff9,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x6,%eax
ja     11ed <print_string_char+0xbd>
mov    -0x18(%rbp),%rax
lea    0xe68(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rsi
mov    $0x6e,%edi
call   1030 <fputc@plt>
jmp    120a <print_string_char+0xda>
mov    -0x10(%rbp),%rsi
mov    $0x74,%edi
call   1030 <fputc@plt>
jmp    120a <print_string_char+0xda>
mov    -0x10(%rbp),%rsi
mov    $0x61,%edi
call   1030 <fputc@plt>
jmp    120a <print_string_char+0xda>
mov    -0x10(%rbp),%rsi
mov    $0x72,%edi
call   1030 <fputc@plt>
jmp    120a <print_string_char+0xda>
mov    -0x10(%rbp),%rsi
mov    $0x78,%edi
call   1030 <fputc@plt>
mov    -0x1(%rbp),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1040 <print_hex@plt>
jmp    120f <print_string_char+0xdf>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_string_char>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
call   1050 <isprint@plt>
test   %rax,%rax
je     1153 <print_string_char+0x23>
movsbl %bpl,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fputc@plt>
mov    $0x5c,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
movsbl %bpl,%r14d
lea    -0x7(%r14),%eax
cmp    $0x6,%eax
ja     1184 <print_string_char+0x54>
lea    0xe8c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x61,%edi
jmp    1147 <print_string_char+0x17>
mov    $0x78,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <print_hex@plt>
mov    $0x74,%edi
jmp    1147 <print_string_char+0x17>
mov    $0x6e,%edi
jmp    1147 <print_string_char+0x17>
mov    $0x72,%edi
jmp    1147 <print_string_char+0x17>

LLVM IR (-O0):
define void @print_string_char(i8 signext %0, i32* %1) {
%3 = alloca i8
%4 = alloca i32*
store i8 %0, i8* %3
store i32* %1, i32** %4
%5 = load i8, i8* %3
%6 = call i64 @isprint(i8 signext %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i8, i8* %3
%10 = load i32*, i32** %4
%11 = call i32 @fputc(i8 signext %9, i32* %10)
br label %36
12: ; preds = %2
%13 = load i32*, i32** %4
%14 = call i32 @fputc(i8 signext 92, i32* %13)
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
switch i32 %16, label %29 [
i32 10, label %17
i32 9, label %20
i32 7, label %23
i32 13, label %26
]
17: ; preds = %12
%18 = load i32*, i32** %4
%19 = call i32 @fputc(i8 signext 110, i32* %18)
br label %35
20: ; preds = %12
%21 = load i32*, i32** %4
%22 = call i32 @fputc(i8 signext 116, i32* %21)
br label %35
23: ; preds = %12
%24 = load i32*, i32** %4
%25 = call i32 @fputc(i8 signext 97, i32* %24)
br label %35
26: ; preds = %12
%27 = load i32*, i32** %4
%28 = call i32 @fputc(i8 signext 114, i32* %27)
br label %35
29: ; preds = %12
%30 = load i32*, i32** %4
%31 = call i32 @fputc(i8 signext 120, i32* %30)
%32 = load i8, i8* %3
%33 = load i32*, i32** %4
%34 = call i32 @print_hex(i8 signext %32, i32* %33)
br label %35
35: ; preds = %29, %26, %23, %20, %17
br label %36
36: ; preds = %35, %8
ret void
}

LLVM IR (-O2):
define void @print_string_char(i8 signext %0, i32* %1) {
%3 = tail call i64 @isprint(i8 signext %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @fputc(i8 signext %0, i32* %1)
br label %21
7: ; preds = %2
%8 = tail call i32 @fputc(i8 signext 92, i32* %1)
%9 = sext i8 %0 to i32
switch i32 %9, label %18 [
i32 10, label %10
i32 9, label %12
i32 7, label %14
i32 13, label %16
]
10: ; preds = %7
%11 = tail call i32 @fputc(i8 signext 110, i32* %1)
br label %21
12: ; preds = %7
%13 = tail call i32 @fputc(i8 signext 116, i32* %1)
br label %21
14: ; preds = %7
%15 = tail call i32 @fputc(i8 signext 97, i32* %1)
br label %21
16: ; preds = %7
%17 = tail call i32 @fputc(i8 signext 114, i32* %1)
br label %21
18: ; preds = %7
%19 = tail call i32 @fputc(i8 signext 120, i32* %1)
%20 = tail call i32 @print_hex(i8 signext %0, i32* %1)
br label %21
21: ; preds = %10, %12, %14, %16, %18, %5
ret void
}