#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 */

/* Variables and functions */
unsigned char input_huffman(unsigned char *);
int /*<<< orphan*/ qtree_copy(unsigned char *, int, int, unsigned char *, int);
void qtree_expand(unsigned char *infile, unsigned char a[], int nx, int ny,
                  unsigned char b[]) {
  int i;
  qtree_copy(a, nx, ny, b, ny);
  for (i = nx * ny - 1; i >= 0; i--) {
    if (b[i])
      b[i] = input_huffman(infile);
  }
}


x86 assembly (clang, -O0):
<qtree_expand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%r8d
call   1030 <qtree_copy@plt>
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     11a3 <qtree_expand+0x83>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1190 <qtree_expand+0x70>
mov    -0x8(%rbp),%rdi
call   1040 <input_huffman@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1195 <qtree_expand+0x75>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    115e <qtree_expand+0x3e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qtree_expand>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%r12
mov    %ecx,%ebp
mov    %edx,%r15d
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %edx,%esi
mov    %ecx,%edx
mov    %r8,%rcx
mov    %ebp,%r8d
call   1030 <qtree_copy@plt>
imul   %r15d,%ebp
test   %ebp,%ebp
jle    1182 <qtree_expand+0x62>
mov    %ebp,%ebp
add    $0x1,%rbp
jmp    116a <qtree_expand+0x4a>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%rbp
jbe    1182 <qtree_expand+0x62>
lea    -0x2(%rbp),%ebx
cmpb   $0x0,(%r12,%rbx,1)
je     1160 <qtree_expand+0x40>
mov    %r14,%rdi
call   1040 <input_huffman@plt>
mov    %al,(%r12,%rbx,1)
jmp    1160 <qtree_expand+0x40>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @qtree_expand(i8* %0, i8* %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%12 = load i8*, i8** %7
%13 = load i32, i32* %8
%14 = load i32, i32* %9
%15 = load i8*, i8** %10
%16 = load i32, i32* %9
%17 = call i32 @qtree_copy(i8* %12, i32 %13, i32 %14, i8* %15, i32 %16)
%18 = load i32, i32* %8
%19 = load i32, i32* %9
%20 = mul nsw i32 %18, %19
%21 = sub nsw i32 %20, 1
store i32 %21, i32* %11
br label %22
22: ; preds = %40, %5
%23 = load i32, i32* %11
%24 = icmp sge i32 %23, 0
br i1 %24, label %25, label %43
25: ; preds = %22
%26 = load i8*, i8** %10
%27 = load i32, i32* %11
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = icmp ne i8 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %25
%33 = load i8*, i8** %6
%34 = call zeroext i8 @input_huffman(i8* %33)
%35 = load i8*, i8** %10
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
store i8 %34, i8* %38
br label %39
39: ; preds = %32, %25
br label %40
40: ; preds = %39
%41 = load i32, i32* %11
%42 = add nsw i32 %41, -1
store i32 %42, i32* %11
br label %22
43: ; preds = %22
ret void
}

LLVM IR (-O2):
define void @qtree_expand(i8* %0, i8* %1, i32 %2, i32 %3, i8* %4) {
%6 = tail call i32 @qtree_copy(i8* %1, i32 %2, i32 %3, i8* %4, i32 %3)
%7 = mul i32 %3, %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %5
%10 = zext i32 %7 to i64
br label %11
11: ; preds = %9, %20
%12 = phi i64 [ %10, %9 ], [ %13, %20 ]
%13 = add nsw i64 %12, -1
%14 = and i64 %13, 4294967295
%15 = getelementptr inbounds i8, i8* %4, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %11
%19 = tail call zeroext i8 @input_huffman(i8* %0)
store i8 %19, i8* %15
br label %20
20: ; preds = %11, %18
%21 = icmp ugt i64 %12, 1
br i1 %21, label %11, label %22
22: ; preds = %20, %5
ret void
}