#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char EOF;
int /*<<< orphan*/ SEEK_CUR;
int abs(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int /*<<< orphan*/ print_to(int, char);
int /*<<< orphan*/ printf(char *, char *);
void tobf_f(char *s) {
  FILE *p = fopen(s, "rb");
  if (p == NULL)
    printf("can not open file : %s", s);
  else {
    int count = 0;
    char toc = 'A';
    for (;; count++) {
      toc = fgetc(p);
      if (toc == EOF)
        break;
      char ch = '+';
      int cha = toc;
      if (count > 0) {
        fseek(p, -2L, SEEK_CUR);
        char toc_p = fgetc(p);
        fseek(p, 1L, SEEK_CUR);
        cha = toc - toc_p;
        if (cha > 0)
          ch = '+';
        else if (cha < 0)
          ch = '-';
      }
      int zi = abs(cha);
      print_to(zi, ch);
    }
  }
  fclose(p);
}


x86 assembly (clang, -O0):
<tobf_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b0 <tobf_f+0x40>
mov    -0x8(%rbp),%rsi
lea    0xe5d(%rip),%rdi
call   1050 <printf@plt>
jmp    1295 <tobf_f+0x125>
movl   $0x0,-0x14(%rbp)
movb   $0x41,-0x15(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
mov    0x2e0e(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11e2 <tobf_f+0x72>
jmp    1290 <tobf_f+0x120>
movb   $0x2b,-0x16(%rbp)
movsbl -0x15(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    126b <tobf_f+0xfb>
mov    -0x10(%rbp),%rdi
mov    0x2de6(%rip),%rax
mov    (%rax),%edx
mov    $0xfffffffffffffffe,%rsi
call   1080 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x1d(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2dc1(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%esi
call   1080 <fseek@plt>
movsbl -0x15(%rbp),%eax
movsbl -0x1d(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1253 <tobf_f+0xe3>
movb   $0x2b,-0x16(%rbp)
jmp    1266 <tobf_f+0xf6>
cmpl   $0x0,-0x1c(%rbp)
jge    1261 <tobf_f+0xf1>
movb   $0x2d,-0x16(%rbp)
jmp    1266 <tobf_f+0xf6>
jmp    126b <tobf_f+0xfb>
mov    -0x1c(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
movsbl -0x16(%rbp),%esi
call   1070 <print_to@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bb <tobf_f+0x4b>
jmp    1295 <tobf_f+0x125>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tobf_f>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
lea    0xe8e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
je     122b <tobf_f+0xcb>
mov    %r15,%rdi
call   1050 <fgetc@plt>
mov    0x2e4e(%rip),%r14
cmp    (%r14),%al
je     123a <tobf_f+0xda>
mov    %eax,%ecx
sar    $0x7,%cl
add    %cl,%al
xor    %cl,%al
movzbl %al,%edi
mov    $0x2b,%esi
call   1060 <print_to@plt>
mov    %r15,%rdi
call   1050 <fgetc@plt>
cmp    (%r14),%al
je     123a <tobf_f+0xda>
mov    0x2e23(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%ebx
mov    (%r12),%edx
mov    %r15,%rdi
mov    $0xfffffffffffffffe,%rsi
call   1070 <fseek@plt>
mov    %r15,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebp
mov    (%r12),%edx
mov    $0x1,%esi
mov    %r15,%rdi
call   1070 <fseek@plt>
movsbl %bpl,%eax
sub    %eax,%ebx
mov    %ebx,%edi
neg    %edi
cmovs  %ebx,%edi
shr    $0x1f,%ebx
lea    (%rbx,%rbx,1),%esi
add    $0x2b,%esi
call   1060 <print_to@plt>
mov    %r15,%rdi
call   1050 <fgetc@plt>
cmp    (%r14),%al
jne    11d0 <tobf_f+0x70>
jmp    123a <tobf_f+0xda>
lea    0xdd1(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [23 x i8] c"can not open file : %s\00"
@EOF = global i8 0
@SEEK_CUR = global i32 0
define void @tobf_f(i8* %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = tail call signext i8 @fgetc(i32* %2)
%6 = load i8, i8* @EOF
%7 = icmp eq i8 %5, %6
br i1 %7, label %34, label %8
8: ; preds = %4
%9 = call i8 @llvm.abs.i8(i8 %5, i1 false)
%10 = zext i8 %9 to i32
%11 = tail call i32 @print_to(i32 %10, i8 signext 43)
%12 = tail call signext i8 @fgetc(i32* %2)
%13 = load i8, i8* @EOF
%14 = icmp eq i8 %12, %13
br i1 %14, label %34, label %17
15: ; preds = %1
%16 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %34
17: ; preds = %8, %17
%18 = phi i8 [ %31, %17 ], [ %12, %8 ]
%19 = sext i8 %18 to i32
%20 = load i32, i32* @SEEK_CUR
%21 = tail call i32 @fseek(i32* %2, i64 -2, i32 %20)
%22 = tail call signext i8 @fgetc(i32* %2)
%23 = load i32, i32* @SEEK_CUR
%24 = tail call i32 @fseek(i32* %2, i64 1, i32 %23)
%25 = sext i8 %22 to i32
%26 = sub nsw i32 %19, %25
%27 = icmp slt i32 %26, 0
%28 = select i1 %27, i8 45, i8 43
%29 = tail call i32 @llvm.abs.i32(i32 %26, i1 true)
%30 = tail call i32 @print_to(i32 %29, i8 signext %28)
%31 = tail call signext i8 @fgetc(i32* %2)
%32 = load i8, i8* @EOF
%33 = icmp eq i8 %31, %32
br i1 %33, label %34, label %17
34: ; preds = %17, %8, %4, %15
%35 = tail call i32 @fclose(i32* %2)
ret void
}