#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 */
scalar_t__ a85finish(int /*<<< orphan*/ *);
scalar_t__ a85init(int /*<<< orphan*/ *);
scalar_t__ a85write(int /*<<< orphan*/ *, char *, int);
scalar_t__ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int a85_xship(FILE *f, int filter, char *s, int len) {
  static int fstate = 0;
  int n = 0;
  if (filter && !fstate) {
    if (filter == 1) {
      n += fprintf(f, "currentfile /ASCII85Decode filter cvx exec\n");
    }
    n += a85init(f);
    fstate = 1;
  } else if (!filter && fstate) {
    n += a85finish(f);
    fstate = 0;
  }
  if (!fstate) {
    fwrite(s, 1, len, f);
    return n + len;
  }
  n += a85write(f, s, len);
  return n;
}


x86 assembly (clang, -O0):
<a85_xship>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11d0 <a85_xship+0x80>
cmpl   $0x0,0x2ece(%rip)
jne    11d0 <a85_xship+0x80>
cmpl   $0x1,-0x14(%rbp)
jne    11ab <a85_xship+0x5b>
mov    -0x10(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1050 <fprintf@plt>
mov    %rax,%rcx
movslq -0x28(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <a85init@plt>
mov    %rax,%rcx
movslq -0x28(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x28(%rbp)
movl   $0x1,0x2e81(%rip)
jmp    120c <a85_xship+0xbc>
cmpl   $0x0,-0x14(%rbp)
jne    1207 <a85_xship+0xb7>
cmpl   $0x0,0x2e6b(%rip)
je     1207 <a85_xship+0xb7>
mov    -0x10(%rbp),%rdi
call   1030 <a85finish@plt>
mov    %rax,%rcx
movslq -0x28(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x28(%rbp)
movl   $0x0,0x2e45(%rip)
jmp    120c <a85_xship+0xbc>
cmpl   $0x0,0x2e39(%rip)
jne    123c <a85_xship+0xec>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1070 <fwrite@plt>
mov    -0x28(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    125f <a85_xship+0x10f>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1040 <a85write@plt>
mov    %rax,%rcx
movslq -0x28(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<a85_xship>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %ecx,%r12d
mov    %rdx,%r15
mov    %rdi,%r14
mov    0x2ee4(%rip),%al
test   %esi,%esi
je     1189 <a85_xship+0x39>
test   $0x1,%al
jne    1189 <a85_xship+0x39>
cmp    $0x1,%esi
jne    11a9 <a85_xship+0x59>
lea    0xe84(%rip),%rsi
mov    %r14,%rdi
call   1050 <fprintf@plt>
movslq %eax,%r13
jmp    11ac <a85_xship+0x5c>
test   %esi,%esi
sete   %cl
and    %al,%cl
cmp    $0x1,%cl
jne    11c3 <a85_xship+0x73>
mov    %r14,%rdi
call   1030 <a85finish@plt>
mov    %rax,%rbx
movb   $0x0,0x2ea5(%rip)
jmp    11dc <a85_xship+0x8c>
xor    %r13d,%r13d
mov    %r14,%rdi
call   1060 <a85init@plt>
mov    %rax,%rbx
add    %r13d,%ebx
movb   $0x1,0x2e8b(%rip)
jmp    11c9 <a85_xship+0x79>
xor    %ebx,%ebx
test   $0x1,%al
je     11dc <a85_xship+0x8c>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1040 <a85write@plt>
mov    %rax,%r12
jmp    11ef <a85_xship+0x9f>
mov    %r15,%rdi
mov    $0x1,%esi
mov    %r12d,%edx
mov    %r14,%rcx
call   1070 <fwrite@plt>
add    %r12d,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@a85_xship.fstate = internal global i32 0
@.str = [44 x i8] c"currentfile /ASCII85Decode filter cvx exec\0A\00"
define i32 @a85_xship(i32* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 0, i32* %10
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %33
13: ; preds = %4
%14 = load i32, i32* @a85_xship.fstate
%15 = icmp ne i32 %14, 0
br i1 %15, label %33, label %16
16: ; preds = %13
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load i32*, i32** %6
%21 = call i64 @fprintf(i32* %20, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* %10
%23 = sext i32 %22 to i64
%24 = add nsw i64 %23, %21
%25 = trunc i64 %24 to i32
store i32 %25, i32* %10
br label %26
26: ; preds = %19, %16
%27 = load i32*, i32** %6
%28 = call i64 @a85init(i32* %27)
%29 = load i32, i32* %10
%30 = sext i32 %29 to i64
%31 = add nsw i64 %30, %28
%32 = trunc i64 %31 to i32
store i32 %32, i32* %10
store i32 1, i32* @a85_xship.fstate
br label %47
33: ; preds = %13, %4
%34 = load i32, i32* %7
%35 = icmp ne i32 %34, 0
br i1 %35, label %46, label %36
36: ; preds = %33
%37 = load i32, i32* @a85_xship.fstate
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %46
39: ; preds = %36
%40 = load i32*, i32** %6
%41 = call i64 @a85finish(i32* %40)
%42 = load i32, i32* %10
%43 = sext i32 %42 to i64
%44 = add nsw i64 %43, %41
%45 = trunc i64 %44 to i32
store i32 %45, i32* %10
store i32 0, i32* @a85_xship.fstate
br label %46
46: ; preds = %39, %36, %33
br label %47
47: ; preds = %46, %26
%48 = load i32, i32* @a85_xship.fstate
%49 = icmp ne i32 %48, 0
br i1 %49, label %58, label %50
50: ; preds = %47
%51 = load i8*, i8** %8
%52 = load i32, i32* %9
%53 = load i32*, i32** %6
%54 = call i32 @fwrite(i8* %51, i32 1, i32 %52, i32* %53)
%55 = load i32, i32* %10
%56 = load i32, i32* %9
%57 = add nsw i32 %55, %56
store i32 %57, i32* %5
br label %68
58: ; preds = %47
%59 = load i32*, i32** %6
%60 = load i8*, i8** %8
%61 = load i32, i32* %9
%62 = call i64 @a85write(i32* %59, i8* %60, i32 %61)
%63 = load i32, i32* %10
%64 = sext i32 %63 to i64
%65 = add nsw i64 %64, %62
%66 = trunc i64 %65 to i32
store i32 %66, i32* %10
%67 = load i32, i32* %10
store i32 %67, i32* %5
br label %68
68: ; preds = %58, %50
%69 = load i32, i32* %5
ret i32 %69
}

LLVM IR (-O2):
@a85_xship.fstate = internal unnamed_addr global i1 false
@.str = [44 x i8] c"currentfile /ASCII85Decode filter cvx exec\0A\00"
define i32 @a85_xship(i32* %0, i32 %1, i8* %2, i32 %3) {
%5 = icmp eq i32 %1, 0
%6 = load i1, i1* @a85_xship.fstate
%7 = select i1 %5, i1 true, i1 %6
br i1 %7, label %19, label %8
8: ; preds = %4
%9 = icmp eq i32 %1, 1
br i1 %9, label %10, label %14
10: ; preds = %8
%11 = tail call i64 @fprintf(i32* %0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%12 = shl i64 %11, 32
%13 = ashr exact i64 %12, 32
br label %14
14: ; preds = %8, %10
%15 = phi i64 [ %13, %10 ], [ 0, %8 ]
%16 = tail call i64 @a85init(i32* %0)
%17 = add nsw i64 %16, %15
%18 = trunc i64 %17 to i32
store i1 true, i1* @a85_xship.fstate
br label %28
19: ; preds = %4
%20 = select i1 %5, i1 %6, i1 false
br i1 %20, label %21, label %24
21: ; preds = %19
%22 = tail call i64 @a85finish(i32* %0)
%23 = trunc i64 %22 to i32
store i1 false, i1* @a85_xship.fstate
br label %25
24: ; preds = %19
br i1 %6, label %28, label %25
25: ; preds = %21, %24
%26 = phi i32 [ %23, %21 ], [ 0, %24 ]
%27 = tail call i32 @fwrite(i8* %2, i32 1, i32 %3, i32* %0)
br label %32
28: ; preds = %14, %24
%29 = phi i32 [ %18, %14 ], [ 0, %24 ]
%30 = tail call i64 @a85write(i32* %0, i8* %2, i32 %3)
%31 = trunc i64 %30 to i32
br label %32
32: ; preds = %28, %25
%33 = phi i32 [ %29, %28 ], [ %26, %25 ]
%34 = phi i32 [ %31, %28 ], [ %3, %25 ]
%35 = add i32 %34, %33
ret i32 %35
}