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

/* Variables and functions */
int /*<<< orphan*/ decode_utf16(unsigned short const **);
unsigned short *get_decomp_record(int /*<<< orphan*/);
scalar_t__ hangul_pair_decompose(int /*<<< orphan*/, int /*<<< orphan*/ *,
                                 int /*<<< orphan*/ *);
int ucdn_decompose(uint32_t code, uint32_t *a, uint32_t *b) {
  const unsigned short *rec;
  int len;
  if (hangul_pair_decompose(code, a, b))
    return 1;
  rec = get_decomp_record(code);
  len = rec[0] >> 8;
  if ((rec[0] & 0xff) != 0 || len == 0)
    return 0;
  rec++;
  *a = decode_utf16(&rec);
  *b = decode_utf16(&rec);
  return 1;
}


x86 assembly (clang, -O0):
<ucdn_decompose>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <hangul_pair_decompose@plt>
cmp    $0x0,%rax
je     1169 <ucdn_decompose+0x39>
movl   $0x1,-0x4(%rbp)
jmp    11e2 <ucdn_decompose+0xb2>
mov    -0x8(%rbp),%edi
call   1030 <get_decomp_record@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzwl (%rax),%eax
sar    $0x8,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movzwl (%rax),%eax
and    $0xff,%eax
cmp    $0x0,%eax
jne    11a1 <ucdn_decompose+0x71>
cmpl   $0x0,-0x24(%rbp)
jne    11ad <ucdn_decompose+0x7d>
movl   $0x0,-0x4(%rbp)
jmp    11e2 <ucdn_decompose+0xb2>
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
lea    -0x20(%rbp),%rdi
call   1050 <decode_utf16@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x20(%rbp),%rdi
call   1050 <decode_utf16@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ucdn_decompose>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
call   1040 <hangul_pair_decompose@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1199 <ucdn_decompose+0x69>
mov    %ebp,%edi
call   1030 <get_decomp_record@plt>
mov    %rax,%rcx
movzwl (%rax),%edx
xor    %eax,%eax
cmp    $0x100,%edx
jb     1199 <ucdn_decompose+0x69>
movzbl %dl,%edx
test   %dx,%dx
jne    1199 <ucdn_decompose+0x69>
add    $0x2,%rcx
mov    %rcx,0x8(%rsp)
lea    0x8(%rsp),%rbp
mov    %rbp,%rdi
call   1050 <decode_utf16@plt>
mov    %eax,(%rbx)
mov    %rbp,%rdi
call   1050 <decode_utf16@plt>
mov    %eax,(%r14)
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ucdn_decompose(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i16*
%9 = alloca i32
store i32 %0, i32* %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%10 = load i32, i32* %5
%11 = load i32*, i32** %6
%12 = load i32*, i32** %7
%13 = call i64 @hangul_pair_decompose(i32 %10, i32* %11, i32* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %3
store i32 1, i32* %4
br label %41
16: ; preds = %3
%17 = load i32, i32* %5
%18 = call i16* @get_decomp_record(i32 %17)
store i16* %18, i16** %8
%19 = load i16*, i16** %8
%20 = getelementptr inbounds i16, i16* %19, i64 0
%21 = load i16, i16* %20
%22 = zext i16 %21 to i32
%23 = ashr i32 %22, 8
store i32 %23, i32* %9
%24 = load i16*, i16** %8
%25 = getelementptr inbounds i16, i16* %24, i64 0
%26 = load i16, i16* %25
%27 = zext i16 %26 to i32
%28 = and i32 %27, 255
%29 = icmp ne i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %16
%31 = load i32, i32* %9
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %30, %16
store i32 0, i32* %4
br label %41
34: ; preds = %30
%35 = load i16*, i16** %8
%36 = getelementptr inbounds i16, i16* %35, i32 1
store i16* %36, i16** %8
%37 = call i32 @decode_utf16(i16** %8)
%38 = load i32*, i32** %6
store i32 %37, i32* %38
%39 = call i32 @decode_utf16(i16** %8)
%40 = load i32*, i32** %7
store i32 %39, i32* %40
store i32 1, i32* %4
br label %41
41: ; preds = %34, %33, %15
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
define i32 @ucdn_decompose(i32 %0, i32* %1, i32* %2) {
%4 = alloca i16*
%5 = bitcast i16** %4 to i8*
%6 = tail call i64 @hangul_pair_decompose(i32 %0, i32* %1, i32* %2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %3
%9 = tail call i16* @get_decomp_record(i32 %0)
%10 = load i16, i16* %9
%11 = and i16 %10, 255
%12 = icmp ne i16 %11, 0
%13 = icmp ult i16 %10, 256
%14 = or i1 %13, %12
br i1 %14, label %19, label %15
15: ; preds = %8
%16 = getelementptr inbounds i16, i16* %9, i64 1
store i16* %16, i16** %4
%17 = call i32 @decode_utf16(i16** %4)
store i32 %17, i32* %1
%18 = call i32 @decode_utf16(i16** %4)
store i32 %18, i32* %2
br label %19
19: ; preds = %8, %3, %15
%20 = phi i32 [ 1, %15 ], [ 1, %3 ], [ 0, %8 ]
ret i32 %20
}