#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*/ SkipESCSeq(int /*<<< orphan*/ *, int, int *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, ...);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ jis2sjis(int *, int *);
void seven2shift(FILE *in, FILE *out) {
  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);
      break;
    case 12:
      break;
    default:
      if (shifted_in) {
        p2 = getc(in);
        jis2sjis(&p1, &p2);
        fprintf(out, "%c%c", p1, p2);
      } else
        fprintf(out, "%c", p1);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<seven2shift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e7e(%rip),%rcx
cmp    (%rcx),%eax
je     121c <seven2shift+0xdc>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0xc,%eax
je     11b8 <seven2shift+0x78>
jmp    1186 <seven2shift+0x46>
mov    -0x24(%rbp),%eax
sub    $0x1b,%eax
jne    11bd <seven2shift+0x7d>
jmp    1197 <seven2shift+0x57>
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
lea    -0x14(%rbp),%rdx
call   1040 <SkipESCSeq@plt>
jmp    1217 <seven2shift+0xd7>
jmp    1217 <seven2shift+0xd7>
cmpl   $0x0,-0x14(%rbp)
je     11fd <seven2shift+0xbd>
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
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    0xe0f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1212 <seven2shift+0xd2>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xdf7(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1217 <seven2shift+0xd7>
jmp    1157 <seven2shift+0x17>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seven2shift>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,0x14(%rsp)
call   1070 <getc@plt>
mov    %eax,0xc(%rsp)
mov    0x2e6c(%rip),%r12
cmp    (%r12),%eax
jne    1191 <seven2shift+0x41>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r13
lea    0xe5e(%rip),%rbp
jmp    11d7 <seven2shift+0x87>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1070 <getc@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r15,%rdx
call   1040 <SkipESCSeq@plt>
mov    %rbx,%rdi
call   1070 <getc@plt>
mov    %eax,0xc(%rsp)
cmp    (%r12),%eax
je     1182 <seven2shift+0x32>
cmp    $0xc,%eax
je     11c5 <seven2shift+0x75>
cmp    $0x1b,%eax
je     11b0 <seven2shift+0x60>
cmpl   $0x0,0x14(%rsp)
je     1218 <seven2shift+0xc8>
mov    %rbx,%rdi
call   1070 <getc@plt>
mov    %eax,0x10(%rsp)
lea    0xc(%rsp),%rdi
mov    %r13,%rsi
call   1030 <jis2sjis@plt>
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    %r14,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    11c5 <seven2shift+0x75>
mov    %eax,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
jmp    11c5 <seven2shift+0x75>

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 @seven2shift(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %9
9: ; preds = %39, %2
%10 = load i32*, i32** %3
%11 = call i32 @getc(i32* %10)
store i32 %11, i32* %7
%12 = load i32, i32* @EOF
%13 = icmp ne i32 %11, %12
br i1 %13, label %14, label %40
14: ; preds = %9
%15 = load i32, i32* %7
switch i32 %15, label %23 [
i32 27, label %16
i32 12, label %22
]
16: ; preds = %14
%17 = load i32*, i32** %3
%18 = call i32 @getc(i32* %17)
store i32 %18, i32* %6
%19 = load i32*, i32** %3
%20 = load i32, i32* %6
%21 = call i32 @SkipESCSeq(i32* %19, i32 %20, i32* %5)
br label %39
22: ; preds = %14
br label %39
23: ; preds = %14
%24 = load i32, i32* %5
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %34
26: ; preds = %23
%27 = load i32*, i32** %3
%28 = call i32 @getc(i32* %27)
store i32 %28, i32* %8
%29 = call i32 @jis2sjis(i32* %7, i32* %8)
%30 = load i32*, i32** %4
%31 = load i32, i32* %7
%32 = load i32, i32* %8
%33 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %31, i32 %32)
br label %38
34: ; preds = %23
%35 = load i32*, i32** %4
%36 = load i32, i32* %7
%37 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %34, %26
br label %39
39: ; preds = %38, %22, %16
br label %9
40: ; preds = %9
ret void
}

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