#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 */

/* Variables and functions */
int /*<<< orphan*/ opa_unicode_surrogate(int);
int opa_unicode_decode_surrogate(int codepoint1, int codepoint2) {
  if (!opa_unicode_surrogate(codepoint1) ||
      !opa_unicode_surrogate(codepoint2)) {
    return 0xfffd;
  }
  return (codepoint1 - 0xd800) << 10 | (codepoint2 - 0xdc00) + 0x10000;
}


x86 assembly (clang, -O0):
<opa_unicode_decode_surrogate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <opa_unicode_surrogate@plt>
cmp    $0x0,%eax
je     1140 <opa_unicode_decode_surrogate+0x30>
mov    -0xc(%rbp),%edi
call   1030 <opa_unicode_surrogate@plt>
cmp    $0x0,%eax
jne    114c <opa_unicode_decode_surrogate+0x3c>
movl   $0xfffd,-0x4(%rbp)
jmp    116b <opa_unicode_decode_surrogate+0x5b>
mov    -0x8(%rbp),%eax
sub    $0xd800,%eax
shl    $0xa,%eax
mov    -0xc(%rbp),%ecx
sub    $0xdc00,%ecx
add    $0x10000,%ecx
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<opa_unicode_decode_surrogate>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
call   1030 <opa_unicode_surrogate@plt>
mov    $0xfffd,%r14d
test   %eax,%eax
je     1146 <opa_unicode_decode_surrogate+0x36>
mov    %ebx,%edi
call   1030 <opa_unicode_surrogate@plt>
test   %eax,%eax
je     1146 <opa_unicode_decode_surrogate+0x36>
shl    $0xa,%ebp
add    $0xfca00000,%ebp
add    $0x2400,%ebx
or     %ebp,%ebx
mov    %ebx,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @opa_unicode_decode_surrogate(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = call i32 @opa_unicode_surrogate(i32 %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* %5
%11 = call i32 @opa_unicode_surrogate(i32 %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %9, %2
store i32 65533, i32* %3
br label %22
14: ; preds = %9
%15 = load i32, i32* %4
%16 = sub nsw i32 %15, 55296
%17 = shl i32 %16, 10
%18 = load i32, i32* %5
%19 = sub nsw i32 %18, 56320
%20 = add nsw i32 %19, 65536
%21 = or i32 %17, %20
store i32 %21, i32* %3
br label %22
22: ; preds = %14, %13
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
define i32 @opa_unicode_decode_surrogate(i32 %0, i32 %1) {
%3 = tail call i32 @opa_unicode_surrogate(i32 %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %2
%6 = tail call i32 @opa_unicode_surrogate(i32 %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = shl i32 %0, 10
%10 = add i32 %9, -56623104
%11 = add nsw i32 %1, 9216
%12 = or i32 %10, %11
br label %13
13: ; preds = %2, %5, %8
%14 = phi i32 [ %12, %8 ], [ 65533, %5 ], [ 65533, %2 ]
ret i32 %14
}