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

/* Variables and functions */
void hangul_decompose(int32_t code, int32_t **bufp) {
  int32_t *dst = *bufp;
  int32_t sindex = code - 0xAC00;
  int32_t lindex = sindex / (21 * 28);
  int32_t vindex = (sindex % (21 * 28)) / 28;
  int32_t tindex = sindex % 28;
  int32_t lpart = 0x1100 + lindex;
  int32_t vpart = 0x1161 + vindex;
  int32_t tpart = 0x11A7 + tindex;
  *dst++ = lpart;
  *dst++ = vpart;
  if (tindex > 0) {
    *dst++ = tpart;
  }
  *bufp = dst;
}


x86 assembly (clang, -O0):
<hangul_decompose>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
sub    $0xac00,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x24c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x24c,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x1c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x1c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1100,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1161,%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%eax
add    $0x11a7,%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x18(%rbp)
mov    %ecx,(%rax)
mov    -0x30(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x18(%rbp)
mov    %ecx,(%rax)
cmpl   $0x0,-0x28(%rbp)
jle    11bc <hangul_decompose+0xbc>
mov    -0x34(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x18(%rbp)
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<hangul_decompose>:
mov    (%rsi),%r8
lea    -0xac00(%rdi),%eax
movslq %eax,%rcx
imul   $0x6f74ae27,%rcx,%rdx
mov    %rdx,%r9
shr    $0x3f,%r9
shr    $0x20,%rdx
sar    $0x8,%edx
lea    (%rdx,%r9,1),%eax
imul   $0x24c,%eax,%r10d
mov    %ecx,%eax
sub    %r10d,%eax
cwtl
imul   $0x4925,%eax,%r11d
mov    %r11d,%r10d
sar    $0x13,%r10d
shr    $0x1f,%r11d
imul   $0xffffffff92492493,%rcx,%rax
shr    $0x20,%rax
add    %edi,%eax
add    $0xffff5400,%eax
mov    %eax,%edi
shr    $0x1f,%edi
sar    $0x4,%eax
add    %edi,%eax
lea    (%rax,%rax,8),%edi
lea    (%rdi,%rdi,2),%edi
add    %eax,%edi
sub    %edi,%ecx
lea    (%rdx,%r9,1),%eax
add    $0x1100,%eax
lea    0x1161(%r10,%r11,1),%edx
movzwl %dx,%edx
mov    %eax,(%r8)
mov    %edx,0x4(%r8)
test   %ecx,%ecx
jle    119b <hangul_decompose+0x9b>
add    $0x11a7,%ecx
mov    %ecx,0x8(%r8)
add    $0xc,%r8
mov    %r8,(%rsi)
ret
add    $0x8,%r8
mov    %r8,(%rsi)
ret

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

LLVM IR (-O2):
define void @hangul_decompose(i32 %0, i32** nocapture %1) {
%3 = load i32*, i32** %1
%4 = add nsw i32 %0, -44032
%5 = sdiv i32 %4, 588
%6 = srem i32 %4, 588
%7 = trunc i32 %6 to i16
%8 = sdiv i16 %7, 28
%9 = srem i32 %4, 28
%10 = add nsw i32 %5, 4352
%11 = add nsw i16 %8, 4449
%12 = zext i16 %11 to i32
%13 = getelementptr inbounds i32, i32* %3, i64 1
store i32 %10, i32* %3
%14 = getelementptr inbounds i32, i32* %3, i64 2
store i32 %12, i32* %13
%15 = icmp sgt i32 %9, 0
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = add nuw nsw i32 %9, 4519
%18 = getelementptr inbounds i32, i32* %3, i64 3
store i32 %17, i32* %14
br label %19
19: ; preds = %16, %2
%20 = phi i32* [ %18, %16 ], [ %14, %2 ]
store i32* %20, i32** %1
ret void
}