#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_putallchar(char *buff) {
  int i;
  if (buff == NULL)
    return (0);
  i = -1;
  while (buff[++i] != '\0') {
    if (buff[i] < 32 || buff[i] >= 127) {
      my_putchar('\\');
      my_putchar('0');
      my_putnbr_base(buff[i], "01234567");
    } else
      my_putchar(buff[i]);
  }
  return (1);
}


x86 assembly (clang, -O0):
<my_putallchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <my_putallchar+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11df <my_putallchar+0xbf>
movl   $0xffffffff,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11d8 <my_putallchar+0xb8>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     1191 <my_putallchar+0x71>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7f,%eax
jl     11c2 <my_putallchar+0xa2>
mov    $0x5c,%edi
call   1040 <my_putchar@plt>
mov    $0x30,%edi
call   1040 <my_putchar@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
lea    0xe4c(%rip),%rsi
movsbl (%rax,%rcx,1),%edi
call   1030 <my_putnbr_base@plt>
jmp    11d3 <my_putallchar+0xb3>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <my_putchar@plt>
jmp    114a <my_putallchar+0x2a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_putallchar>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     118d <my_putallchar+0x6d>
mov    %rdi,%rbx
mov    (%rdi),%al
mov    $0x1,%r14d
test   %al,%al
je     1190 <my_putallchar+0x70>
add    $0x1,%rbx
lea    0xebd(%rip),%rbp
jmp    1163 <my_putallchar+0x43>
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
call   1040 <my_putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1190 <my_putallchar+0x70>
lea    -0x7f(%rax),%ecx
cmp    $0xa0,%cl
ja     1150 <my_putallchar+0x30>
mov    $0x5c,%edi
call   1040 <my_putchar@plt>
mov    $0x30,%edi
call   1040 <my_putchar@plt>
movsbl -0x1(%rbx),%edi
mov    %rbp,%rsi
call   1030 <my_putnbr_base@plt>
jmp    1158 <my_putallchar+0x38>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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