#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 */
struct ascii85 {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ascii85_encode(struct ascii85 *, unsigned char);
void _ascii85_write_spaces(struct ascii85 *ascii85_p, unsigned int z) {
  if (z) {
    if (z > 3) {
      ascii85_encode(ascii85_p, 0xFF);
      ascii85_encode(ascii85_p, (unsigned char)((z >> 8) & 0xFF));
      ascii85_encode(ascii85_p, (unsigned char)(z & 0xFF));
    } else {
      while (z--) {
        ascii85_encode(ascii85_p, (unsigned char)0);
      }
    }
  }
}


x86 assembly (clang, -O0):
<_ascii85_write_spaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11a4 <_ascii85_write_spaces+0x94>
cmpl   $0x3,-0xc(%rbp)
jbe    1171 <_ascii85_write_spaces+0x61>
mov    -0x8(%rbp),%rdi
mov    $0xff,%esi
call   1030 <ascii85_encode@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
movzbl %al,%esi
call   1030 <ascii85_encode@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
and    $0xff,%eax
movzbl %al,%esi
call   1030 <ascii85_encode@plt>
jmp    119f <_ascii85_write_spaces+0x8f>
jmp    1176 <_ascii85_write_spaces+0x66>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     119a <_ascii85_write_spaces+0x8a>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1030 <ascii85_encode@plt>
jmp    1176 <_ascii85_write_spaces+0x66>
jmp    119f <_ascii85_write_spaces+0x8f>
jmp    11a4 <_ascii85_write_spaces+0x94>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ascii85_write_spaces>:
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
je     115f <_ascii85_write_spaces+0x4f>
mov    %esi,%ebx
mov    %rdi,%r14
cmp    $0x3,%esi
jbe    1150 <_ascii85_write_spaces+0x40>
mov    %r14,%rdi
mov    $0xff,%esi
call   1030 <ascii85_encode@plt>
movzbl %bh,%esi
mov    %r14,%rdi
call   1030 <ascii85_encode@plt>
movzbl %bl,%esi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <ascii85_encode@plt>
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <ascii85_encode@plt>
add    $0xffffffff,%ebx
jne    1150 <_ascii85_write_spaces+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.ascii85 = type { i32 }
define void @_ascii85_write_spaces(%struct.ascii85* %0, i32 %1) {
%3 = alloca %struct.ascii85*
%4 = alloca i32
store %struct.ascii85* %0, %struct.ascii85** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %34
7: ; preds = %2
%8 = load i32, i32* %4
%9 = icmp ugt i32 %8, 3
br i1 %9, label %10, label %24
10: ; preds = %7
%11 = load %struct.ascii85*, %struct.ascii85** %3
%12 = call i32 @ascii85_encode(%struct.ascii85* %11, i8 zeroext -1)
%13 = load %struct.ascii85*, %struct.ascii85** %3
%14 = load i32, i32* %4
%15 = lshr i32 %14, 8
%16 = and i32 %15, 255
%17 = trunc i32 %16 to i8
%18 = call i32 @ascii85_encode(%struct.ascii85* %13, i8 zeroext %17)
%19 = load %struct.ascii85*, %struct.ascii85** %3
%20 = load i32, i32* %4
%21 = and i32 %20, 255
%22 = trunc i32 %21 to i8
%23 = call i32 @ascii85_encode(%struct.ascii85* %19, i8 zeroext %22)
br label %33
24: ; preds = %7
br label %25
25: ; preds = %29, %24
%26 = load i32, i32* %4
%27 = add i32 %26, -1
store i32 %27, i32* %4
%28 = icmp ne i32 %26, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load %struct.ascii85*, %struct.ascii85** %3
%31 = call i32 @ascii85_encode(%struct.ascii85* %30, i8 zeroext 0)
br label %25
32: ; preds = %25
br label %33
33: ; preds = %32, %10
br label %34
34: ; preds = %33, %2
ret void
}

LLVM IR (-O2):
%struct.ascii85 = type { i32 }
define void @_ascii85_write_spaces(%struct.ascii85* %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %18, label %4
4: ; preds = %2
%5 = icmp ugt i32 %1, 3
br i1 %5, label %6, label %13
6: ; preds = %4
%7 = tail call i32 @ascii85_encode(%struct.ascii85* %0, i8 zeroext -1)
%8 = lshr i32 %1, 8
%9 = trunc i32 %8 to i8
%10 = tail call i32 @ascii85_encode(%struct.ascii85* %0, i8 zeroext %9)
%11 = trunc i32 %1 to i8
%12 = tail call i32 @ascii85_encode(%struct.ascii85* %0, i8 zeroext %11)
br label %18
13: ; preds = %4, %13
%14 = phi i32 [ %15, %13 ], [ %1, %4 ]
%15 = add i32 %14, -1
%16 = tail call i32 @ascii85_encode(%struct.ascii85* %0, i8 zeroext 0)
%17 = icmp eq i32 %15, 0
br i1 %17, label %18, label %13
18: ; preds = %13, %6, %2
ret void
}