#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*/ sjis2jis(int *, int *);
void euc2euc(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))
          fprintf(out, "%c%c", p1, p2);
      } else if (p1 == 142) {
        p2 = getc(in);
        if (((p2 >= 161) && (p2 <= 223)) && (tofullsize)) {
          p1 = p2;
          han2zen(in, &p1, &p2, incode);
          sjis2jis(&p1, &p2);
          p1 += 128;
          p2 += 128;
        }
        fprintf(out, "%c%c", p1, p2);
      } else
        fprintf(out, "%c", p1);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<euc2euc>:
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     129f <euc2euc+0x15f>
mov    -0x1c(%rbp),%eax
sub    $0xc,%eax
jne    1187 <euc2euc+0x47>
jmp    1182 <euc2euc+0x42>
jmp    129a <euc2euc+0x15a>
cmpl   $0xa1,-0x1c(%rbp)
jl     11e4 <euc2euc+0xa4>
cmpl   $0xfe,-0x1c(%rbp)
jg     11e4 <euc2euc+0xa4>
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xa1,-0x20(%rbp)
jl     11df <euc2euc+0x9f>
cmpl   $0xfe,-0x20(%rbp)
jg     11df <euc2euc+0x9f>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe28(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1295 <euc2euc+0x155>
cmpl   $0x8e,-0x1c(%rbp)
jne    127b <euc2euc+0x13b>
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xa1,-0x20(%rbp)
jl     125e <euc2euc+0x11e>
cmpl   $0xdf,-0x20(%rbp)
jg     125e <euc2euc+0x11e>
cmpl   $0x0,-0x18(%rbp)
je     125e <euc2euc+0x11e>
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>
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <sjis2jis@plt>
mov    -0x1c(%rbp),%eax
add    $0x80,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x80,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xd91(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1290 <euc2euc+0x150>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xd79(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1295 <euc2euc+0x155>
jmp    129a <euc2euc+0x15a>
jmp    1156 <euc2euc+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<euc2euc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r14d
mov    %edx,0xc(%rsp)
mov    %rsi,%r15
mov    %rdi,%rbx
call   1070 <getc@plt>
mov    %eax,0x4(%rsp)
mov    0x2e6d(%rip),%r13
cmp    0x0(%r13),%eax
jne    1190 <euc2euc+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe69(%rip),%rbp
mov    %r15,0x10(%rsp)
jmp    11c3 <euc2euc+0x73>
mov    0x4(%rsp),%edx
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1070 <getc@plt>
mov    %eax,0x4(%rsp)
cmp    0x0(%r13),%eax
je     1181 <euc2euc+0x31>
cmp    $0xc,%eax
je     11b1 <euc2euc+0x61>
lea    -0xa1(%rax),%ecx
cmp    $0x5d,%ecx
ja     1200 <euc2euc+0xb0>
mov    %rbx,%rdi
call   1070 <getc@plt>
mov    %eax,0x8(%rsp)
lea    -0xa1(%rax),%ecx
cmp    $0x5d,%ecx
ja     11b1 <euc2euc+0x61>
mov    0x4(%rsp),%edx
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %eax,%ecx
jmp    11aa <euc2euc+0x5a>
nopl   0x0(%rax,%rax,1)
cmp    $0x8e,%eax
jne    127a <euc2euc+0x12a>
mov    %rbx,%rdi
call   1070 <getc@plt>
mov    %eax,0x8(%rsp)
test   %r14d,%r14d
je     119e <euc2euc+0x4e>
mov    %eax,%ecx
add    $0xffffff5f,%ecx
cmp    $0x3f,%ecx
jae    119e <euc2euc+0x4e>
mov    %eax,0x4(%rsp)
mov    %rbx,%rdi
mov    %r14d,%r15d
lea    0x4(%rsp),%r14
mov    %r14,%rsi
lea    0x8(%rsp),%r12
mov    %r12,%rdx
mov    0xc(%rsp),%ecx
call   1060 <han2zen@plt>
mov    %r14,%rdi
mov    %r15d,%r14d
mov    0x10(%rsp),%r15
mov    %r12,%rsi
call   1050 <sjis2jis@plt>
mov    0x4(%rsp),%edx
sub    $0xffffff80,%edx
mov    %edx,0x4(%rsp)
mov    0x8(%rsp),%eax
sub    $0xffffff80,%eax
mov    %eax,0x8(%rsp)
jmp    11a2 <euc2euc+0x52>
mov    %eax,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
jmp    11b1 <euc2euc+0x61>

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 @euc2euc(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 = %74, %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 %75
16: ; preds = %11
%17 = load i32, i32* %9
switch i32 %17, label %19 [
i32 12, label %18
]
18: ; preds = %16
br label %74
19: ; preds = %16
%20 = load i32, i32* %9
%21 = icmp sge i32 %20, 161
br i1 %21, label %22, label %39
22: ; preds = %19
%23 = load i32, i32* %9
%24 = icmp sle i32 %23, 254
br i1 %24, label %25, label %39
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 %38
30: ; preds = %25
%31 = load i32, i32* %10
%32 = icmp sle i32 %31, 254
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load i32*, i32** %6
%35 = load i32, i32* %9
%36 = load i32, i32* %10
%37 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %35, i32 %36)
br label %38
38: ; preds = %33, %30, %25
br label %73
39: ; preds = %22, %19
%40 = load i32, i32* %9
%41 = icmp eq i32 %40, 142
br i1 %41, label %42, label %68
42: ; preds = %39
%43 = load i32*, i32** %5
%44 = call i32 @getc(i32* %43)
store i32 %44, i32* %10
%45 = load i32, i32* %10
%46 = icmp sge i32 %45, 161
br i1 %46, label %47, label %63
47: ; preds = %42
%48 = load i32, i32* %10
%49 = icmp sle i32 %48, 223
br i1 %49, label %50, label %63
50: ; preds = %47
%51 = load i32, i32* %8
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %63
53: ; preds = %50
%54 = load i32, i32* %10
store i32 %54, i32* %9
%55 = load i32*, i32** %5
%56 = load i32, i32* %7
%57 = call i32 @han2zen(i32* %55, i32* %9, i32* %10, i32 %56)
%58 = call i32 @sjis2jis(i32* %9, i32* %10)
%59 = load i32, i32* %9
%60 = add nsw i32 %59, 128
store i32 %60, i32* %9
%61 = load i32, i32* %10
%62 = add nsw i32 %61, 128
store i32 %62, i32* %10
br label %63
63: ; preds = %53, %50, %47, %42
%64 = load i32*, i32** %6
%65 = load i32, i32* %9
%66 = load i32, i32* %10
%67 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %65, i32 %66)
br label %72
68: ; preds = %39
%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 = %68, %63
br label %73
73: ; preds = %72, %38
br label %74
74: ; preds = %73, %18
br label %11
75: ; preds = %11
ret void
}

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