#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 */
int decode(unsigned char *, int *, int *, int *, int *);
int hinv(int *, int, int, int, int);
int /*<<< orphan*/ undigitize(int *, int, int, int);
int fits_hdecompress(unsigned char *input, int smooth, int *a, int *ny, int *nx,
                     int *scale, int *status) {
  int stat;
  if (*status > 0)
    return (*status);
  ;
  stat = decode(input, a, nx, ny, scale);
  ;
  *status = stat;
  if (stat)
    return (*status);
  undigitize(a, *nx, *ny, *scale);
  stat = hinv(a, *nx, *ny, smooth, *scale);
  *status = stat;
  return (*status);
}


x86 assembly (clang, -O0):
<fits_hdecompress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jle    116e <fits_hdecompress+0x3e>
mov    0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11fa <fits_hdecompress+0xca>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x38(%rbp),%r8
call   1040 <decode@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x0,-0x3c(%rbp)
je     11ab <fits_hdecompress+0x7b>
mov    0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11fa <fits_hdecompress+0xca>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
call   1030 <undigitize@plt>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
mov    -0x14(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    (%rax),%r8d
call   1050 <hinv@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fits_hdecompress>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x40(%rsp),%r13
mov    0x0(%r13),%eax
test   %eax,%eax
jg     1194 <fits_hdecompress+0x64>
mov    %r9,%r15
mov    %r8,%rbp
mov    %rcx,%rbx
mov    %rdx,%r12
mov    %esi,%r14d
mov    %rdx,%rsi
mov    %r8,%rdx
mov    %r9,%r8
call   1040 <decode@plt>
mov    %eax,0x0(%r13)
test   %eax,%eax
jne    1194 <fits_hdecompress+0x64>
mov    0x0(%rbp),%esi
mov    (%rbx),%edx
mov    (%r15),%ecx
mov    %r12,%rdi
call   1030 <undigitize@plt>
mov    0x0(%rbp),%esi
mov    (%rbx),%edx
mov    (%r15),%r8d
mov    %r12,%rdi
mov    %r14d,%ecx
call   1050 <hinv@plt>
mov    %eax,0x0(%r13)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fits_hdecompress(i8* %0, i32 %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32
store i8* %0, i8** %9
store i32 %1, i32* %10
store i32* %2, i32** %11
store i32* %3, i32** %12
store i32* %4, i32** %13
store i32* %5, i32** %14
store i32* %6, i32** %15
%17 = load i32*, i32** %15
%18 = load i32, i32* %17
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %7
%21 = load i32*, i32** %15
%22 = load i32, i32* %21
store i32 %22, i32* %8
br label %59
23: ; preds = %7
%24 = load i8*, i8** %9
%25 = load i32*, i32** %11
%26 = load i32*, i32** %13
%27 = load i32*, i32** %12
%28 = load i32*, i32** %14
%29 = call i32 @decode(i8* %24, i32* %25, i32* %26, i32* %27, i32* %28)
store i32 %29, i32* %16
%30 = load i32, i32* %16
%31 = load i32*, i32** %15
store i32 %30, i32* %31
%32 = load i32, i32* %16
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %23
%35 = load i32*, i32** %15
%36 = load i32, i32* %35
store i32 %36, i32* %8
br label %59
37: ; preds = %23
%38 = load i32*, i32** %11
%39 = load i32*, i32** %13
%40 = load i32, i32* %39
%41 = load i32*, i32** %12
%42 = load i32, i32* %41
%43 = load i32*, i32** %14
%44 = load i32, i32* %43
%45 = call i32 @undigitize(i32* %38, i32 %40, i32 %42, i32 %44)
%46 = load i32*, i32** %11
%47 = load i32*, i32** %13
%48 = load i32, i32* %47
%49 = load i32*, i32** %12
%50 = load i32, i32* %49
%51 = load i32, i32* %10
%52 = load i32*, i32** %14
%53 = load i32, i32* %52
%54 = call i32 @hinv(i32* %46, i32 %48, i32 %50, i32 %51, i32 %53)
store i32 %54, i32* %16
%55 = load i32, i32* %16
%56 = load i32*, i32** %15
store i32 %55, i32* %56
%57 = load i32*, i32** %15
%58 = load i32, i32* %57
store i32 %58, i32* %8
br label %59
59: ; preds = %37, %34, %20
%60 = load i32, i32* %8
ret i32 %60
}

LLVM IR (-O2):
define i32 @fits_hdecompress(i8* %0, i32 %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* nocapture %6) {
%8 = load i32, i32* %6
%9 = icmp sgt i32 %8, 0
br i1 %9, label %22, label %10
10: ; preds = %7
%11 = tail call i32 @decode(i8* %0, i32* %2, i32* %4, i32* %3, i32* %5)
store i32 %11, i32* %6
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = load i32, i32* %4
%15 = load i32, i32* %3
%16 = load i32, i32* %5
%17 = tail call i32 @undigitize(i32* %2, i32 %14, i32 %15, i32 %16)
%18 = load i32, i32* %4
%19 = load i32, i32* %3
%20 = load i32, i32* %5
%21 = tail call i32 @hinv(i32* %2, i32 %18, i32 %19, i32 %1, i32 %20)
store i32 %21, i32* %6
br label %22
22: ; preds = %10, %7, %13
%23 = phi i32 [ %21, %13 ], [ %8, %7 ], [ %11, %10 ]
ret i32 %23
}