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

/* Variables and functions */
scalar_t__ isascii(char const);
scalar_t__ isgraph(char const);
int /*<<< orphan*/ snprintf(char *, int, char *, char const);
int /*<<< orphan*/ strlcat(char *, char *, int);
char *show_mb(const char *mb) {
  static char buf[64];
  if (isascii(*mb) && isgraph(*mb)) {
    buf[0] = *mb;
    buf[1] = 0;
    return (buf);
  }
  buf[0] = 0;
  while (*mb != 0) {
    char scr[8];
    (void)snprintf(scr, sizeof(scr), "\\x%02x", *mb);
    (void)strlcat(buf, scr, sizeof(buf));
    mb++;
  }
  return (buf);
}


x86 assembly (clang, -O0):
<show_mb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isascii@plt>
cmp    $0x0,%rax
je     119b <show_mb+0x5b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isgraph@plt>
cmp    $0x0,%rax
je     119b <show_mb+0x5b>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,0x2ecc(%rip)
movb   $0x0,0x2ec6(%rip)
lea    0x2ebe(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11ff <show_mb+0xbf>
movb   $0x0,0x2eae(%rip)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11f4 <show_mb+0xb4>
lea    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    $0x8,%esi
lea    0xe3a(%rip),%rdx
movsbl (%rax),%ecx
call   1040 <snprintf@plt>
lea    -0x18(%rbp),%rsi
lea    0x2e77(%rip),%rdi
mov    $0x40,%edx
call   1030 <strlcat@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11a2 <show_mb+0x62>
lea    0x2e55(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_mb>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1050 <isascii@plt>
test   %rax,%rax
je     1176 <show_mb+0x36>
movsbl (%rbx),%edi
call   1060 <isgraph@plt>
test   %rax,%rax
je     1176 <show_mb+0x36>
mov    (%rbx),%al
mov    %al,0x2ee3(%rip)
movb   $0x0,0x2edd(%rip)
jmp    11ce <show_mb+0x8e>
movb   $0x0,0x2ed3(%rip)
mov    (%rbx),%al
test   %al,%al
je     11ce <show_mb+0x8e>
add    $0x1,%rbx
lea    0xe72(%rip),%r14
mov    %rsp,%r15
lea    0x2eb8(%rip),%r12
nopl   0x0(%rax,%rax,1)
movsbl %al,%ecx
mov    %r15,%rdi
mov    $0x8,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x40,%edx
call   1030 <strlcat@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    11a0 <show_mb+0x60>
lea    0x2e7b(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@show_mb.buf = internal global [64 x i8] zeroinitializer
@.str = [7 x i8] c"\\x%02x\00"
define i8* @show_mb(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [8 x i8]
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = call i64 @isascii(i8 signext %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = call i64 @isgraph(i8 signext %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
store i8 %16, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @show_mb.buf, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @show_mb.buf, i64 0, i64 1)
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @show_mb.buf, i64 0, i64 0), i8** %2
br label %33
17: ; preds = %9, %1
store i8 0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @show_mb.buf, i64 0, i64 0)
br label %18
18: ; preds = %23, %17
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %18
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = call i32 @snprintf(i8* %24, i32 8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %26)
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%29 = call i32 @strlcat(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @show_mb.buf, i64 0, i64 0), i8* %28, i32 64)
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %3
br label %18
32: ; preds = %18
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @show_mb.buf, i64 0, i64 0), i8** %2
br label %33
33: ; preds = %32, %14
%34 = load i8*, i8** %2
ret i8* %34
}

LLVM IR (-O2):
@show_mb.buf = internal global [64 x i8] zeroinitializer
@.str = [7 x i8] c"\\x%02x\00"
define i8* @show_mb(i8* nocapture %0) {
%2 = alloca [8 x i8]
%3 = load i8, i8* %0
%4 = tail call i64 @isascii(i8 signext %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %1
%7 = load i8, i8* %0
%8 = tail call i64 @isgraph(i8 signext %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = load i8, i8* %0
store i8 %11, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @show_mb.buf, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @show_mb.buf, i64 0, i64 1)
br label %25
12: ; preds = %6, %1
store i8 0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @show_mb.buf, i64 0, i64 0)
%13 = load i8, i8* %0
%14 = icmp eq i8 %13, 0
br i1 %14, label %25, label %15
15: ; preds = %12
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
br label %17
17: ; preds = %15, %17
%18 = phi i8 [ %13, %15 ], [ %23, %17 ]
%19 = phi i8* [ %0, %15 ], [ %22, %17 ]
%20 = call i32 @snprintf(i8* %16, i32 8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %18)
%21 = call i32 @strlcat(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @show_mb.buf, i64 0, i64 0), i8* %16, i32 64)
%22 = getelementptr inbounds i8, i8* %19, i64 1
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %17
25: ; preds = %17, %12, %10
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @show_mb.buf, i64 0, i64 0)
}