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

/* Variables and functions */
void util_euc_to_sjis(u_char *ch, u_char *cl) {
  u_char nh, nl;
  nh = ((*ch - 0x21) >> 1) + 0x81;
  if (nh > 0x9F)
    nh += 0x40;
  if (*ch & 1) {
    nl = *cl + 0x1F;
    if (*cl > 0x5F)
      nl++;
  } else
    nl = *cl + 0x7E;
  *cl = nl;
  *ch = nh;
}


x86 assembly (clang, -O0):
<util_euc_to_sjis>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
sub    $0x21,%eax
sar    $0x1,%eax
add    $0x81,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x9f,-0x14(%rbp)
jle    1136 <util_euc_to_sjis+0x36>
mov    -0x14(%rbp),%eax
add    $0x40,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     116f <util_euc_to_sjis+0x6f>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
add    $0x1f,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x5f,(%rax)
jle    116a <util_euc_to_sjis+0x6a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    117b <util_euc_to_sjis+0x7b>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
add    $0x7e,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_euc_to_sjis>:
mov    (%rdi),%eax
mov    (%rsi),%r8d
xor    %edx,%edx
cmp    $0x60,%r8d
setge  %dl
add    $0x1f,%edx
test   $0x1,%al
mov    $0x7e,%ecx
cmovne %edx,%ecx
add    %r8d,%ecx
xor    %edx,%edx
cmp    $0x5f,%eax
setge  %dl
add    $0xffffffdf,%eax
sar    %eax
shl    $0x6,%edx
add    %edx,%eax
add    $0x81,%eax
mov    %ecx,(%rsi)
mov    %eax,(%rdi)
ret

LLVM IR (-O0):
define void @util_euc_to_sjis(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%7 = load i32*, i32** %3
%8 = load i32, i32* %7
%9 = sub nsw i32 %8, 33
%10 = ashr i32 %9, 1
%11 = add nsw i32 %10, 129
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp sgt i32 %12, 159
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 64
store i32 %16, i32* %5
br label %17
17: ; preds = %14, %2
%18 = load i32*, i32** %3
%19 = load i32, i32* %18
%20 = and i32 %19, 1
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %33
22: ; preds = %17
%23 = load i32*, i32** %4
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 31
store i32 %25, i32* %6
%26 = load i32*, i32** %4
%27 = load i32, i32* %26
%28 = icmp sgt i32 %27, 95
br i1 %28, label %29, label %32
29: ; preds = %22
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %32
32: ; preds = %29, %22
br label %37
33: ; preds = %17
%34 = load i32*, i32** %4
%35 = load i32, i32* %34
%36 = add nsw i32 %35, 126
store i32 %36, i32* %6
br label %37
37: ; preds = %33, %32
%38 = load i32, i32* %6
%39 = load i32*, i32** %4
store i32 %38, i32* %39
%40 = load i32, i32* %5
%41 = load i32*, i32** %3
store i32 %40, i32* %41
ret void
}

LLVM IR (-O2):
define void @util_euc_to_sjis(i32* nocapture %0, i32* nocapture %1) {
%3 = load i32, i32* %0
%4 = and i32 %3, 1
%5 = icmp eq i32 %4, 0
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 95
%8 = select i1 %7, i32 32, i32 31
%9 = select i1 %5, i32 126, i32 %8
%10 = add nsw i32 %6, %9
%11 = icmp sgt i32 %3, 94
%12 = add nsw i32 %3, -33
%13 = ashr i32 %12, 1
%14 = select i1 %11, i32 193, i32 129
%15 = add nsw i32 %13, %14
store i32 %10, i32* %1
store i32 %15, i32* %0
ret void
}