#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 */
void decompose_hangul(uint32_t s, uint32_t *r, size_t *result_len) {
  int SIndex = s - 0xAC00;
  if (SIndex < 0 || SIndex >= (19 * (21 * 28))) {
    if (r)
      r[0] = s;
    *result_len = 1;
  } else {
    uint32_t L = 0x1100 + SIndex / (21 * 28);
    uint32_t V = 0x1161 + (SIndex % (21 * 28)) / 28;
    uint32_t T = 0x11A7 + SIndex % 28;
    if (r) {
      r[0] = L;
      r[1] = V;
    }
    if (T != 0x11A7) {
      if (r)
        r[2] = T;
      *result_len = 3;
    } else
      *result_len = 2;
  }
}


x86 assembly (clang, -O0):
<decompose_hangul>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
sub    $0xac00,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     1131 <decompose_hangul+0x31>
cmpl   $0x2ba4,-0x1c(%rbp)
jl     1155 <decompose_hangul+0x55>
cmpq   $0x0,-0x10(%rbp)
je     1145 <decompose_hangul+0x45>
mov    -0x4(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x1,(%rax)
jmp    11f9 <decompose_hangul+0xf9>
mov    -0x1c(%rbp),%eax
mov    $0x24c,%ecx
cltd
idiv   %ecx
add    $0x1100,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x24c,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x1c,%ecx
cltd
idiv   %ecx
add    $0x1161,%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x1c,%ecx
cltd
idiv   %ecx
add    $0x11a7,%edx
mov    %edx,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b7 <decompose_hangul+0xb7>
mov    -0x20(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
cmpl   $0x11a7,-0x28(%rbp)
je     11e9 <decompose_hangul+0xe9>
cmpq   $0x0,-0x10(%rbp)
je     11d9 <decompose_hangul+0xd9>
mov    -0x28(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x18(%rbp),%rax
movq   $0x3,(%rax)
jmp    11f4 <decompose_hangul+0xf4>
mov    -0x18(%rbp),%rax
movq   $0x2,(%rax)
jmp    11f9 <decompose_hangul+0xf9>
pop    %rbp
ret

x86 assembly (clang, -O2):
<decompose_hangul>:
push   %rbx
lea    -0xd7a4(%rdi),%eax
cmp    $0xffffd45b,%eax
ja     1123 <decompose_hangul+0x23>
mov    $0x1,%eax
test   %rsi,%rsi
je     11d1 <decompose_hangul+0xd1>
mov    %edi,(%rsi)
jmp    11d1 <decompose_hangul+0xd1>
add    $0xffff5400,%edi
movslq %edi,%r9
imul   $0xffffffff92492493,%r9,%rcx
shr    $0x20,%rcx
add    %edi,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0x4,%ecx
add    %eax,%ecx
lea    (%rcx,%rcx,8),%eax
lea    (%rax,%rax,2),%r10d
add    %ecx,%r10d
mov    %r9d,%r8d
sub    %r10d,%r8d
test   %rsi,%rsi
je     11bd <decompose_hangul+0xbd>
imul   $0x6f74ae27,%r9,%rbx
mov    %rbx,%r9
shr    $0x3f,%r9
sar    $0x28,%rbx
lea    (%rbx,%r9,1),%eax
imul   $0x24c,%eax,%r11d
mov    %edi,%eax
sub    %r11d,%eax
cwtl
imul   $0x4925,%eax,%eax
mov    %eax,%ecx
sar    $0x13,%ecx
shr    $0x1f,%eax
add    %ecx,%eax
add    $0x1161,%eax
movzwl %ax,%eax
lea    (%rbx,%r9,1),%ecx
add    $0x1100,%ecx
mov    %ecx,(%rsi)
mov    %eax,0x4(%rsi)
test   %r8d,%r8d
je     11cc <decompose_hangul+0xcc>
neg    %r10d
lea    (%rdi,%r10,1),%eax
add    $0x11a7,%eax
mov    %eax,0x8(%rsi)
mov    $0x3,%eax
jmp    11d1 <decompose_hangul+0xd1>
cmp    $0x1,%r8d
mov    $0x3,%eax
sbb    $0x0,%rax
jmp    11d1 <decompose_hangul+0xd1>
mov    $0x2,%eax
mov    %rax,(%rdx)
pop    %rbx
ret

LLVM IR (-O0):
define void @decompose_hangul(i32 %0, i32* %1, i64* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i64*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i64* %2, i64** %6
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 44032
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %3
%16 = load i32, i32* %7
%17 = icmp sge i32 %16, 11172
br i1 %17, label %18, label %27
18: ; preds = %15, %3
%19 = load i32*, i32** %5
%20 = icmp ne i32* %19, null
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i32, i32* %4
%23 = load i32*, i32** %5
%24 = getelementptr inbounds i32, i32* %23, i64 0
store i32 %22, i32* %24
br label %25
25: ; preds = %21, %18
%26 = load i64*, i64** %6
store i64 1, i64* %26
br label %62
27: ; preds = %15
%28 = load i32, i32* %7
%29 = sdiv i32 %28, 588
%30 = add nsw i32 4352, %29
store i32 %30, i32* %8
%31 = load i32, i32* %7
%32 = srem i32 %31, 588
%33 = sdiv i32 %32, 28
%34 = add nsw i32 4449, %33
store i32 %34, i32* %9
%35 = load i32, i32* %7
%36 = srem i32 %35, 28
%37 = add nsw i32 4519, %36
store i32 %37, i32* %10
%38 = load i32*, i32** %5
%39 = icmp ne i32* %38, null
br i1 %39, label %40, label %47
40: ; preds = %27
%41 = load i32, i32* %8
%42 = load i32*, i32** %5
%43 = getelementptr inbounds i32, i32* %42, i64 0
store i32 %41, i32* %43
%44 = load i32, i32* %9
%45 = load i32*, i32** %5
%46 = getelementptr inbounds i32, i32* %45, i64 1
store i32 %44, i32* %46
br label %47
47: ; preds = %40, %27
%48 = load i32, i32* %10
%49 = icmp ne i32 %48, 4519
br i1 %49, label %50, label %59
50: ; preds = %47
%51 = load i32*, i32** %5
%52 = icmp ne i32* %51, null
br i1 %52, label %53, label %57
53: ; preds = %50
%54 = load i32, i32* %10
%55 = load i32*, i32** %5
%56 = getelementptr inbounds i32, i32* %55, i64 2
store i32 %54, i32* %56
br label %57
57: ; preds = %53, %50
%58 = load i64*, i64** %6
store i64 3, i64* %58
br label %61
59: ; preds = %47
%60 = load i64*, i64** %6
store i64 2, i64* %60
br label %61
61: ; preds = %59, %57
br label %62
62: ; preds = %61, %25
ret void
}

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