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

/* Variables and functions */
int hangul_pair_decompose(uint32_t code, uint32_t *a, uint32_t *b) {
  int si = code - 0xAC00;
  if (si < 0 || si >= 11172)
    return 0;
  if (si % 28) {
    *a = 0xAC00 + (si / 28) * 28;
    *b = 0x11A7 + (si % 28);
    return 3;
  } else {
    *a = 0x1100 + (si / (21 * 28));
    *b = 0x1161 + (si % (21 * 28)) / 28;
    return 2;
  }
}


x86 assembly (clang, -O0):
<hangul_pair_decompose>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
sub    $0xac00,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     1131 <hangul_pair_decompose+0x31>
cmpl   $0x2ba4,-0x1c(%rbp)
jl     113d <hangul_pair_decompose+0x3d>
movl   $0x0,-0x4(%rbp)
jmp    11d1 <hangul_pair_decompose+0xd1>
mov    -0x1c(%rbp),%eax
mov    $0x1c,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     118e <hangul_pair_decompose+0x8e>
mov    -0x1c(%rbp),%eax
mov    $0x1c,%ecx
cltd
idiv   %ecx
imul   $0x1c,%eax,%ecx
add    $0xac00,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
mov    $0x1c,%ecx
cltd
idiv   %ecx
add    $0x11a7,%edx
mov    -0x18(%rbp),%rax
mov    %edx,(%rax)
movl   $0x3,-0x4(%rbp)
jmp    11d1 <hangul_pair_decompose+0xd1>
mov    -0x1c(%rbp),%eax
mov    $0x24c,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
add    $0x1100,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
mov    $0x24c,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x1c,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
add    $0x1161,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<hangul_pair_decompose>:
lea    -0xd7a4(%rdi),%ecx
xor    %eax,%eax
cmp    $0xffffd45c,%ecx
jb     11a0 <hangul_pair_decompose+0xa0>
lea    -0xac00(%rdi),%eax
movslq %eax,%r8
imul   $0xffffffff92492493,%r8,%rcx
shr    $0x20,%rcx
add    %r8d,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0x4,%ecx
add    %eax,%ecx
lea    (%rcx,%rcx,8),%eax
lea    (%rax,%rax,2),%eax
add    %ecx,%eax
mov    %r8d,%ecx
sub    %eax,%ecx
je     1155 <hangul_pair_decompose+0x55>
sub    %ecx,%edi
mov    %edi,(%rsi)
add    $0x11a7,%ecx
mov    $0x3,%eax
jmp    119e <hangul_pair_decompose+0x9e>
imul   $0x6f74ae27,%r8,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x28,%rax
lea    (%rax,%rcx,1),%edi
add    $0x1100,%edi
mov    %edi,(%rsi)
add    %ecx,%eax
imul   $0x24c,%eax,%eax
sub    %eax,%r8d
movswl %r8w,%eax
imul   $0x4925,%eax,%eax
mov    %eax,%ecx
sar    $0x13,%ecx
shr    $0x1f,%eax
add    %ecx,%eax
add    $0x1161,%eax
movzwl %ax,%ecx
mov    $0x2,%eax
mov    %ecx,(%rdx)
ret

LLVM IR (-O0):
define i32 @hangul_pair_decompose(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
store i32 %0, i32* %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%9 = load i32, i32* %5
%10 = sub nsw i32 %9, 44032
store i32 %10, i32* %8
%11 = load i32, i32* %8
%12 = icmp slt i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %3
%14 = load i32, i32* %8
%15 = icmp sge i32 %14, 11172
br i1 %15, label %16, label %17
16: ; preds = %13, %3
store i32 0, i32* %4
br label %41
17: ; preds = %13
%18 = load i32, i32* %8
%19 = srem i32 %18, 28
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = load i32, i32* %8
%23 = sdiv i32 %22, 28
%24 = mul nsw i32 %23, 28
%25 = add nsw i32 44032, %24
%26 = load i32*, i32** %6
store i32 %25, i32* %26
%27 = load i32, i32* %8
%28 = srem i32 %27, 28
%29 = add nsw i32 4519, %28
%30 = load i32*, i32** %7
store i32 %29, i32* %30
store i32 3, i32* %4
br label %41
31: ; preds = %17
%32 = load i32, i32* %8
%33 = sdiv i32 %32, 588
%34 = add nsw i32 4352, %33
%35 = load i32*, i32** %6
store i32 %34, i32* %35
%36 = load i32, i32* %8
%37 = srem i32 %36, 588
%38 = sdiv i32 %37, 28
%39 = add nsw i32 4449, %38
%40 = load i32*, i32** %7
store i32 %39, i32* %40
store i32 2, i32* %4
br label %41
41: ; preds = %31, %21, %16
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
define i32 @hangul_pair_decompose(i32 %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = add nsw i32 %0, -44032
%5 = add i32 %0, -55204
%6 = icmp ult i32 %5, -11172
br i1 %6, label %24, label %7
7: ; preds = %3
%8 = srem i32 %4, 28
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = sub nsw i32 %0, %8
store i32 %11, i32* %1
%12 = add nsw i32 %8, 4519
br label %21
13: ; preds = %7
%14 = sdiv i32 %4, 588
%15 = add nsw i32 %14, 4352
store i32 %15, i32* %1
%16 = srem i32 %4, 588
%17 = trunc i32 %16 to i16
%18 = sdiv i16 %17, 28
%19 = add nsw i16 %18, 4449
%20 = zext i16 %19 to i32
br label %21
21: ; preds = %10, %13
%22 = phi i32 [ %20, %13 ], [ %12, %10 ]
%23 = phi i32 [ 2, %13 ], [ 3, %10 ]
store i32 %22, i32* %2
br label %24
24: ; preds = %21, %3
%25 = phi i32 [ 0, %3 ], [ %23, %21 ]
ret i32 %25
}