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

/* Variables and functions */
int /*<<< orphan*/ *_hs_text_decode_utf8_int(int /*<<< orphan*/ *const,
                                             size_t *,
                                             int /*<<< orphan*/ const **,
                                             int /*<<< orphan*/ const *const,
                                             scalar_t__ *, scalar_t__ *);
const uint8_t *_hs_text_decode_utf8(uint16_t *const dest, size_t *destoff,
                                    const uint8_t *src,
                                    const uint8_t *const srcend) {
  uint32_t codepoint;
  uint32_t state = 0;
  uint8_t const *ret =
      _hs_text_decode_utf8_int(dest, destoff, &src, srcend, &codepoint, &state);
  if (state != 0)
    ret -= 1;
  return ret;
}


x86 assembly (clang, -O0):
<_hs_text_decode_utf8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rcx
lea    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%r8
lea    -0x30(%rbp),%r9
call   1030 <_hs_text_decode_utf8_int@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1168 <_hs_text_decode_utf8+0x58>
mov    -0x38(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_hs_text_decode_utf8>:
sub    $0x18,%rsp
mov    %rdx,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0x8(%rsp),%rdx
lea    0x10(%rsp),%r8
mov    %rsp,%r9
call   1030 <_hs_text_decode_utf8_int@plt>
xor    %ecx,%ecx
cmp    (%rsp),%rcx
sbb    %rcx,%rcx
lea    (%rax,%rcx,4),%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32* @_hs_text_decode_utf8(i32* %0, i64* %1, i32* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i64*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32*
store i32* %0, i32** %5
store i64* %1, i64** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
store i64 0, i64* %10
%12 = load i32*, i32** %5
%13 = load i64*, i64** %6
%14 = load i32*, i32** %8
%15 = call i32* @_hs_text_decode_utf8_int(i32* %12, i64* %13, i32** %7, i32* %14, i64* %9, i64* %10)
store i32* %15, i32** %11
%16 = load i64, i64* %10
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %4
%19 = load i32*, i32** %11
%20 = getelementptr inbounds i32, i32* %19, i64 -1
store i32* %20, i32** %11
br label %21
21: ; preds = %18, %4
%22 = load i32*, i32** %11
ret i32* %22
}

LLVM IR (-O2):
define i32* @_hs_text_decode_utf8(i32* %0, i64* %1, i32* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i64
store i32* %2, i32** %5
%8 = bitcast i64* %6 to i8*
%9 = bitcast i64* %7 to i8*
store i64 0, i64* %7
%10 = call i32* @_hs_text_decode_utf8_int(i32* %0, i64* %1, i32** %5, i32* %3, i64* %6, i64* %7)
%11 = load i64, i64* %7
%12 = icmp ne i64 %11, 0
%13 = sext i1 %12 to i64
%14 = getelementptr i32, i32* %10, i64 %13
ret i32* %14
}