#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 lzss_io {
  int dummy;
};
struct lzss {
  int dummy;
};

/* Variables and functions */
scalar_t__ putbit0(struct lzss *, struct lzss_io *);
scalar_t__ putbit1(struct lzss *, struct lzss_io *);
int output_word(struct lzss *lzss, struct lzss_io *io, int mask, int byte) {
  while (mask >>= 1) {
    if (byte & mask) {
      if (putbit1(lzss, io))
        return -1;
    } else {
      if (putbit0(lzss, io))
        return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<output_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
je     11ac <output_word+0x8c>
mov    -0x20(%rbp),%eax
and    -0x1c(%rbp),%eax
cmp    $0x0,%eax
je     117f <output_word+0x5f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <putbit1@plt>
cmp    $0x0,%rax
je     117a <output_word+0x5a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b3 <output_word+0x93>
jmp    11a7 <output_word+0x87>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <putbit0@plt>
cmp    $0x0,%rax
je     11a2 <output_word+0x82>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b3 <output_word+0x93>
jmp    11a7 <output_word+0x87>
jmp    1136 <output_word+0x16>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_word>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r14d,%r14d
cmp    $0x2,%edx
jb     117e <output_word+0x5e>
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %rsi,%r12
mov    %rdi,%r13
mov    %edx,%ebx
jmp    1161 <output_word+0x41>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1040 <putbit0@plt>
test   %rax,%rax
jne    1178 <output_word+0x58>
cmp    $0x3,%ebp
mov    %ebx,%ebp
jbe    117e <output_word+0x5e>
sar    %ebx
mov    %r13,%rdi
mov    %r12,%rsi
test   %r15d,%ebx
je     1150 <output_word+0x30>
call   1030 <putbit1@plt>
test   %rax,%rax
je     115a <output_word+0x3a>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.lzss = type { i32 }
%struct.lzss_io = type { i32 }
define i32 @output_word(%struct.lzss* %0, %struct.lzss_io* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca %struct.lzss*
%7 = alloca %struct.lzss_io*
%8 = alloca i32
%9 = alloca i32
store %struct.lzss* %0, %struct.lzss** %6
store %struct.lzss_io* %1, %struct.lzss_io** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
br label %10
10: ; preds = %33, %4
%11 = load i32, i32* %8
%12 = ashr i32 %11, 1
store i32 %12, i32* %8
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %34
14: ; preds = %10
%15 = load i32, i32* %9
%16 = load i32, i32* %8
%17 = and i32 %15, %16
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %14
%20 = load %struct.lzss*, %struct.lzss** %6
%21 = load %struct.lzss_io*, %struct.lzss_io** %7
%22 = call i64 @putbit1(%struct.lzss* %20, %struct.lzss_io* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19
store i32 -1, i32* %5
br label %35
25: ; preds = %19
br label %33
26: ; preds = %14
%27 = load %struct.lzss*, %struct.lzss** %6
%28 = load %struct.lzss_io*, %struct.lzss_io** %7
%29 = call i64 @putbit0(%struct.lzss* %27, %struct.lzss_io* %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %26
store i32 -1, i32* %5
br label %35
32: ; preds = %26
br label %33
33: ; preds = %32, %25
br label %10
34: ; preds = %10
store i32 0, i32* %5
br label %35
35: ; preds = %34, %31, %24
%36 = load i32, i32* %5
ret i32 %36
}

LLVM IR (-O2):
%struct.lzss = type { i32 }
%struct.lzss_io = type { i32 }
define i32 @output_word(%struct.lzss* %0, %struct.lzss_io* %1, i32 %2, i32 %3) {
%5 = icmp ult i32 %2, 2
br i1 %5, label %19, label %6
6: ; preds = %4, %17
%7 = phi i32 [ %8, %17 ], [ %2, %4 ]
%8 = ashr i32 %7, 1
%9 = and i32 %8, %3
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = tail call i64 @putbit1(%struct.lzss* %0, %struct.lzss_io* %1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %19
14: ; preds = %6
%15 = tail call i64 @putbit0(%struct.lzss* %0, %struct.lzss_io* %1)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14, %11
%18 = icmp ult i32 %7, 4
br i1 %18, label %19, label %6
19: ; preds = %11, %14, %17, %4
%20 = phi i32 [ 0, %4 ], [ 0, %17 ], [ -1, %14 ], [ -1, %11 ]
ret i32 %20
}