int hangul_pair_decompose(unsigned int code, unsigned int *a, unsigned int *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    -0xac00(%rdi),%ecx
xor    %eax,%eax
cmp    $0x2ba3,%ecx
ja     1182 <hangul_pair_decompose+0x82>
movzwl %cx,%r8d
mov    %r8d,%eax
shr    $0x2,%eax
imul   $0x4925,%eax,%r9d
shr    $0x11,%r9d
lea    (%r9,%r9,8),%eax
lea    (%rax,%rax,2),%eax
add    %r9d,%eax
sub    %eax,%ecx
test   %cx,%cx
je     114a <hangul_pair_decompose+0x4a>
movzwl %cx,%ecx
sub    %ecx,%edi
mov    %edi,(%rsi)
add    $0x11a7,%ecx
mov    $0x3,%eax
jmp    1180 <hangul_pair_decompose+0x80>
imul   $0x6f75,%r8d,%eax
shr    $0x18,%eax
lea    0x1100(%rax),%ecx
mov    %ecx,(%rsi)
imul   $0x24c,%eax,%eax
sub    %eax,%r8d
movzwl %r8w,%eax
shr    $0x2,%eax
imul   $0x4925,%eax,%ecx
shr    $0x11,%ecx
add    $0x1161,%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 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 i32 %0, -44032
%5 = icmp ugt i32 %4, 11171
br i1 %5, label %25, label %6
6: ; preds = %3
%7 = trunc i32 %4 to i16
%8 = urem i16 %7, 28
%9 = zext i16 %8 to i32
%10 = icmp eq i16 %8, 0
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = sub nuw nsw i32 %0, %9
store i32 %12, i32* %1
%13 = add nuw nsw i32 %9, 4519
br label %22
14: ; preds = %6
%15 = udiv i16 %7, 588
%16 = or i16 %15, 4352
%17 = zext i16 %16 to i32
store i32 %17, i32* %1
%18 = urem i16 %7, 588
%19 = udiv i16 %18, 28
%20 = add nuw nsw i16 %19, 4449
%21 = zext i16 %20 to i32
br label %22
22: ; preds = %11, %14
%23 = phi i32 [ %21, %14 ], [ %13, %11 ]
%24 = phi i32 [ 2, %14 ], [ 3, %11 ]
store i32 %23, i32* %2
br label %25
25: ; preds = %22, %3
%26 = phi i32 [ 0, %3 ], [ %24, %22 ]
ret i32 %26
}