#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);
  if (len > 1)
    *b = decode_utf16(&rec);
  else
    *b = 0;
  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    11fb <ucdn_decompose+0xcb>
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    11fb <ucdn_decompose+0xcb>
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)
cmpl   $0x1,-0x24(%rbp)
jle    11ea <ucdn_decompose+0xba>
lea    -0x20(%rbp),%rdi
call   1050 <decode_utf16@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    11f4 <ucdn_decompose+0xc4>
mov    -0x18(%rbp),%rax
movl   $0x0,(%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    11a6 <ucdn_decompose+0x76>
mov    %ebp,%edi
call   1030 <get_decomp_record@plt>
mov    %rax,%rcx
movzwl (%rax),%ebp
xor    %eax,%eax
cmp    $0x100,%ebp
jb     11a6 <ucdn_decompose+0x76>
movzbl %bpl,%edx
test   %dx,%dx
jne    11a6 <ucdn_decompose+0x76>
add    $0x2,%rcx
mov    %rcx,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1050 <decode_utf16@plt>
mov    %eax,(%rbx)
movzwl %bp,%ecx
xor    %eax,%eax
cmp    $0x200,%ecx
jb     119e <ucdn_decompose+0x6e>
lea    0x8(%rsp),%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 %47
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 %47
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 = load i32, i32* %9
%40 = icmp sgt i32 %39, 1
br i1 %40, label %41, label %44
41: ; preds = %34
%42 = call i32 @decode_utf16(i16** %8)
%43 = load i32*, i32** %7
store i32 %42, i32* %43
br label %46
44: ; preds = %34
%45 = load i32*, i32** %7
store i32 0, i32* %45
br label %46
46: ; preds = %44, %41
store i32 1, i32* %4
br label %47
47: ; preds = %46, %33, %15
%48 = load i32, i32* %4
ret i32 %48
}

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 %23
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 %23, 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 = icmp ugt i16 %10, 511
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @decode_utf16(i16** %4)
br label %21
21: ; preds = %15, %19
%22 = phi i32 [ %20, %19 ], [ 0, %15 ]
store i32 %22, i32* %2
br label %23
23: ; preds = %8, %3, %21
%24 = phi i32 [ 1, %21 ], [ 1, %3 ], [ 0, %8 ]
ret i32 %24
}