#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_compose(uint32_t *code, uint32_t a, uint32_t b) {
  if (b < 0x1161 || b >= (0x11A7 + 28))
    return 0;
  if ((a < 0x1100 || a >= (0x1100 + 19)) &&
      (a < 0xAC00 || a >= (0xAC00 + 11172)))
    return 0;
  if (a >= 0xAC00) {
    *code = a + (b - 0x11A7);
    return 3;
  } else {
    int li = a - 0x1100;
    int vi = b - 0x1161;
    *code = 0xAC00 + li * (21 * 28) + vi * 28;
    return 2;
  }
}


x86 assembly (clang, -O0):
<hangul_pair_compose>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
cmpl   $0x1161,-0x18(%rbp)
jl     1128 <hangul_pair_compose+0x28>
cmpl   $0x11c3,-0x18(%rbp)
jl     1134 <hangul_pair_compose+0x34>
movl   $0x0,-0x4(%rbp)
jmp    11d6 <hangul_pair_compose+0xd6>
cmpl   $0x1100,-0x14(%rbp)
jl     114e <hangul_pair_compose+0x4e>
cmpl   $0x1113,-0x14(%rbp)
jl     1174 <hangul_pair_compose+0x74>
cmpl   $0xac00,-0x14(%rbp)
jl     1168 <hangul_pair_compose+0x68>
cmpl   $0xd7a4,-0x14(%rbp)
jl     1174 <hangul_pair_compose+0x74>
movl   $0x0,-0x4(%rbp)
jmp    11d6 <hangul_pair_compose+0xd6>
cmpl   $0xac00,-0x14(%rbp)
jl     11a0 <hangul_pair_compose+0xa0>
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%eax
sub    $0x11a7,%eax
add    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x3,-0x4(%rbp)
jmp    11d6 <hangul_pair_compose+0xd6>
mov    -0x14(%rbp),%eax
sub    $0x1100,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
sub    $0x1161,%eax
mov    %eax,-0x20(%rbp)
imul   $0x24c,-0x1c(%rbp),%ecx
add    $0xac00,%ecx
imul   $0x1c,-0x20(%rbp),%eax
add    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<hangul_pair_compose>:
lea    -0x11c3(%rdx),%ecx
xor    %eax,%eax
cmp    $0xffffff9e,%ecx
jb     1126 <hangul_pair_compose+0x26>
lea    -0x1113(%rsi),%ecx
cmp    $0xffffffec,%ecx
ja     1127 <hangul_pair_compose+0x27>
lea    -0xd7a4(%rsi),%ecx
cmp    $0xffffd45c,%ecx
jae    1127 <hangul_pair_compose+0x27>
ret
cmp    $0xac00,%esi
jb     1140 <hangul_pair_compose+0x40>
lea    (%rsi,%rdx,1),%ecx
add    $0xffffee59,%ecx
mov    $0x3,%eax
mov    %ecx,(%rdi)
ret
imul   $0x24c,%esi,%eax
lea    (%rdx,%rdx,8),%ecx
lea    (%rcx,%rcx,2),%ecx
add    %edx,%ecx
add    %eax,%ecx
add    $0xffd7b964,%ecx
mov    $0x2,%eax
mov    %ecx,(%rdi)
ret

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

LLVM IR (-O2):
define i32 @hangul_pair_compose(i32* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = add i32 %2, -4547
%5 = icmp ult i32 %4, -98
br i1 %5, label %25, label %6
6: ; preds = %3
%7 = add i32 %1, -4371
%8 = icmp ult i32 %7, -19
%9 = add i32 %1, -55204
%10 = icmp ult i32 %9, -11172
%11 = and i1 %8, %10
br i1 %11, label %25, label %12
12: ; preds = %6
%13 = icmp ugt i32 %1, 44031
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = add nsw i32 %1, -4519
%16 = add nuw nsw i32 %15, %2
br label %22
17: ; preds = %12
%18 = mul nuw nsw i32 %1, 588
%19 = mul nuw nsw i32 %2, 28
%20 = add nsw i32 %18, -2639516
%21 = add nsw i32 %20, %19
br label %22
22: ; preds = %14, %17
%23 = phi i32 [ %21, %17 ], [ %16, %14 ]
%24 = phi i32 [ 2, %17 ], [ 3, %14 ]
store i32 %23, i32* %0
br label %25
25: ; preds = %22, %6, %3
%26 = phi i32 [ 0, %3 ], [ 0, %6 ], [ %24, %22 ]
ret i32 %26
}