#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;
typedef int uint16_t;

/* Variables and functions */
int from_surrogate_pair(uint16_t uc, uint16_t lc, uint32_t *unicode) {
  if (uc >= 0xD800 && uc <= 0xDBFF && lc >= 0xDC00 && lc <= 0xDFFF) {
    *unicode = 0x10000 + ((((uint32_t)uc & 0x3FF) << 10) | (lc & 0x3FF));
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<from_surrogate_pair>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0xd800,-0x8(%rbp)
jl     1170 <from_surrogate_pair+0x70>
cmpl   $0xdbff,-0x8(%rbp)
jg     1170 <from_surrogate_pair+0x70>
cmpl   $0xdc00,-0xc(%rbp)
jl     1170 <from_surrogate_pair+0x70>
cmpl   $0xdfff,-0xc(%rbp)
jg     1170 <from_surrogate_pair+0x70>
mov    -0x8(%rbp),%ecx
and    $0x3ff,%ecx
shl    $0xa,%ecx
mov    -0xc(%rbp),%eax
and    $0x3ff,%eax
or     %eax,%ecx
add    $0x10000,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1177 <from_surrogate_pair+0x77>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<from_surrogate_pair>:
mov    %edi,%ecx
and    $0xfffffc00,%ecx
xor    %eax,%eax
cmp    $0xd800,%ecx
jne    1140 <from_surrogate_pair+0x40>
mov    %esi,%ecx
and    $0xfffffc00,%ecx
cmp    $0xdc00,%ecx
jne    1140 <from_surrogate_pair+0x40>
shl    $0xa,%edi
and    $0xffc00,%edi
and    $0x3ff,%esi
lea    (%rdi,%rsi,1),%eax
add    $0x10000,%eax
mov    %eax,(%rdx)
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @from_surrogate_pair(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
%8 = load i32, i32* %5
%9 = icmp sge i32 %8, 55296
br i1 %9, label %10, label %28
10: ; preds = %3
%11 = load i32, i32* %5
%12 = icmp sle i32 %11, 56319
br i1 %12, label %13, label %28
13: ; preds = %10
%14 = load i32, i32* %6
%15 = icmp sge i32 %14, 56320
br i1 %15, label %16, label %28
16: ; preds = %13
%17 = load i32, i32* %6
%18 = icmp sle i32 %17, 57343
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = load i32, i32* %5
%21 = and i32 %20, 1023
%22 = shl i32 %21, 10
%23 = load i32, i32* %6
%24 = and i32 %23, 1023
%25 = or i32 %22, %24
%26 = add nsw i32 65536, %25
%27 = load i32*, i32** %7
store i32 %26, i32* %27
store i32 1, i32* %4
br label %29
28: ; preds = %16, %13, %10, %3
store i32 0, i32* %4
br label %29
29: ; preds = %28, %19
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
define i32 @from_surrogate_pair(i32 %0, i32 %1, i32* nocapture writeonly %2) {
%4 = and i32 %0, -1024
%5 = icmp eq i32 %4, 55296
%6 = and i32 %1, -1024
%7 = icmp eq i32 %6, 56320
%8 = and i1 %5, %7
br i1 %8, label %9, label %15
9: ; preds = %3
%10 = shl nuw nsw i32 %0, 10
%11 = and i32 %10, 1047552
%12 = and i32 %1, 1023
%13 = or i32 %12, 65536
%14 = add nuw nsw i32 %13, %11
store i32 %14, i32* %2
br label %15
15: ; preds = %3, %9
%16 = phi i32 [ 1, %9 ], [ 0, %3 ]
ret i32 %16
}