#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 abs(int);
int /*<<< orphan*/ print_to(int, char);
int /*<<< orphan*/ printf(char *);
int strlen(char const *);
void tobf_s(const char *S) {
  int len = strlen(S);
  for (int i = 0; i < len; ++i) {
    char ch = '+';
    int cha = S[i];
    if (i > 0) {
      cha = S[i] - S[i - 1];
      if (cha > 0)
        ch = '+';
      else if (cha < 0)
        ch = '-';
      else
        printf(".");
    }
    int zi = abs(cha);
    print_to(zi, ch);
  }
}


x86 assembly (clang, -O0):
<tobf_s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120b <tobf_s+0xcb>
movb   $0x2b,-0x11(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    11e6 <tobf_s+0xa6>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    11bd <tobf_s+0x7d>
movb   $0x2b,-0x11(%rbp)
jmp    11e1 <tobf_s+0xa1>
cmpl   $0x0,-0x18(%rbp)
jge    11d0 <tobf_s+0x90>
movb   $0x2d,-0x11(%rbp)
jmp    11dc <tobf_s+0x9c>
lea    0xe29(%rip),%rdi
call   1050 <printf@plt>
jmp    11e1 <tobf_s+0xa1>
jmp    11e6 <tobf_s+0xa6>
mov    -0x18(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
movsbl -0x11(%rbp),%esi
call   1060 <print_to@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115f <tobf_s+0x1f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tobf_s>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
call   1040 <strlen@plt>
test   %eax,%eax
jle    1164 <tobf_s+0x34>
mov    %eax,%ebp
mov    (%r15),%al
mov    %eax,%ecx
sar    $0x7,%cl
add    %cl,%al
xor    %cl,%al
movzbl %al,%edi
mov    $0x2b,%esi
call   1050 <print_to@plt>
cmp    $0x1,%ebp
jne    116d <tobf_s+0x3d>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%r14d
add    $0xffffffffffffffff,%r14
xor    %ebp,%ebp
jmp    11a3 <tobf_s+0x73>
nopl   0x0(%rax,%rax,1)
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
neg    %edi
cmovs  %ebx,%edi
movzbl %r12b,%esi
call   1050 <print_to@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
je     1164 <tobf_s+0x34>
movsbl 0x1(%r15,%rbp,1),%ebx
mov    %ebp,%eax
movsbl (%r15,%rax,1),%eax
mov    $0x2b,%r12b
sub    %eax,%ebx
jg     118a <tobf_s+0x5a>
jns    1180 <tobf_s+0x50>
mov    $0x2d,%r12b
jmp    118a <tobf_s+0x5a>

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

LLVM IR (-O2):
define void @tobf_s(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %11
4: ; preds = %1
%5 = zext i32 %2 to i64
%6 = load i8, i8* %0
%7 = call i8 @llvm.abs.i8(i8 %6, i1 false)
%8 = zext i8 %7 to i32
%9 = tail call i32 @print_to(i32 %8, i8 signext 43)
%10 = icmp eq i32 %2, 1
br i1 %10, label %11, label %12
11: ; preds = %28, %4, %1
ret void
12: ; preds = %4, %28
%13 = phi i64 [ %32, %28 ], [ 1, %4 ]
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = add nuw i64 %13, 4294967295
%18 = and i64 %17, 4294967295
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = sub nsw i32 %16, %21
%23 = icmp sgt i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %12
%25 = icmp slt i32 %22, 0
br i1 %25, label %28, label %26
26: ; preds = %24
%27 = tail call i32 @putchar(i32 46)
br label %28
28: ; preds = %24, %12, %26
%29 = phi i8 [ 43, %26 ], [ 43, %12 ], [ 45, %24 ]
%30 = tail call i32 @llvm.abs.i32(i32 %22, i1 true)
%31 = tail call i32 @print_to(i32 %30, i8 signext %29)
%32 = add nuw nsw i64 %13, 1
%33 = icmp eq i64 %32, %5
br i1 %33, label %11, label %12
}