#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ remove_comments(char *);
int /*<<< orphan*/ remove_trailing_whitespace(char *);
int strlen(char *);
void file_cleanup(FILE *output, FILE *input) {
  char buffer[(1024)];
  while (fgets(buffer, sizeof buffer, input)) {
    remove_comments(buffer);
    remove_trailing_whitespace(buffer);
    if (strlen(buffer) > (1024)) {
      printf("[!] Line too long: %s\n", buffer);
      exit(EXIT_FAILURE);
    }
    fprintf(output, "%s", buffer);
  }
}


x86 assembly (clang, -O0):
<file_cleanup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     120e <file_cleanup+0x9e>
lea    -0x410(%rbp),%rdi
call   1030 <remove_comments@plt>
lea    -0x410(%rbp),%rdi
call   1040 <remove_trailing_whitespace@plt>
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x400,%eax
jle    11f2 <file_cleanup+0x82>
lea    -0x410(%rbp),%rsi
lea    0xe21(%rip),%rdi
call   1060 <printf@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xe13(%rip),%rsi
call   1080 <fprintf@plt>
jmp    1183 <file_cleanup+0x13>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_cleanup>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     11df <file_cleanup+0x6f>
mov    %rsp,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <remove_comments@plt>
mov    %rbx,%rdi
call   1040 <remove_trailing_whitespace@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x401,%eax
jge    11ec <file_cleanup+0x7c>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <fputs@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
jne    11a0 <file_cleanup+0x30>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe0d(%rip),%rdi
mov    %rsp,%rsi
call   1060 <printf@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"[!] Line too long: %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define void @file_cleanup(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [1024 x i8]
store i32* %0, i32** %3
store i32* %1, i32** %4
br label %6
6: ; preds = %24, %2
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%8 = load i32*, i32** %4
%9 = call i64 @fgets(i8* %7, i32 1024, i32* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %28
11: ; preds = %6
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%13 = call i32 @remove_comments(i8* %12)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%15 = call i32 @remove_trailing_whitespace(i8* %14)
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = icmp sgt i32 %17, 1024
br i1 %18, label %19, label %24
19: ; preds = %11
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%21 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %11
%25 = load i32*, i32** %3
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%27 = call i32 @fprintf(i32* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %6
28: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"[!] Line too long: %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @file_cleanup(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i64 @fgets(i8* %4, i32 1024, i32* %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %20, label %7
7: ; preds = %2, %16
%8 = call i32 @remove_comments(i8* %4)
%9 = call i32 @remove_trailing_whitespace(i8* %4)
%10 = call i32 @strlen(i8* %4)
%11 = icmp sgt i32 %10, 1024
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %4)
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %7
%17 = call i32 @fputs(i8* %4, i32* %0)
%18 = call i64 @fgets(i8* %4, i32 1024, i32* %1)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %7
20: ; preds = %16, %2
ret void
}