#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*/ BUFSIZ;
int /*<<< orphan*/ check_io(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ *fgets(char *, int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int strlen(char *);
void output_remark(FILE *output, char *oname, FILE *remark, char *rname) {
  char buf[BUFSIZ + 1];
  fprintf(output, "---remark---\n");
  check_io(output, oname, 0);
  while (fgets(buf, BUFSIZ, remark) != NULL) {
    fputs(buf, output);
    check_io(output, oname, 0);
  }
  check_io(remark, rname, 1);
  if (buf[strlen(buf) - 1] != '\n') {
    fputc('\n', output);
    check_io(output, oname, 0);
  }
}


x86 assembly (clang, -O0):
<output_remark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1080 <check_io@plt>
mov    -0x38(%rbp),%rdi
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rdx
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1207 <output_remark+0xa7>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <fputs@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1080 <check_io@plt>
jmp    11c6 <output_remark+0x66>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1080 <check_io@plt>
mov    -0x38(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     1258 <output_remark+0xf8>
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1080 <check_io@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_remark>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,-0x30(%rbp)
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r13
mov    0x2e5e(%rip),%r15
mov    (%r15),%eax
add    $0x1,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe60(%rip),%rdi
mov    $0xd,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1080 <fwrite@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1070 <check_io@plt>
mov    (%r15),%esi
mov    %rbx,%rdi
mov    %r12,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11ed <output_remark+0x8d>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <fputs@plt>
jmp    11c0 <output_remark+0x60>
mov    %r12,%rdi
mov    -0x30(%rbp),%rsi
mov    $0x1,%edx
call   1070 <check_io@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
je     1229 <output_remark+0xc9>
mov    $0xa,%edi
mov    %r13,%rsi
call   1050 <fputc@plt>
mov    %r13,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1070 <check_io@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [14 x i8] c"---remark---\0A\00"
define void @output_remark(i32* %0, i8* %1, i32* %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i8* %3, i8** %8
%11 = load i32, i32* @BUFSIZ
%12 = add nsw i32 %11, 1
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %9
%15 = alloca i8, i64 %13
store i64 %13, i64* %10
%16 = load i32*, i32** %5
%17 = call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%18 = load i32*, i32** %5
%19 = load i8*, i8** %6
%20 = call i32 @check_io(i32* %18, i8* %19, i32 0)
br label %21
21: ; preds = %26, %4
%22 = load i32, i32* @BUFSIZ
%23 = load i32*, i32** %7
%24 = call i32* @fgets(i8* %15, i32 %22, i32* %23)
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %32
26: ; preds = %21
%27 = load i32*, i32** %5
%28 = call i32 @fputs(i8* %15, i32* %27)
%29 = load i32*, i32** %5
%30 = load i8*, i8** %6
%31 = call i32 @check_io(i32* %29, i8* %30, i32 0)
br label %21
32: ; preds = %21
%33 = load i32*, i32** %7
%34 = load i8*, i8** %8
%35 = call i32 @check_io(i32* %33, i8* %34, i32 1)
%36 = call i32 @strlen(i8* %15)
%37 = sub nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %15, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 10
br i1 %42, label %43, label %49
43: ; preds = %32
%44 = load i32*, i32** %5
%45 = call i32 @fputc(i8 signext 10, i32* %44)
%46 = load i32*, i32** %5
%47 = load i8*, i8** %6
%48 = call i32 @check_io(i32* %46, i8* %47, i32 0)
br label %49
49: ; preds = %43, %32
%50 = load i8*, i8** %9
ret void
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [14 x i8] c"---remark---\0A\00"
define void @output_remark(i32* %0, i8* %1, i32* %2, i8* %3) {
%5 = load i32, i32* @BUFSIZ
%6 = add nsw i32 %5, 1
%7 = zext i32 %6 to i64
%8 = alloca i8, i64 %7
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 13, i64 1, i32* %0)
%10 = tail call i32 @check_io(i32* %0, i8* %1, i32 0)
%11 = load i32, i32* @BUFSIZ
%12 = call i32* @fgets(i8* %8, i32 %11, i32* %2)
%13 = icmp eq i32* %12, null
br i1 %13, label %20, label %14
14: ; preds = %4, %14
%15 = call i32 @fputs(i8* %8, i32* %0)
%16 = call i32 @check_io(i32* %0, i8* %1, i32 0)
%17 = load i32, i32* @BUFSIZ
%18 = call i32* @fgets(i8* %8, i32 %17, i32* %2)
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %14
20: ; preds = %14, %4
%21 = call i32 @check_io(i32* %2, i8* %3, i32 1)
%22 = call i32 @strlen(i8* %8)
%23 = add nsw i32 %22, -1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %8, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 10
br i1 %27, label %31, label %28
28: ; preds = %20
%29 = call i32 @fputc(i8 signext 10, i32* %0)
%30 = call i32 @check_io(i32* %0, i8* %1, i32 0)
br label %31
31: ; preds = %28, %20
ret void
}