#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 */
int EOF;
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
void decompress(FILE *in, FILE *out) {
  int input;
  int num;
  int i;
  while ((input = getc(in)) != EOF) {
    if (input & 0x80) {
      num = input & 0x7f;
      num = (num << 8) | getc(in);
      num = (num << 8) | getc(in);
      num = (num << 8) | getc(in);
      for (i = 0; i < num; i++)
        putc(0, out);
    } else {
      num = input & 0x7f;
      num = (num << 8) | getc(in);
      for (i = 0; i < num; i++)
        putc(getc(in), out);
    }
  }
}


x86 assembly (clang, -O0):
<decompress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2ea5(%rip),%rcx
cmp    (%rcx),%eax
je     124e <decompress+0x12e>
mov    -0x14(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     11ea <decompress+0xca>
mov    -0x14(%rbp),%eax
and    $0x7f,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11e5 <decompress+0xc5>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1030 <putc@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c0 <decompress+0xa0>
jmp    1249 <decompress+0x129>
mov    -0x14(%rbp),%eax
and    $0x7f,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1244 <decompress+0x124>
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1216 <decompress+0xf6>
jmp    1249 <decompress+0x129>
jmp    1130 <decompress+0x10>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decompress>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
call   1040 <getc@plt>
mov    0x2eab(%rip),%r13
cmp    0x0(%r13),%eax
jne    1152 <decompress+0x32>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%r15d
jmp    1171 <decompress+0x51>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <getc@plt>
mov    %eax,%r15d
cmp    0x0(%r13),%eax
je     1143 <decompress+0x23>
mov    %r15d,%ebx
and    $0x7f,%ebx
shl    $0x8,%ebx
mov    %r14,%rdi
call   1040 <getc@plt>
mov    %eax,%ebp
or     %ebx,%ebp
test   $0x80,%r15b
jne    11b0 <decompress+0x90>
test   %ebp,%ebp
jle    1160 <decompress+0x40>
mov    %r14,%rdi
call   1040 <getc@plt>
mov    %eax,%edi
mov    %r12,%rsi
call   1030 <putc@plt>
add    $0xffffffff,%ebp
jne    1190 <decompress+0x70>
jmp    1160 <decompress+0x40>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <getc@plt>
mov    %eax,%r15d
shl    $0x10,%ebp
shl    $0x8,%r15d
mov    %r14,%rdi
call   1040 <getc@plt>
mov    %eax,%ebx
or     %r15d,%ebx
or     %ebp,%ebx
jle    1160 <decompress+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edi,%edi
mov    %r12,%rsi
call   1030 <putc@plt>
add    $0xffffffff,%ebx
jne    11e0 <decompress+0xc0>
jmp    1160 <decompress+0x40>

LLVM IR (-O0):
@EOF = global i32 0
define void @decompress(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
br label %8
8: ; preds = %67, %2
%9 = load i32*, i32** %3
%10 = call i32 @getc(i32* %9)
store i32 %10, i32* %5
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %68
13: ; preds = %8
%14 = load i32, i32* %5
%15 = and i32 %14, 128
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %46
17: ; preds = %13
%18 = load i32, i32* %5
%19 = and i32 %18, 127
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = shl i32 %20, 8
%22 = load i32*, i32** %3
%23 = call i32 @getc(i32* %22)
%24 = or i32 %21, %23
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = shl i32 %25, 8
%27 = load i32*, i32** %3
%28 = call i32 @getc(i32* %27)
%29 = or i32 %26, %28
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = shl i32 %30, 8
%32 = load i32*, i32** %3
%33 = call i32 @getc(i32* %32)
%34 = or i32 %31, %33
store i32 %34, i32* %6
store i32 0, i32* %7
br label %35
35: ; preds = %42, %17
%36 = load i32, i32* %7
%37 = load i32, i32* %6
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %45
39: ; preds = %35
%40 = load i32*, i32** %4
%41 = call i32 @putc(i32 0, i32* %40)
br label %42
42: ; preds = %39
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %35
45: ; preds = %35
br label %67
46: ; preds = %13
%47 = load i32, i32* %5
%48 = and i32 %47, 127
store i32 %48, i32* %6
%49 = load i32, i32* %6
%50 = shl i32 %49, 8
%51 = load i32*, i32** %3
%52 = call i32 @getc(i32* %51)
%53 = or i32 %50, %52
store i32 %53, i32* %6
store i32 0, i32* %7
br label %54
54: ; preds = %63, %46
%55 = load i32, i32* %7
%56 = load i32, i32* %6
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %66
58: ; preds = %54
%59 = load i32*, i32** %3
%60 = call i32 @getc(i32* %59)
%61 = load i32*, i32** %4
%62 = call i32 @putc(i32 %60, i32* %61)
br label %63
63: ; preds = %58
%64 = load i32, i32* %7
%65 = add nsw i32 %64, 1
store i32 %65, i32* %7
br label %54
66: ; preds = %54
br label %67
67: ; preds = %66, %45
br label %8
68: ; preds = %8
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @decompress(i32* nocapture %0, i32* nocapture %1) {
%3 = tail call i32 @getc(i32* %0)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %39, label %6
6: ; preds = %2, %35
%7 = phi i32 [ %36, %35 ], [ %3, %2 ]
%8 = and i32 %7, 128
%9 = icmp eq i32 %8, 0
%10 = shl i32 %7, 8
%11 = and i32 %10, 32512
%12 = tail call i32 @getc(i32* %0)
%13 = or i32 %12, %11
br i1 %9, label %27, label %14
14: ; preds = %6
%15 = tail call i32 @getc(i32* %0)
%16 = shl i32 %13, 16
%17 = shl i32 %15, 8
%18 = or i32 %16, %17
%19 = tail call i32 @getc(i32* %0)
%20 = or i32 %18, %19
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %35
22: ; preds = %14, %22
%23 = phi i32 [ %25, %22 ], [ 0, %14 ]
%24 = tail call i32 @putc(i32 0, i32* %1)
%25 = add nuw nsw i32 %23, 1
%26 = icmp eq i32 %25, %20
br i1 %26, label %35, label %22
27: ; preds = %6
%28 = icmp sgt i32 %13, 0
br i1 %28, label %29, label %35
29: ; preds = %27, %29
%30 = phi i32 [ %33, %29 ], [ 0, %27 ]
%31 = tail call i32 @getc(i32* %0)
%32 = tail call i32 @putc(i32 %31, i32* %1)
%33 = add nuw nsw i32 %30, 1
%34 = icmp eq i32 %33, %13
br i1 %34, label %35, label %29
35: ; preds = %22, %29, %14, %27
%36 = tail call i32 @getc(i32* %0)
%37 = load i32, i32* @EOF
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %6
39: ; preds = %35, %2
ret void
}