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

/* Variables and functions */
int cash_encode(char *, char const *, int /*<<< orphan*/ *, size_t);
int /*<<< orphan*/ convert_bits(int /*<<< orphan*/ *, size_t *, int,
                                int /*<<< orphan*/ const *, size_t, int, int);
int cash_addr_encode(char *output, const char *hrp, const uint8_t *data,
                     size_t data_len) {
  uint8_t base32[104];
  size_t base32len = 0;
  if (data_len < 2 || data_len > 65)
    return 0;
  convert_bits(base32, &base32len, 5, data, data_len, 8, 1);
  return cash_encode(output, hrp, base32, base32len);
}


x86 assembly (clang, -O0):
<cash_addr_encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movq   $0x0,-0x1d8(%rbp)
cmpq   $0x2,-0x28(%rbp)
jb     115c <cash_addr_encode+0x3c>
cmpq   $0x41,-0x28(%rbp)
jbe    1168 <cash_addr_encode+0x48>
movl   $0x0,-0x4(%rbp)
jmp    11b3 <cash_addr_encode+0x93>
lea    -0x1d0(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    -0x1d8(%rbp),%rsi
mov    $0x5,%edx
mov    $0x8,%r9d
movl   $0x1,(%rsp)
call   1040 <convert_bits@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x1d0(%rbp),%rdx
mov    -0x1d8(%rbp),%rcx
call   1030 <cash_encode@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cash_addr_encode>:
push   %r15
push   %r14
push   %rbx
sub    $0x1b0,%rsp
mov    %rcx,%r8
mov    %rdx,%rcx
movq   $0x0,0x8(%rsp)
lea    -0x42(%r8),%rdx
xor    %eax,%eax
cmp    $0xffffffffffffffc0,%rdx
jb     1184 <cash_addr_encode+0x64>
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x1,(%rsp)
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
mov    $0x5,%edx
mov    $0x8,%r9d
call   1040 <convert_bits@plt>
mov    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <cash_encode@plt>
add    $0x1b0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @cash_addr_encode(i8* %0, i8* %1, i32* %2, i64 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i64
%10 = alloca [104 x i32]
%11 = alloca i64
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32* %2, i32** %8
store i64 %3, i64* %9
store i64 0, i64* %11
%12 = load i64, i64* %9
%13 = icmp ult i64 %12, 2
br i1 %13, label %17, label %14
14: ; preds = %4
%15 = load i64, i64* %9
%16 = icmp ugt i64 %15, 65
br i1 %16, label %17, label %18
17: ; preds = %14, %4
store i32 0, i32* %5
br label %28
18: ; preds = %14
%19 = getelementptr inbounds [104 x i32], [104 x i32]* %10, i64 0, i64 0
%20 = load i32*, i32** %8
%21 = load i64, i64* %9
%22 = call i32 @convert_bits(i32* %19, i64* %11, i32 5, i32* %20, i64 %21, i32 8, i32 1)
%23 = load i8*, i8** %6
%24 = load i8*, i8** %7
%25 = getelementptr inbounds [104 x i32], [104 x i32]* %10, i64 0, i64 0
%26 = load i64, i64* %11
%27 = call i32 @cash_encode(i8* %23, i8* %24, i32* %25, i64 %26)
store i32 %27, i32* %5
br label %28
28: ; preds = %18, %17
%29 = load i32, i32* %5
ret i32 %29
}

LLVM IR (-O2):
define i32 @cash_addr_encode(i8* %0, i8* %1, i32* %2, i64 %3) {
%5 = alloca [104 x i32]
%6 = alloca i64
%7 = bitcast [104 x i32]* %5 to i8*
%8 = bitcast i64* %6 to i8*
store i64 0, i64* %6
%9 = add i64 %3, -66
%10 = icmp ult i64 %9, -64
br i1 %10, label %16, label %11
11: ; preds = %4
%12 = getelementptr inbounds [104 x i32], [104 x i32]* %5, i64 0, i64 0
%13 = call i32 @convert_bits(i32* %12, i64* %6, i32 5, i32* %2, i64 %3, i32 8, i32 1)
%14 = load i64, i64* %6
%15 = call i32 @cash_encode(i8* %0, i8* %1, i32* %12, i64 %14)
br label %16
16: ; preds = %4, %11
%17 = phi i32 [ %15, %11 ], [ 0, %4 ]
ret i32 %17
}