#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 */
char EOF;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
void f2v(FILE *inputFile, FILE *outputFile) {
  char tmpChar;
  while ((tmpChar = fgetc(inputFile)) != EOF) {
    if (tmpChar == '{') {
      fprintf(outputFile, "begin");
    } else if (tmpChar == '}') {
      fprintf(outputFile, "end");
    } else {
      fputc(tmpChar, outputFile);
    }
  }
}


x86 assembly (clang, -O0):
<f2v>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e92(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11be <f2v+0x8e>
movsbl -0x11(%rbp),%eax
cmp    $0x7b,%eax
jne    1183 <f2v+0x53>
mov    -0x10(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11b9 <f2v+0x89>
movsbl -0x11(%rbp),%eax
cmp    $0x7d,%eax
jne    11a5 <f2v+0x75>
mov    -0x10(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11b4 <f2v+0x84>
mov    -0x11(%rbp),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1040 <fputc@plt>
jmp    11b9 <f2v+0x89>
jmp    1140 <f2v+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f2v>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <fgetc@plt>
mov    0x2e9d(%rip),%r13
cmp    0x0(%r13),%al
jne    115b <f2v+0x2b>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xea4(%rip),%r15
lea    0xe97(%rip),%r12
jmp    1189 <f2v+0x59>
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    0x0(%r13),%al
je     1151 <f2v+0x21>
cmp    $0x7d,%al
je     11a0 <f2v+0x70>
cmp    $0x7b,%al
jne    1170 <f2v+0x40>
mov    $0x5,%esi
mov    $0x1,%edx
mov    %r12,%rdi
jmp    11ad <f2v+0x7d>
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %r14,%rcx
call   1050 <fwrite@plt>
jmp    117b <f2v+0x4b>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [6 x i8] c"begin\00"
@.str.1 = [4 x i8] c"end\00"
define void @f2v(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8
store i32* %0, i32** %3
store i32* %1, i32** %4
br label %6
6: ; preds = %32, %2
%7 = load i32*, i32** %3
%8 = call signext i8 @fgetc(i32* %7)
store i8 %8, i8* %5
%9 = sext i8 %8 to i32
%10 = load i8, i8* @EOF
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %9, %11
br i1 %12, label %13, label %33
13: ; preds = %6
%14 = load i8, i8* %5
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 123
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32*, i32** %4
%19 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %32
20: ; preds = %13
%21 = load i8, i8* %5
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 125
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32*, i32** %4
%26 = call i32 @fprintf(i32* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %31
27: ; preds = %20
%28 = load i8, i8* %5
%29 = load i32*, i32** %4
%30 = call i32 @fputc(i8 signext %28, i32* %29)
br label %31
31: ; preds = %27, %24
br label %32
32: ; preds = %31, %17
br label %6
33: ; preds = %6
ret void
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [6 x i8] c"begin\00"
@.str.1 = [4 x i8] c"end\00"
define void @f2v(i32* nocapture %0, i32* nocapture %1) {
%3 = tail call signext i8 @fgetc(i32* %0)
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %18, label %6
6: ; preds = %2, %14
%7 = phi i8 [ %15, %14 ], [ %3, %2 ]
switch i8 %7, label %12 [
i8 123, label %8
i8 125, label %10
]
8: ; preds = %6
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 5, i64 1, i32* %1)
br label %14
10: ; preds = %6
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 3, i64 1, i32* %1)
br label %14
12: ; preds = %6
%13 = tail call i32 @fputc(i8 signext %7, i32* %1)
br label %14
14: ; preds = %10, %12, %8
%15 = tail call signext i8 @fgetc(i32* %0)
%16 = load i8, i8* @EOF
%17 = icmp eq i8 %15, %16
br i1 %17, label %18, label %6
18: ; preds = %14, %2
ret void
}