#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 */
scalar_t__ unicode_to_cns11643(long, int *, int *, int *);
unsigned long euc_tw_from_ucs(long int ucs) {
  int p, r, c;
  if (unicode_to_cns11643(ucs, &p, &r, &c)) {
    if (p == 0)
      return 0x10000000 | ((r + 0xA1) << 8) | (c + 0xA1);
    else
      return 0x20000000 | ((p + 0xA1) << 16) | ((r + 0xA1) << 8) | (c + 0xA1);
  } else
    return 0;
}


x86 assembly (clang, -O0):
<euc_tw_from_ucs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1030 <unicode_to_cns11643@plt>
cmp    $0x0,%rax
je     119f <euc_tw_from_ucs+0x8f>
cmpl   $0x0,-0x14(%rbp)
jne    116b <euc_tw_from_ucs+0x5b>
mov    -0x18(%rbp),%eax
add    $0xa1,%eax
shl    $0x8,%eax
or     $0x10000000,%eax
mov    -0x1c(%rbp),%ecx
add    $0xa1,%ecx
or     %ecx,%eax
cltq
mov    %rax,-0x8(%rbp)
jmp    11a7 <euc_tw_from_ucs+0x97>
mov    -0x14(%rbp),%eax
add    $0xa1,%eax
shl    $0x10,%eax
or     $0x20000000,%eax
mov    -0x18(%rbp),%ecx
add    $0xa1,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x1c(%rbp),%ecx
add    $0xa1,%ecx
or     %ecx,%eax
cltq
mov    %rax,-0x8(%rbp)
jmp    11a7 <euc_tw_from_ucs+0x97>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<euc_tw_from_ucs>:
sub    $0x18,%rsp
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1030 <unicode_to_cns11643@plt>
test   %rax,%rax
je     1169 <euc_tw_from_ucs+0x59>
mov    0x14(%rsp),%eax
test   %eax,%eax
je     1170 <euc_tw_from_ucs+0x60>
shl    $0x10,%eax
add    $0xa10000,%eax
mov    0x10(%rsp),%ecx
shl    $0x8,%ecx
add    $0xa100,%ecx
or     %eax,%ecx
movslq 0xc(%rsp),%rdx
add    $0xa1,%rdx
movslq %ecx,%rax
or     %rdx,%rax
or     $0x20000000,%rax
add    $0x18,%rsp
ret
xor    %eax,%eax
add    $0x18,%rsp
ret
mov    0x10(%rsp),%eax
shl    $0x8,%eax
add    $0xa100,%eax
movslq 0xc(%rsp),%rcx
add    $0xa1,%rcx
cltq
or     %rcx,%rax
or     $0x10000000,%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i64 @euc_tw_from_ucs(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i64 %0, i64* %3
%7 = load i64, i64* %3
%8 = call i64 @unicode_to_cns11643(i64 %7, i32* %4, i32* %5, i32* %6)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %35
10: ; preds = %1
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 161
%16 = shl i32 %15, 8
%17 = or i32 268435456, %16
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 161
%20 = or i32 %17, %19
%21 = sext i32 %20 to i64
store i64 %21, i64* %2
br label %36
22: ; preds = %10
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 161
%25 = shl i32 %24, 16
%26 = or i32 536870912, %25
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 161
%29 = shl i32 %28, 8
%30 = or i32 %26, %29
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 161
%33 = or i32 %30, %32
%34 = sext i32 %33 to i64
store i64 %34, i64* %2
br label %36
35: ; preds = %1
store i64 0, i64* %2
br label %36
36: ; preds = %35, %22, %13
%37 = load i64, i64* %2
ret i64 %37
}

LLVM IR (-O2):
define i64 @euc_tw_from_ucs(i64 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = call i64 @unicode_to_cns11643(i64 %0, i32* %2, i32* %3, i32* %4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %34, label %10
10: ; preds = %1
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = load i32, i32* %3
%15 = shl i32 %14, 8
%16 = add i32 %15, 41216
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 161
%19 = or i32 %18, %16
%20 = or i32 %19, 268435456
%21 = sext i32 %20 to i64
br label %34
22: ; preds = %10
%23 = shl i32 %11, 16
%24 = add i32 %23, 10551296
%25 = load i32, i32* %3
%26 = shl i32 %25, 8
%27 = add i32 %26, 41216
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 161
%30 = or i32 %24, %27
%31 = or i32 %30, %29
%32 = or i32 %31, 536870912
%33 = sext i32 %32 to i64
br label %34
34: ; preds = %1, %22, %13
%35 = phi i64 [ %21, %13 ], [ %33, %22 ], [ 0, %1 ]
ret i64 %35
}