#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 /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ reverse(char *);
int main() {
  FILE *fin = fopen("input.txt", "r");
  FILE *fout = fopen("output.txt", "w");
  char line[200];
  while (fgets(line, sizeof line, fin) != NULL) {
    reverse(line);
    fprintf(fout, "%s", line);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    0xeaa(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe9c(%rip),%rdi
lea    0xea0(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xc8,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11c7 <main+0x87>
lea    -0xe0(%rbp),%rdi
call   1030 <reverse@plt>
mov    -0x18(%rbp),%rdi
lea    -0xe0(%rbp),%rdx
lea    0xe5c(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1180 <main+0x40>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xd0,%rsp
lea    0xead(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xea3(%rip),%rdi
lea    0xea7(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0xc8,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11b8 <main+0x78>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <reverse@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <fputs@plt>
mov    %rbx,%rdi
mov    $0xc8,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    1190 <main+0x50>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"output.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [200 x i8]
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
%6 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %6, i32** %3
br label %7
7: ; preds = %12, %0
%8 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%9 = load i32*, i32** %2
%10 = call i32* @fgets(i8* %8, i32 200, i32* %9)
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %18
12: ; preds = %7
%13 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%14 = call i32 @reverse(i8* %13)
%15 = load i32*, i32** %3
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%17 = call i32 @fprintf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %16)
br label %7
18: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"output.txt\00"
@.str.3 = [2 x i8] c"w\00"
define i32 @main() {
%1 = alloca [200 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%5 = call i32* @fgets(i8* %4, i32 200, i32* %2)
%6 = icmp eq i32* %5, null
br i1 %6, label %12, label %7
7: ; preds = %0, %7
%8 = call i32 @reverse(i8* %4)
%9 = call i32 @fputs(i8* %4, i32* %3)
%10 = call i32* @fgets(i8* %4, i32 200, i32* %2)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %7
12: ; preds = %7, %0
ret i32 0
}