#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;
typedef int uint32_t;
typedef scalar_t__ uint16_t;

/* Variables and functions */
int decode(int *, scalar_t__ *, int /*<<< orphan*/);
uint8_t const *_hs_text_decode_utf7_int(uint16_t *const dest, size_t *destoff,
                                        const uint8_t **src,
                                        const uint8_t *srcend,
                                        uint16_t *codepoint0,
                                        uint32_t *state0) {
  uint16_t *d = dest + *destoff;
  const uint8_t *s = *src, *last = *src;
  uint32_t state = *state0;
  uint16_t codepoint = *codepoint0;
  while (s < srcend) {
    if (decode(&state, &codepoint, *s++) & 0x000000ff != 0) {
      if (state & 0x000000ff != 2)
        continue;
      break;
    }
    *d++ = codepoint;
    last = s;
    codepoint = 0;
  }
  *destoff = d - dest;
  *codepoint0 = codepoint;
  *state0 = state;
  *src = last;
  return s;
}


x86 assembly (clang, -O0):
<_hs_text_decode_utf7_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11ec <_hs_text_decode_utf7_int+0xdc>
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x40(%rbp)
mov    (%rax),%edx
lea    -0x4c(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1030 <decode@plt>
and    $0x1,%eax
cmp    $0x0,%eax
je     11c1 <_hs_text_decode_utf7_int+0xb1>
mov    -0x4c(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11bc <_hs_text_decode_utf7_int+0xac>
jmp    1170 <_hs_text_decode_utf7_int+0x60>
jmp    11ec <_hs_text_decode_utf7_int+0xdc>
mov    -0x58(%rbp),%rcx
mov    -0x38(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x38(%rbp)
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x58(%rbp)
jmp    1170 <_hs_text_decode_utf7_int+0x60>
mov    -0x38(%rbp),%rcx
mov    -0x8(%rbp),%rax
sub    %rax,%rcx
sar    $0x3,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x58(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x4c(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_hs_text_decode_utf7_int>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,%r14
mov    %rsi,0x18(%rsp)
mov    (%rsi),%rax
mov    %rdi,0x10(%rsp)
lea    (%rdi,%rax,8),%r13
mov    %rdx,0x28(%rsp)
mov    (%rdx),%rbx
mov    %r9,0x30(%rsp)
mov    (%r9),%eax
mov    %eax,0x4(%rsp)
mov    %r8,0x20(%rsp)
mov    (%r8),%rax
lea    0x4(%rsp),%r15
lea    0x8(%rsp),%r12
mov    %rbx,%rbp
mov    %rax,0x8(%rsp)
cmp    %r14,%rbp
jae    11a8 <_hs_text_decode_utf7_int+0x98>
mov    0x0(%rbp),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <decode@plt>
test   $0x1,%al
je     1190 <_hs_text_decode_utf7_int+0x80>
add    $0x4,%rbp
mov    0x4(%rsp),%eax
test   $0x1,%al
jne    1160 <_hs_text_decode_utf7_int+0x50>
jmp    11ac <_hs_text_decode_utf7_int+0x9c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x8(%rsp),%rax
mov    %rax,0x0(%r13)
add    $0x8,%r13
add    $0x4,%rbp
xor    %eax,%eax
mov    %rbp,%rbx
jmp    115b <_hs_text_decode_utf7_int+0x4b>
mov    0x4(%rsp),%eax
sub    0x10(%rsp),%r13
sar    $0x3,%r13
mov    0x18(%rsp),%rcx
mov    %r13,(%rcx)
mov    0x8(%rsp),%rcx
mov    0x20(%rsp),%rdx
mov    %rcx,(%rdx)
mov    0x30(%rsp),%rcx
mov    %eax,(%rcx)
mov    0x28(%rsp),%rax
mov    %rbx,(%rax)
mov    %rbp,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32* @_hs_text_decode_utf7_int(i64* %0, i64* nocapture %1, i32** nocapture %2, i32* readnone %3, i64* nocapture %4, i32* nocapture %5) {
%7 = alloca i32
%8 = alloca i64
%9 = load i64, i64* %1
%10 = getelementptr inbounds i64, i64* %0, i64 %9
%11 = load i32*, i32** %2
%12 = bitcast i32* %7 to i8*
%13 = load i32, i32* %5
store i32 %13, i32* %7
%14 = bitcast i64* %8 to i8*
%15 = load i64, i64* %4
br label %16
16: ; preds = %35, %6
%17 = phi i64 [ %15, %6 ], [ 0, %35 ]
%18 = phi i64* [ %10, %6 ], [ %37, %35 ]
%19 = phi i32* [ %11, %6 ], [ %26, %35 ]
store i64 %17, i64* %8
br label %20
20: ; preds = %16, %31
%21 = phi i32* [ %26, %31 ], [ %19, %16 ]
%22 = icmp ult i32* %21, %3
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = load i32, i32* %7
br label %38
25: ; preds = %20
%26 = getelementptr inbounds i32, i32* %21, i64 1
%27 = load i32, i32* %21
%28 = call i32 @decode(i32* %7, i64* %8, i32 %27)
%29 = and i32 %28, 1
%30 = icmp eq i32 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %25
%32 = load i32, i32* %7
%33 = and i32 %32, 1
%34 = icmp eq i32 %33, 0
br i1 %34, label %38, label %20
35: ; preds = %25
%36 = load i64, i64* %8
%37 = getelementptr inbounds i64, i64* %18, i64 1
store i64 %36, i64* %18
br label %16
38: ; preds = %31, %23
%39 = phi i32 [ %24, %23 ], [ %32, %31 ]
%40 = phi i32* [ %21, %23 ], [ %26, %31 ]
%41 = ptrtoint i64* %18 to i64
%42 = ptrtoint i64* %0 to i64
%43 = sub i64 %41, %42
%44 = ashr exact i64 %43, 3
store i64 %44, i64* %1
%45 = load i64, i64* %8
store i64 %45, i64* %4
store i32 %39, i32* %5
store i32* %19, i32** %2
ret i32* %40
}