#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*/ my_putchar(char);
int /*<<< orphan*/ my_putnbr_base(char, char *);
int my_showstr(char *str) {
  int i;
  i = 0;
  while (str[i] != '\0') {
    if (str[i] < 32 || str[i] > 126) {
      my_putchar('\\');
      if (str[i] < 14)
        my_putchar('0');
      my_putnbr_base(str[i], "0123456789abcdef");
    } else {
      my_putchar(str[i]);
    }
    i++;
  }
  return (0);
}


x86 assembly (clang, -O0):
<my_showstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11d7 <my_showstr+0xb7>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     1172 <my_showstr+0x52>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jle    11b8 <my_showstr+0x98>
mov    $0x5c,%edi
call   1040 <my_putchar@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xe,%eax
jge    119b <my_showstr+0x7b>
mov    $0x30,%edi
call   1040 <my_putchar@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
lea    0xe56(%rip),%rsi
movsbl (%rax,%rcx,1),%edi
call   1030 <my_putnbr_base@plt>
jmp    11c9 <my_showstr+0xa9>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <my_putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <my_showstr+0x13>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_showstr>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     1187 <my_showstr+0x67>
mov    %rdi,%rbx
lea    0xecc(%rip),%r14
jmp    1154 <my_showstr+0x34>
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%edi
call   1040 <my_putchar@plt>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1187 <my_showstr+0x67>
lea    -0x7f(%rax),%ecx
cmp    $0xa0,%cl
ja     1140 <my_showstr+0x20>
mov    $0x5c,%edi
call   1040 <my_putchar@plt>
movzbl (%rbx),%eax
cmp    $0xd,%al
jg     117a <my_showstr+0x5a>
mov    $0x30,%edi
call   1040 <my_putchar@plt>
movzbl (%rbx),%eax
movsbl %al,%edi
mov    %r14,%rsi
call   1030 <my_putnbr_base@plt>
jmp    1148 <my_showstr+0x28>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [17 x i8] c"0123456789abcdef\00"
define i32 @my_showstr(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %27, label %4
4: ; preds = %1, %22
%5 = phi i64 [ %23, %22 ], [ 0, %1 ]
%6 = phi i8 [ %25, %22 ], [ %2, %1 ]
%7 = phi i8* [ %24, %22 ], [ %0, %1 ]
%8 = add i8 %6, -127
%9 = icmp ult i8 %8, -95
br i1 %9, label %10, label %20
10: ; preds = %4
%11 = tail call i32 @my_putchar(i8 signext 92)
%12 = load i8, i8* %7
%13 = icmp slt i8 %12, 14
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = tail call i32 @my_putchar(i8 signext 48)
%16 = load i8, i8* %7
br label %17
17: ; preds = %14, %10
%18 = phi i8 [ %16, %14 ], [ %12, %10 ]
%19 = tail call i32 @my_putnbr_base(i8 signext %18, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %22
20: ; preds = %4
%21 = tail call i32 @my_putchar(i8 signext %6)
br label %22
22: ; preds = %20, %17
%23 = add nuw i64 %5, 1
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %4
27: ; preds = %22, %1
ret i32 0
}