#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(int);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
size_t fwrite(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
void emit(char *sol, char *eol, FILE *output_stream) {
  size_t ntowrite = eol - sol;
  size_t nwritten = fwrite(sol, 1, ntowrite, output_stream);
  if (nwritten != ntowrite) {
    perror("fwrite");
    exit(1);
  }
  fputc('\n', output_stream);
}


x86 assembly (clang, -O0):
<emit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1060 <fwrite@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     11a1 <emit+0x61>
lea    0xe6e(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%rsi
mov    $0xa,%edi
call   1030 <fputc@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
sub    %rdi,%rbx
mov    $0x1,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1060 <fwrite@plt>
cmp    %rbx,%rax
jne    1176 <emit+0x36>
mov    $0xa,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fputc@plt>
lea    0xe83(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"fwrite\00"
define void @emit(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%9 = load i8*, i8** %5
%10 = load i8*, i8** %4
%11 = ptrtoint i8* %9 to i64
%12 = ptrtoint i8* %10 to i64
%13 = sub i64 %11, %12
store i64 %13, i64* %7
%14 = load i8*, i8** %4
%15 = load i64, i64* %7
%16 = load i32*, i32** %6
%17 = call i64 @fwrite(i8* %14, i32 1, i64 %15, i32* %16)
store i64 %17, i64* %8
%18 = load i64, i64* %8
%19 = load i64, i64* %7
%20 = icmp ne i64 %18, %19
br i1 %20, label %21, label %24
21: ; preds = %3
%22 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %3
%25 = load i32*, i32** %6
%26 = call i32 @fputc(i8 signext 10, i32* %25)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"fwrite\00"
define void @emit(i8* %0, i8* %1, i32* nocapture %2) {
%4 = ptrtoint i8* %1 to i64
%5 = ptrtoint i8* %0 to i64
%6 = sub i64 %4, %5
%7 = tail call i64 @fwrite(i8* %0, i32 1, i64 %6, i32* %2)
%8 = icmp eq i64 %7, %6
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %3
%13 = tail call i32 @fputc(i8 signext 10, i32* %2)
ret void
}