#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, ...);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ han2zen(int /*<<< orphan*/ *, int *, int *, int);
int /*<<< orphan*/ jis2sjis(int *, int *);
void euc2shift(FILE *in, FILE *out, int incode, int tofullsize) {
  int p1, p2;
  while ((p1 = getc(in)) != EOF) {
    switch (p1) {
    case 12:
      break;
    default:
      if ((p1 >= 161) && (p1 <= 254)) {
        p2 = getc(in);
        if ((p2 >= 161) && (p2 <= 254)) {
          p1 -= 128;
          p2 -= 128;
          jis2sjis(&p1, &p2);
        }
        fprintf(out, "%c%c", p1, p2);
      } else if (p1 == 142) {
        p2 = getc(in);
        if ((p2 >= 161) && (p2 <= 223)) {
          if (tofullsize) {
            p1 = p2;
            han2zen(in, &p1, &p2, incode);
            fprintf(out, "%c%c", p1, p2);
          } else {
            p1 = p2;
            fprintf(out, "%c", p1);
          }
        } else
          fprintf(out, "%c%c", p1, p2);
      } else
        fprintf(out, "%c", p1);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<euc2shift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e7f(%rip),%rcx
cmp    (%rcx),%eax
je     12dc <euc2shift+0x19c>
mov    -0x1c(%rbp),%eax
sub    $0xc,%eax
jne    1187 <euc2shift+0x47>
jmp    1182 <euc2shift+0x42>
jmp    12d7 <euc2shift+0x197>
cmpl   $0xa1,-0x1c(%rbp)
jl     1207 <euc2shift+0xc7>
cmpl   $0xfe,-0x1c(%rbp)
jg     1207 <euc2shift+0xc7>
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xa1,-0x20(%rbp)
jl     11ea <euc2shift+0xaa>
cmpl   $0xfe,-0x20(%rbp)
jg     11ea <euc2shift+0xaa>
mov    -0x1c(%rbp),%eax
sub    $0x80,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
sub    $0x80,%eax
mov    %eax,-0x20(%rbp)
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <jis2sjis@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    12d2 <euc2shift+0x192>
cmpl   $0x8e,-0x1c(%rbp)
jne    12b8 <euc2shift+0x178>
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xa1,-0x20(%rbp)
jl     129b <euc2shift+0x15b>
cmpl   $0xdf,-0x20(%rbp)
jg     129b <euc2shift+0x15b>
cmpl   $0x0,-0x18(%rbp)
je     127b <euc2shift+0x13b>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%ecx
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <han2zen@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xd91(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1296 <euc2shift+0x156>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xd73(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    12b3 <euc2shift+0x173>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xd54(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    12cd <euc2shift+0x18d>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xd3c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    12d2 <euc2shift+0x192>
jmp    12d7 <euc2shift+0x197>
jmp    1156 <euc2shift+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<euc2shift>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r15d
mov    %edx,0x14(%rsp)
mov    %rsi,%rbp
mov    %rdi,%rbx
call   1070 <getc@plt>
mov    %eax,0xc(%rsp)
mov    0x2e6d(%rip),%r12
cmp    (%r12),%eax
jne    1190 <euc2shift+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%r13
lea    0xe64(%rip),%r14
jmp    11c5 <euc2shift+0x75>
xchg   %ax,%ax
mov    0xc(%rsp),%edx
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1070 <getc@plt>
mov    %eax,0xc(%rsp)
cmp    (%r12),%eax
je     1181 <euc2shift+0x31>
cmp    $0xc,%eax
je     11b3 <euc2shift+0x63>
lea    -0xa1(%rax),%ecx
cmp    $0x5d,%ecx
ja     1210 <euc2shift+0xc0>
mov    %rbx,%rdi
call   1070 <getc@plt>
mov    %eax,0x10(%rsp)
lea    -0xa1(%rax),%ecx
cmp    $0x5d,%ecx
ja     11a0 <euc2shift+0x50>
addl   $0xffffff80,0xc(%rsp)
add    $0xffffff80,%eax
mov    %eax,0x10(%rsp)
lea    0xc(%rsp),%rdi
mov    %r13,%rsi
call   1030 <jis2sjis@plt>
mov    0x10(%rsp),%eax
jmp    11a0 <euc2shift+0x50>
nopl   0x0(%rax,%rax,1)
cmp    $0x8e,%eax
jne    1260 <euc2shift+0x110>
mov    %rbx,%rdi
call   1070 <getc@plt>
mov    %eax,0x10(%rsp)
mov    %eax,%ecx
add    $0xffffff5f,%ecx
cmp    $0x3e,%ecx
ja     126f <euc2shift+0x11f>
mov    %eax,0xc(%rsp)
test   %r15d,%r15d
je     1280 <euc2shift+0x130>
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
mov    %r13,%rdx
mov    0x14(%rsp),%ecx
call   1060 <han2zen@plt>
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    %rbp,%rdi
mov    %r14,%rsi
jmp    11ac <euc2shift+0x5c>
mov    %eax,%edi
mov    %rbp,%rsi
call   1040 <fputc@plt>
jmp    11b3 <euc2shift+0x63>
mov    0xc(%rsp),%edx
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %eax,%ecx
jmp    11ac <euc2shift+0x5c>
mov    %eax,%edi
jmp    1262 <euc2shift+0x112>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [5 x i8] c"%c%c\00"
@.str.1 = [3 x i8] c"%c\00"
define void @euc2shift(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
br label %11
11: ; preds = %85, %4
%12 = load i32*, i32** %5
%13 = call i32 @getc(i32* %12)
store i32 %13, i32* %9
%14 = load i32, i32* @EOF
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %86
16: ; preds = %11
%17 = load i32, i32* %9
switch i32 %17, label %19 [
i32 12, label %18
]
18: ; preds = %16
br label %85
19: ; preds = %16
%20 = load i32, i32* %9
%21 = icmp sge i32 %20, 161
br i1 %21, label %22, label %44
22: ; preds = %19
%23 = load i32, i32* %9
%24 = icmp sle i32 %23, 254
br i1 %24, label %25, label %44
25: ; preds = %22
%26 = load i32*, i32** %5
%27 = call i32 @getc(i32* %26)
store i32 %27, i32* %10
%28 = load i32, i32* %10
%29 = icmp sge i32 %28, 161
br i1 %29, label %30, label %39
30: ; preds = %25
%31 = load i32, i32* %10
%32 = icmp sle i32 %31, 254
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32, i32* %9
%35 = sub nsw i32 %34, 128
store i32 %35, i32* %9
%36 = load i32, i32* %10
%37 = sub nsw i32 %36, 128
store i32 %37, i32* %10
%38 = call i32 @jis2sjis(i32* %9, i32* %10)
br label %39
39: ; preds = %33, %30, %25
%40 = load i32*, i32** %6
%41 = load i32, i32* %9
%42 = load i32, i32* %10
%43 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %41, i32 %42)
br label %84
44: ; preds = %22, %19
%45 = load i32, i32* %9
%46 = icmp eq i32 %45, 142
br i1 %46, label %47, label %79
47: ; preds = %44
%48 = load i32*, i32** %5
%49 = call i32 @getc(i32* %48)
store i32 %49, i32* %10
%50 = load i32, i32* %10
%51 = icmp sge i32 %50, 161
br i1 %51, label %52, label %73
52: ; preds = %47
%53 = load i32, i32* %10
%54 = icmp sle i32 %53, 223
br i1 %54, label %55, label %73
55: ; preds = %52
%56 = load i32, i32* %8
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %67
58: ; preds = %55
%59 = load i32, i32* %10
store i32 %59, i32* %9
%60 = load i32*, i32** %5
%61 = load i32, i32* %7
%62 = call i32 @han2zen(i32* %60, i32* %9, i32* %10, i32 %61)
%63 = load i32*, i32** %6
%64 = load i32, i32* %9
%65 = load i32, i32* %10
%66 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %64, i32 %65)
br label %72
67: ; preds = %55
%68 = load i32, i32* %10
store i32 %68, i32* %9
%69 = load i32*, i32** %6
%70 = load i32, i32* %9
%71 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %70)
br label %72
72: ; preds = %67, %58
br label %78
73: ; preds = %52, %47
%74 = load i32*, i32** %6
%75 = load i32, i32* %9
%76 = load i32, i32* %10
%77 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %74, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %75, i32 %76)
br label %78
78: ; preds = %73, %72
br label %83
79: ; preds = %44
%80 = load i32*, i32** %6
%81 = load i32, i32* %9
%82 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %81)
br label %83
83: ; preds = %79, %78
br label %84
84: ; preds = %83, %39
br label %85
85: ; preds = %84, %18
br label %11
86: ; preds = %11
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [5 x i8] c"%c%c\00"
define void @euc2shift(i32* %0, i32* nocapture %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %5 to i8*
%8 = bitcast i32* %6 to i8*
%9 = call i32 @getc(i32* %0)
store i32 %9, i32* %5
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %57, label %12
12: ; preds = %4
%13 = icmp eq i32 %3, 0
br label %14
14: ; preds = %12, %53
%15 = phi i32 [ %9, %12 ], [ %54, %53 ]
%16 = icmp eq i32 %15, 12
br i1 %16, label %53, label %17
17: ; preds = %14
%18 = add i32 %15, -161
%19 = icmp ult i32 %18, 94
br i1 %19, label %20, label %34
20: ; preds = %17
%21 = call i32 @getc(i32* %0)
store i32 %21, i32* %6
%22 = add i32 %21, -161
%23 = icmp ult i32 %22, 94
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = load i32, i32* %5
%26 = add nsw i32 %25, -128
store i32 %26, i32* %5
%27 = add nsw i32 %21, -128
store i32 %27, i32* %6
%28 = call i32 @jis2sjis(i32* %5, i32* %6)
%29 = load i32, i32* %6
br label %30
30: ; preds = %24, %20
%31 = phi i32 [ %29, %24 ], [ %21, %20 ]
%32 = load i32, i32* %5
%33 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %32, i32 %31)
br label %53
34: ; preds = %17
%35 = icmp eq i32 %15, 142
br i1 %35, label %36, label %51
36: ; preds = %34
%37 = call i32 @getc(i32* %0)
store i32 %37, i32* %6
%38 = add i32 %37, -161
%39 = icmp ult i32 %38, 63
br i1 %39, label %40, label %48
40: ; preds = %36
store i32 %37, i32* %5
br i1 %13, label %46, label %41
41: ; preds = %40
%42 = call i32 @han2zen(i32* %0, i32* %5, i32* %6, i32 %2)
%43 = load i32, i32* %5
%44 = load i32, i32* %6
%45 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %43, i32 %44)
br label %53
46: ; preds = %40
%47 = call i32 @fputc(i32 %37, i32* %1)
br label %53
48: ; preds = %36
%49 = load i32, i32* %5
%50 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %49, i32 %37)
br label %53
51: ; preds = %34
%52 = call i32 @fputc(i32 %15, i32* %1)
br label %53
53: ; preds = %30, %48, %46, %41, %51, %14
%54 = call i32 @getc(i32* %0)
store i32 %54, i32* %5
%55 = load i32, i32* @EOF
%56 = icmp eq i32 %54, %55
br i1 %56, label %57, label %14
57: ; preds = %53, %4
ret void
}