#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(char, int);
int my_put_S(char *s) {
  int i = 0;
  while (s[i] != '\0') {
    if (s[i] < 31) {
      my_putchar(92);
      my_putchar(48);
      my_putnbr(s[i], 8);
    } else {
      my_putchar(s[i]);
    }
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<my_put_S>:
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     11ab <my_put_S+0x8b>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x1f,%eax
jge    118c <my_put_S+0x6c>
mov    $0x5c,%edi
call   1030 <my_putchar@plt>
mov    $0x30,%edi
call   1030 <my_putchar@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    $0x8,%esi
movsbl (%rax,%rcx,1),%edi
call   1040 <my_putnbr@plt>
jmp    119d <my_put_S+0x7d>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <my_putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <my_put_S+0x13>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_put_S>:
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     116b <my_put_S+0x4b>
mov    %rdi,%rbx
add    $0x1,%rbx
jmp    1143 <my_put_S+0x23>
movsbl %al,%edi
call   1030 <my_putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     116b <my_put_S+0x4b>
cmp    $0x1e,%al
jg     1130 <my_put_S+0x10>
mov    $0x5c,%edi
call   1030 <my_putchar@plt>
mov    $0x30,%edi
call   1030 <my_putchar@plt>
movsbl -0x1(%rbx),%edi
mov    $0x8,%esi
call   1040 <my_putnbr@plt>
jmp    1138 <my_put_S+0x18>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @my_put_S(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %36, %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 %39
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, 31
br i1 %19, label %20, label %29
20: ; preds = %12
%21 = call i32 @my_putchar(i8 signext 92)
%22 = call i32 @my_putchar(i8 signext 48)
%23 = load i8*, i8** %2
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = call i32 @my_putnbr(i8 signext %27, i32 8)
br label %36
29: ; preds = %12
%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 = call i32 @my_putchar(i8 signext %34)
br label %36
36: ; preds = %29, %20
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %4
39: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
define i32 @my_put_S(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %21, label %4
4: ; preds = %1, %16
%5 = phi i64 [ %17, %16 ], [ 0, %1 ]
%6 = phi i8 [ %19, %16 ], [ %2, %1 ]
%7 = phi i8* [ %18, %16 ], [ %0, %1 ]
%8 = icmp slt i8 %6, 31
br i1 %8, label %9, label %14
9: ; preds = %4
%10 = tail call i32 @my_putchar(i8 signext 92)
%11 = tail call i32 @my_putchar(i8 signext 48)
%12 = load i8, i8* %7
%13 = tail call i32 @my_putnbr(i8 signext %12, i32 8)
br label %16
14: ; preds = %4
%15 = tail call i32 @my_putchar(i8 signext %6)
br label %16
16: ; preds = %14, %9
%17 = add nuw i64 %5, 1
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %4
21: ; preds = %16, %1
ret i32 0
}