#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*/ *);
void seven2euc(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 10:
      if (shifted_in) {
        shifted_in = 0;
      }
      fprintf(out, "%c", p1);
      break;
    case 12:
      break;
    default:
      if (shifted_in) {
        p2 = getc(in);
        p1 += 128;
        p2 += 128;
        fprintf(out, "%c%c", p1, p2);
      } else
        fprintf(out, "%c", p1);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<seven2euc>:
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   1050 <getc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e8e(%rip),%rcx
cmp    (%rcx),%eax
je     1251 <seven2euc+0x121>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0xa,%eax
je     11b9 <seven2euc+0x89>
jmp    1176 <seven2euc+0x46>
mov    -0x24(%rbp),%eax
sub    $0xc,%eax
je     11e4 <seven2euc+0xb4>
jmp    1187 <seven2euc+0x57>
mov    -0x24(%rbp),%eax
sub    $0x1b,%eax
jne    11e9 <seven2euc+0xb9>
jmp    1198 <seven2euc+0x68>
mov    -0x8(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
lea    -0x14(%rbp),%rdx
call   1030 <SkipESCSeq@plt>
jmp    124c <seven2euc+0x11c>
cmpl   $0x0,-0x14(%rbp)
je     11ca <seven2euc+0x9a>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe2a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    124c <seven2euc+0x11c>
jmp    124c <seven2euc+0x11c>
cmpl   $0x0,-0x14(%rbp)
je     1232 <seven2euc+0x102>
mov    -0x8(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x20(%rbp)
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    0xdda(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1247 <seven2euc+0x117>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xdc2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    124c <seven2euc+0x11c>
jmp    1147 <seven2euc+0x17>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seven2euc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,0x4(%rsp)
call   1060 <getc@plt>
mov    0x2e83(%rip),%r13
cmp    0x0(%r13),%eax
jne    117a <seven2euc+0x3a>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
lea    0x4(%rsp),%r15
lea    0xe78(%rip),%r12
jmp    11b5 <seven2euc+0x75>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r15,%rdx
call   1030 <SkipESCSeq@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %eax,%ebp
cmp    0x0(%r13),%eax
je     116b <seven2euc+0x2b>
cmp    $0xa,%ebp
je     11f0 <seven2euc+0xb0>
cmp    $0xc,%ebp
je     11a5 <seven2euc+0x65>
cmp    $0x1b,%ebp
je     1190 <seven2euc+0x50>
cmpl   $0x0,0x4(%rsp)
je     1206 <seven2euc+0xc6>
mov    %rbx,%rdi
call   1060 <getc@plt>
sub    $0xffffff80,%ebp
lea    0x80(%rax),%ecx
mov    %r14,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11a5 <seven2euc+0x65>
nopl   (%rax)
cmpl   $0x0,0x4(%rsp)
je     11ff <seven2euc+0xbf>
movl   $0x0,0x4(%rsp)
mov    $0xa,%edi
jmp    1208 <seven2euc+0xc8>
mov    %ebp,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
jmp    11a5 <seven2euc+0x65>

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 @seven2euc(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 = %50, %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 %51
14: ; preds = %9
%15 = load i32, i32* %7
switch i32 %15, label %31 [
i32 27, label %16
i32 10, label %22
i32 12, label %30
]
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 %50
22: ; preds = %14
%23 = load i32, i32* %5
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %22
store i32 0, i32* %5
br label %26
26: ; preds = %25, %22
%27 = load i32*, i32** %4
%28 = load i32, i32* %7
%29 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %28)
br label %50
30: ; preds = %14
br label %50
31: ; preds = %14
%32 = load i32, i32* %5
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %45
34: ; preds = %31
%35 = load i32*, i32** %3
%36 = call i32 @getc(i32* %35)
store i32 %36, i32* %8
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 128
store i32 %38, i32* %7
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 128
store i32 %40, i32* %8
%41 = load i32*, i32** %4
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %42, i32 %43)
br label %49
45: ; preds = %31
%46 = load i32*, i32** %4
%47 = load i32, i32* %7
%48 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %45, %34
br label %50
50: ; preds = %49, %30, %26, %16
br label %9
51: ; preds = %9
ret void
}

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