#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;
  for (i = 0; str[i]; i++) {
    if (str[i] < 32 || str[i] > 126) {
      my_putchar('\\');
      if (str[i] <= 16)
        my_putchar('0');
      my_putnbr_base(str[i], "0123456789abcdef");
    } else
      my_putchar(str[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
cmpb   $0x0,(%rax,%rcx,1)
je     11d9 <my_showstr+0xb9>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     116f <my_showstr+0x4f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jle    11b5 <my_showstr+0x95>
mov    $0x5c,%edi
call   1040 <my_putchar@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x10,%eax
jg     1198 <my_showstr+0x78>
mov    $0x30,%edi
call   1040 <my_putchar@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
lea    0xe59(%rip),%rsi
movsbl (%rax,%rcx,1),%edi
call   1030 <my_putnbr_base@plt>
jmp    11c6 <my_showstr+0xa6>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <my_putchar@plt>
jmp    11cb <my_showstr+0xab>
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    $0x10,%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 = icmp ne i8 %9, 0
br i1 %10, label %11, label %56
11: ; preds = %4
%12 = load i8*, i8** %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp slt i32 %17, 32
br i1 %18, label %27, label %19
19: ; preds = %11
%20 = load i8*, i8** %2
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp sgt i32 %25, 126
br i1 %26, label %27, label %45
27: ; preds = %19, %11
%28 = call i32 @my_putchar(i8 signext 92)
%29 = load i8*, i8** %2
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp sle i32 %34, 16
br i1 %35, label %36, label %38
36: ; preds = %27
%37 = call i32 @my_putchar(i8 signext 48)
br label %38
38: ; preds = %36, %27
%39 = load i8*, i8** %2
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = call i32 @my_putnbr_base(i8 signext %43, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %52
45: ; preds = %19
%46 = load i8*, i8** %2
%47 = load i32, i32* %3
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = call i32 @my_putchar(i8 signext %50)
br label %52
52: ; preds = %45, %38
br label %53
53: ; preds = %52
%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, 17
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 = %17, %20
%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
}