#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*/ KanjiIn(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ KanjiOut(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, ...);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ han2zen(int /*<<< orphan*/ *, int *, int *, int);
int /*<<< orphan*/ sjis2jis(int *, int *);
void shift2seven(FILE *in, FILE *out, int outcode, int incode) {
  int shifted_in, p1, p2;
  shifted_in = 0;
  while ((p1 = getc(in)) != EOF) {
    switch (p1) {
    case 0:
    case 12:
      break;
    case 13:
    case 10:
      if (shifted_in) {
        shifted_in = 0;
        KanjiOut(out, outcode);
      }
      fprintf(out, "%c", 10);
      break;
    default:
      if (((p1 >= 129) && (p1 <= 159)) || ((p1 >= 224) && (p1 <= 239))) {
        p2 = getc(in);
        if ((p2 >= 64) && (p2 <= 252)) {
          sjis2jis(&p1, &p2);
          if (!shifted_in) {
            shifted_in = 1;
            KanjiIn(out, outcode);
          }
        }
        fprintf(out, "%c%c", p1, p2);
      } else if ((p1 >= 161) && (p1 <= 223)) {
        han2zen(in, &p1, &p2, incode);
        sjis2jis(&p1, &p2);
        if (!shifted_in) {
          shifted_in = 1;
          KanjiIn(out, outcode);
        }
        fprintf(out, "%c%c", p1, p2);
      } else {
        if (shifted_in) {
          shifted_in = 0;
          KanjiOut(out, outcode);
        }
        fprintf(out, "%c", p1);
      }
      break;
    }
  }
  if (shifted_in)
    KanjiOut(out, outcode);
}


x86 assembly (clang, -O0):
<shift2seven>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <getc@plt>
mov    %eax,-0x20(%rbp)
mov    0x2e58(%rip),%rcx
cmp    (%rcx),%eax
je     1354 <shift2seven+0x1f4>
mov    -0x20(%rbp),%eax
mov    %rax,-0x30(%rbp)
sub    $0xd,%rax
ja     11fb <shift2seven+0x9b>
mov    -0x30(%rbp),%rax
lea    0xe4c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    134f <shift2seven+0x1ef>
cmpl   $0x0,-0x1c(%rbp)
je     11df <shift2seven+0x7f>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <KanjiOut@plt>
mov    -0x10(%rbp),%rdi
lea    0xe50(%rip),%rsi
mov    $0xa,%edx
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    134f <shift2seven+0x1ef>
cmpl   $0x81,-0x20(%rbp)
jl     1215 <shift2seven+0xb5>
cmpl   $0x9f,-0x20(%rbp)
jle    122f <shift2seven+0xcf>
cmpl   $0xe0,-0x20(%rbp)
jl     129e <shift2seven+0x13e>
cmpl   $0xef,-0x20(%rbp)
jg     129e <shift2seven+0x13e>
mov    -0x8(%rbp),%rdi
call   1080 <getc@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x40,-0x24(%rbp)
jl     1281 <shift2seven+0x121>
cmpl   $0xfc,-0x24(%rbp)
jg     1281 <shift2seven+0x121>
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1060 <sjis2jis@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    127c <shift2seven+0x11c>
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <KanjiIn@plt>
jmp    1281 <shift2seven+0x121>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xda6(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    134a <shift2seven+0x1ea>
cmpl   $0xa1,-0x20(%rbp)
jl     1313 <shift2seven+0x1b3>
cmpl   $0xdf,-0x20(%rbp)
jg     1313 <shift2seven+0x1b3>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%ecx
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1070 <han2zen@plt>
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1060 <sjis2jis@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    12f6 <shift2seven+0x196>
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <KanjiIn@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xd31(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1345 <shift2seven+0x1e5>
cmpl   $0x0,-0x1c(%rbp)
je     1330 <shift2seven+0x1d0>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <KanjiOut@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xcfc(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    134a <shift2seven+0x1ea>
jmp    134f <shift2seven+0x1ef>
jmp    117d <shift2seven+0x1d>
cmpl   $0x0,-0x1c(%rbp)
je     136a <shift2seven+0x20a>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <KanjiOut@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shift2seven>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,0x14(%rsp)
mov    %edx,%r15d
mov    %rsi,%r13
mov    %rdi,%rbp
call   1090 <getc@plt>
mov    %eax,0xc(%rsp)
mov    0x2e4d(%rip),%rbx
cmp    (%rbx),%eax
je     1318 <shift2seven+0x1a8>
lea    0xe56(%rip),%r12
xor    %r14d,%r14d
jmp    11d4 <shift2seven+0x64>
nop
mov    $0xa,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
xor    %r14d,%r14d
mov    %rbp,%rdi
call   1090 <getc@plt>
mov    %eax,0xc(%rsp)
cmp    (%rbx),%eax
je     1308 <shift2seven+0x198>
cmp    $0xd,%eax
ja     1200 <shift2seven+0x90>
mov    %eax,%ecx
movslq (%r12,%rcx,4),%rcx
add    %r12,%rcx
jmp    *%rcx
test   %r14d,%r14d
je     11b0 <shift2seven+0x40>
mov    %r13,%rdi
mov    %r15d,%esi
call   1060 <KanjiOut@plt>
jmp    11b0 <shift2seven+0x40>
cs nopw 0x0(%rax,%rax,1)
lea    -0x81(%rax),%ecx
cmp    $0x1f,%ecx
jb     1280 <shift2seven+0x110>
mov    %eax,%ecx
and    $0xfffffff0,%ecx
cmp    $0xe0,%ecx
je     1280 <shift2seven+0x110>
lea    -0xa1(%rax),%ecx
cmp    $0x3e,%ecx
ja     12bf <shift2seven+0x14f>
mov    %rbp,%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    0x14(%rsp),%ecx
call   1080 <han2zen@plt>
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1070 <sjis2jis@plt>
test   %r14d,%r14d
jne    125c <shift2seven+0xec>
mov    %r13,%rdi
mov    %r15d,%esi
call   1050 <KanjiIn@plt>
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    %r13,%rdi
lea    0xdca(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%r14d
jmp    11c0 <shift2seven+0x50>
mov    %r15d,%ebx
mov    %rbp,%rdi
call   1090 <getc@plt>
mov    %eax,0x10(%rsp)
add    $0xffffffc0,%eax
cmp    $0xbc,%eax
ja     12da <shift2seven+0x16a>
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1070 <sjis2jis@plt>
mov    $0x1,%r15d
test   %r14d,%r14d
jne    12dd <shift2seven+0x16d>
mov    %r13,%rdi
mov    %ebx,%esi
call   1050 <KanjiIn@plt>
jmp    12dd <shift2seven+0x16d>
test   %r14d,%r14d
je     12d3 <shift2seven+0x163>
mov    %r13,%rdi
mov    %r15d,%esi
call   1060 <KanjiOut@plt>
mov    0xc(%rsp),%eax
mov    %eax,%edi
jmp    11b5 <shift2seven+0x45>
mov    %r14d,%r15d
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    %r13,%rdi
lea    0xd49(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r15d,%r14d
mov    %ebx,%r15d
mov    0x2ce5(%rip),%rbx
jmp    11c0 <shift2seven+0x50>
test   %r14d,%r14d
je     1318 <shift2seven+0x1a8>
mov    %r13,%rdi
mov    %r15d,%esi
call   1060 <KanjiOut@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [3 x i8] c"%c\00"
@.str.1 = [5 x i8] c"%c%c\00"
define void @shift2seven(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
%11 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %12
12: ; preds = %99, %4
%13 = load i32*, i32** %5
%14 = call i32 @getc(i32* %13)
store i32 %14, i32* %10
%15 = load i32, i32* @EOF
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %100
17: ; preds = %12
%18 = load i32, i32* %10
switch i32 %18, label %30 [
i32 0, label %19
i32 12, label %19
i32 13, label %20
i32 10, label %20
]
19: ; preds = %17, %17
br label %99
20: ; preds = %17, %17
%21 = load i32, i32* %9
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %20
store i32 0, i32* %9
%24 = load i32*, i32** %6
%25 = load i32, i32* %7
%26 = call i32 @KanjiOut(i32* %24, i32 %25)
br label %27
27: ; preds = %23, %20
%28 = load i32*, i32** %6
%29 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 10)
br label %99
30: ; preds = %17
%31 = load i32, i32* %10
%32 = icmp sge i32 %31, 129
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32, i32* %10
%35 = icmp sle i32 %34, 159
br i1 %35, label %42, label %36
36: ; preds = %33, %30
%37 = load i32, i32* %10
%38 = icmp sge i32 %37, 224
br i1 %38, label %39, label %64
39: ; preds = %36
%40 = load i32, i32* %10
%41 = icmp sle i32 %40, 239
br i1 %41, label %42, label %64
42: ; preds = %39, %33
%43 = load i32*, i32** %5
%44 = call i32 @getc(i32* %43)
store i32 %44, i32* %11
%45 = load i32, i32* %11
%46 = icmp sge i32 %45, 64
br i1 %46, label %47, label %59
47: ; preds = %42
%48 = load i32, i32* %11
%49 = icmp sle i32 %48, 252
br i1 %49, label %50, label %59
50: ; preds = %47
%51 = call i32 @sjis2jis(i32* %10, i32* %11)
%52 = load i32, i32* %9
%53 = icmp ne i32 %52, 0
br i1 %53, label %58, label %54
54: ; preds = %50
store i32 1, i32* %9
%55 = load i32*, i32** %6
%56 = load i32, i32* %7
%57 = call i32 @KanjiIn(i32* %55, i32 %56)
br label %58
58: ; preds = %54, %50
br label %59
59: ; preds = %58, %47, %42
%60 = load i32*, i32** %6
%61 = load i32, i32* %10
%62 = load i32, i32* %11
%63 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %61, i32 %62)
br label %98
64: ; preds = %39, %36
%65 = load i32, i32* %10
%66 = icmp sge i32 %65, 161
br i1 %66, label %67, label %86
67: ; preds = %64
%68 = load i32, i32* %10
%69 = icmp sle i32 %68, 223
br i1 %69, label %70, label %86
70: ; preds = %67
%71 = load i32*, i32** %5
%72 = load i32, i32* %8
%73 = call i32 @han2zen(i32* %71, i32* %10, i32* %11, i32 %72)
%74 = call i32 @sjis2jis(i32* %10, i32* %11)
%75 = load i32, i32* %9
%76 = icmp ne i32 %75, 0
br i1 %76, label %81, label %77
77: ; preds = %70
store i32 1, i32* %9
%78 = load i32*, i32** %6
%79 = load i32, i32* %7
%80 = call i32 @KanjiIn(i32* %78, i32 %79)
br label %81
81: ; preds = %77, %70
%82 = load i32*, i32** %6
%83 = load i32, i32* %10
%84 = load i32, i32* %11
%85 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %82, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %83, i32 %84)
br label %97
86: ; preds = %67, %64
%87 = load i32, i32* %9
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %93
89: ; preds = %86
store i32 0, i32* %9
%90 = load i32*, i32** %6
%91 = load i32, i32* %7
%92 = call i32 @KanjiOut(i32* %90, i32 %91)
br label %93
93: ; preds = %89, %86
%94 = load i32*, i32** %6
%95 = load i32, i32* %10
%96 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %94, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %95)
br label %97
97: ; preds = %93, %81
br label %98
98: ; preds = %97, %59
br label %99
99: ; preds = %98, %27, %19
br label %12
100: ; preds = %12
%101 = load i32, i32* %9
%102 = icmp ne i32 %101, 0
br i1 %102, label %103, label %107
103: ; preds = %100
%104 = load i32*, i32** %6
%105 = load i32, i32* %7
%106 = call i32 @KanjiOut(i32* %104, i32 %105)
br label %107
107: ; preds = %103, %100
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.1 = [5 x i8] c"%c%c\00"
define void @shift2seven(i32* %0, i32* %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 %71, label %12
12: ; preds = %4, %62
%13 = phi i32 [ %64, %62 ], [ %9, %4 ]
%14 = phi i32 [ %63, %62 ], [ 0, %4 ]
switch i32 %13, label %21 [
i32 0, label %62
i32 12, label %62
i32 13, label %15
i32 10, label %15
]
15: ; preds = %12, %12
%16 = icmp eq i32 %14, 0
br i1 %16, label %19, label %17
17: ; preds = %15
%18 = call i32 @KanjiOut(i32* %1, i32 %2)
br label %19
19: ; preds = %17, %15
%20 = call i32 @fputc(i32 10, i32* %1)
br label %62
21: ; preds = %12
%22 = add i32 %13, -129
%23 = icmp ult i32 %22, 31
%24 = and i32 %13, -16
%25 = icmp eq i32 %24, 224
%26 = or i1 %23, %25
br i1 %26, label %27, label %41
27: ; preds = %21
%28 = call i32 @getc(i32* %0)
store i32 %28, i32* %6
%29 = add i32 %28, -64
%30 = icmp ult i32 %29, 189
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = call i32 @sjis2jis(i32* %5, i32* %6)
%33 = icmp eq i32 %14, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 @KanjiIn(i32* %1, i32 %2)
br label %36
36: ; preds = %31, %34, %27
%37 = phi i32 [ 1, %31 ], [ 1, %34 ], [ %14, %27 ]
%38 = load i32, i32* %5
%39 = load i32, i32* %6
%40 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %38, i32 %39)
br label %62
41: ; preds = %21
%42 = add i32 %13, -161
%43 = icmp ult i32 %42, 63
br i1 %43, label %44, label %54
44: ; preds = %41
%45 = call i32 @han2zen(i32* %0, i32* %5, i32* %6, i32 %3)
%46 = call i32 @sjis2jis(i32* %5, i32* %6)
%47 = icmp eq i32 %14, 0
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 @KanjiIn(i32* %1, i32 %2)
br label %50
50: ; preds = %48, %44
%51 = load i32, i32* %5
%52 = load i32, i32* %6
%53 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %51, i32 %52)
br label %62
54: ; preds = %41
%55 = icmp eq i32 %14, 0
br i1 %55, label %59, label %56
56: ; preds = %54
%57 = call i32 @KanjiOut(i32* %1, i32 %2)
%58 = load i32, i32* %5
br label %59
59: ; preds = %56, %54
%60 = phi i32 [ %58, %56 ], [ %13, %54 ]
%61 = call i32 @fputc(i32 %60, i32* %1)
br label %62
62: ; preds = %36, %59, %50, %12, %12, %19
%63 = phi i32 [ %37, %36 ], [ 1, %50 ], [ 0, %59 ], [ 0, %19 ], [ %14, %12 ], [ %14, %12 ]
%64 = call i32 @getc(i32* %0)
store i32 %64, i32* %5
%65 = load i32, i32* @EOF
%66 = icmp eq i32 %64, %65
br i1 %66, label %67, label %12
67: ; preds = %62
%68 = icmp eq i32 %63, 0
br i1 %68, label %71, label %69
69: ; preds = %67
%70 = call i32 @KanjiOut(i32* %1, i32 %2)
br label %71
71: ; preds = %4, %69, %67
ret void
}