#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*/ SkipESCSeq(int /*<<< orphan*/ *, int, int *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, ...);
int getc(int /*<<< orphan*/ *);
void seven2seven(FILE *in, FILE *out, int outcode) {
  int shifted_in, temp, p1, p2;
  shifted_in = 0;
  while ((p1 = getc(in)) != EOF) {
    switch (p1) {
    case 27:
      temp = getc(in);
      SkipESCSeq(in, temp, &shifted_in);
      if (shifted_in)
        KanjiIn(out, outcode);
      else
        KanjiOut(out, outcode);
      break;
    case 10:
      if (shifted_in) {
        shifted_in = 0;
        KanjiOut(out, outcode);
      }
      fprintf(out, "%c", p1);
      break;
    case 12:
      break;
    default:
      if (shifted_in) {
        p2 = getc(in);
        fprintf(out, "%c%c", p1, p2);
      } else
        fprintf(out, "%c", p1);
      break;
    }
  }
  if (shifted_in)
    KanjiOut(out, outcode);
}


x86 assembly (clang, -O0):
<seven2seven>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x20(%rbp)
mov    0x2e6b(%rip),%rcx
cmp    (%rcx),%eax
je     1291 <seven2seven+0x141>
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0xa,%eax
je     1203 <seven2seven+0xb3>
jmp    1199 <seven2seven+0x49>
mov    -0x28(%rbp),%eax
sub    $0xc,%eax
je     123a <seven2seven+0xea>
jmp    11aa <seven2seven+0x5a>
mov    -0x28(%rbp),%eax
sub    $0x1b,%eax
jne    123f <seven2seven+0xef>
jmp    11bb <seven2seven+0x6b>
mov    -0x8(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0x18(%rbp),%rdx
call   1030 <SkipESCSeq@plt>
cmpl   $0x0,-0x18(%rbp)
je     11f2 <seven2seven+0xa2>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <KanjiIn@plt>
jmp    11fe <seven2seven+0xae>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <KanjiOut@plt>
jmp    128c <seven2seven+0x13c>
cmpl   $0x0,-0x18(%rbp)
je     1220 <seven2seven+0xd0>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <KanjiOut@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    128c <seven2seven+0x13c>
jmp    128c <seven2seven+0x13c>
cmpl   $0x0,-0x18(%rbp)
je     1272 <seven2seven+0x122>
mov    -0x8(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xd9a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1287 <seven2seven+0x137>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xd82(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    128c <seven2seven+0x13c>
jmp    116a <seven2seven+0x1a>
cmpl   $0x0,-0x18(%rbp)
je     12a7 <seven2seven+0x157>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <KanjiOut@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seven2seven>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r13
mov    %rdi,%rbp
movl   $0x0,0x4(%rsp)
call   1080 <getc@plt>
mov    0x2e60(%rip),%r12
cmp    (%r12),%eax
je     1272 <seven2seven+0x112>
mov    %eax,%ebx
lea    0x4(%rsp),%r15
jmp    11c1 <seven2seven+0x61>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %r13,%rsi
call   1040 <fputc@plt>
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %eax,%ebx
cmp    (%r12),%eax
je     1260 <seven2seven+0x100>
cmp    $0xa,%ebx
je     1200 <seven2seven+0xa0>
cmp    $0xc,%ebx
je     11ad <seven2seven+0x4d>
cmp    $0x1b,%ebx
jne    1220 <seven2seven+0xc0>
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %rbp,%rdi
mov    %eax,%esi
mov    %r15,%rdx
call   1030 <SkipESCSeq@plt>
cmpl   $0x0,0x4(%rsp)
je     1249 <seven2seven+0xe9>
mov    %r13,%rdi
mov    %r14d,%esi
call   1060 <KanjiIn@plt>
jmp    11ad <seven2seven+0x4d>
nopl   0x0(%rax)
cmpl   $0x0,0x4(%rsp)
je     11a0 <seven2seven+0x40>
movl   $0x0,0x4(%rsp)
mov    %r13,%rdi
mov    %r14d,%esi
call   1070 <KanjiOut@plt>
jmp    11a0 <seven2seven+0x40>
nopl   0x0(%rax)
cmpl   $0x0,0x4(%rsp)
je     1259 <seven2seven+0xf9>
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %r13,%rdi
lea    0xdc7(%rip),%rsi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11ad <seven2seven+0x4d>
mov    %r13,%rdi
mov    %r14d,%esi
call   1070 <KanjiOut@plt>
jmp    11ad <seven2seven+0x4d>
mov    %ebx,%edi
jmp    11a5 <seven2seven+0x45>
cmpl   $0x0,0x4(%rsp)
je     1272 <seven2seven+0x112>
mov    %r13,%rdi
mov    %r14d,%esi
call   1070 <KanjiOut@plt>
add    $0x8,%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 @seven2seven(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %11
11: ; preds = %62, %3
%12 = load i32*, i32** %4
%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 %63
16: ; preds = %11
%17 = load i32, i32* %9
switch i32 %17, label %47 [
i32 27, label %18
i32 10, label %35
i32 12, label %46
]
18: ; preds = %16
%19 = load i32*, i32** %4
%20 = call i32 @getc(i32* %19)
store i32 %20, i32* %8
%21 = load i32*, i32** %4
%22 = load i32, i32* %8
%23 = call i32 @SkipESCSeq(i32* %21, i32 %22, i32* %7)
%24 = load i32, i32* %7
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %18
%27 = load i32*, i32** %5
%28 = load i32, i32* %6
%29 = call i32 @KanjiIn(i32* %27, i32 %28)
br label %34
30: ; preds = %18
%31 = load i32*, i32** %5
%32 = load i32, i32* %6
%33 = call i32 @KanjiOut(i32* %31, i32 %32)
br label %34
34: ; preds = %30, %26
br label %62
35: ; preds = %16
%36 = load i32, i32* %7
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %35
store i32 0, i32* %7
%39 = load i32*, i32** %5
%40 = load i32, i32* %6
%41 = call i32 @KanjiOut(i32* %39, i32 %40)
br label %42
42: ; preds = %38, %35
%43 = load i32*, i32** %5
%44 = load i32, i32* %9
%45 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %44)
br label %62
46: ; preds = %16
br label %62
47: ; preds = %16
%48 = load i32, i32* %7
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %57
50: ; preds = %47
%51 = load i32*, i32** %4
%52 = call i32 @getc(i32* %51)
store i32 %52, i32* %10
%53 = load i32*, i32** %5
%54 = load i32, i32* %9
%55 = load i32, i32* %10
%56 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %54, i32 %55)
br label %61
57: ; preds = %47
%58 = load i32*, i32** %5
%59 = load i32, i32* %9
%60 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %59)
br label %61
61: ; preds = %57, %50
br label %62
62: ; preds = %61, %46, %42, %34
br label %11
63: ; preds = %11
%64 = load i32, i32* %7
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %70
66: ; preds = %63
%67 = load i32*, i32** %5
%68 = load i32, i32* %6
%69 = call i32 @KanjiOut(i32* %67, i32 %68)
br label %70
70: ; preds = %66, %63
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.1 = [5 x i8] c"%c%c\00"
define void @seven2seven(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%6 = call i32 @getc(i32* %0)
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %44, label %9
9: ; preds = %3, %35
%10 = phi i32 [ %36, %35 ], [ %6, %3 ]
switch i32 %10, label %27 [
i32 27, label %11
i32 10, label %20
i32 12, label %35
]
11: ; preds = %9
%12 = call i32 @getc(i32* %0)
%13 = call i32 @SkipESCSeq(i32* %0, i32 %12, i32* %4)
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %11
%17 = call i32 @KanjiIn(i32* %1, i32 %2)
br label %35
18: ; preds = %11
%19 = call i32 @KanjiOut(i32* %1, i32 %2)
br label %35
20: ; preds = %9
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %20
store i32 0, i32* %4
%24 = call i32 @KanjiOut(i32* %1, i32 %2)
br label %25
25: ; preds = %23, %20
%26 = call i32 @fputc(i32 10, i32* %1)
br label %35
27: ; preds = %9
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = call i32 @getc(i32* %0)
%32 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %31)
br label %35
33: ; preds = %27
%34 = call i32 @fputc(i32 %10, i32* %1)
br label %35
35: ; preds = %30, %33, %16, %18, %9, %25
%36 = call i32 @getc(i32* %0)
%37 = load i32, i32* @EOF
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %9
39: ; preds = %35
%40 = load i32, i32* %4
%41 = icmp eq i32 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = call i32 @KanjiOut(i32* %1, i32 %2)
br label %44
44: ; preds = %3, %42, %39
ret void
}