// File: /workspace/github_c_makefile_star2_O0/martincameron[P]towntalk/towntalk.c
// Function: write_byte_string
int write_byte_string( char *bytes, int count, char *output ) {
	int chr, size, idx = 0, length = 0;
	if( output ) {
		output[ length++ ] = '"';
		while( idx < count ) {
			chr = bytes[ idx++ ];
			if( chr == '"' || chr == '\\' ) {
				output[ length++ ] = '\\';
				output[ length++ ] = chr;
			} else if( ( chr & 0x7F ) < 32 || chr == 127 ) {
				output[ length++ ] = '\\';
				output[ length++ ] = '0' + ( ( chr >> 6 ) & 0x3 );
				output[ length++ ] = '0' + ( ( chr >> 3 ) & 0x7 );
				output[ length++ ] = '0' + ( chr & 0x7 );
			} else {
				output[ length++ ] = chr;
			}
		}
		output[ length++ ] = '"';
	} else {
		length = 2;
		while( idx < count && length > 0 ) {
			chr = bytes[ idx++ ];
			if( chr == '"' || chr == '\\' ) {
				size = 2;
			} else if( ( chr & 0x7F ) < 32 || chr == 127 ) {
				size = 4;
			} else {
				size = 1;
			}
			if( MAX_INTEGER - length > size ) {
				length += size;
			} else {
				length = -1;
			}
		}
	}
	return length;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x466f
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x28(%rbp)
movslq %ecx, %rcx
movb $0x22, (%rax,%rcx)
movl -0x24(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x4654
movq -0x8(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x24(%rbp)
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x22, -0x1c(%rbp)
je 0x456f
cmpl $0x5c, -0x1c(%rbp)
jne 0x45a4
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x28(%rbp)
movslq %ecx, %rcx
movb $0x5c, (%rax,%rcx)
movl -0x1c(%rbp), %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x464f
movl -0x1c(%rbp), %eax
andl $0x7f, %eax
cmpl $0x20, %eax
jl 0x45b5
cmpl $0x7f, -0x1c(%rbp)
jne 0x4633
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x28(%rbp)
movslq %ecx, %rcx
movb $0x5c, (%rax,%rcx)
movl -0x1c(%rbp), %eax
sarl $0x6, %eax
andl $0x3, %eax
addl $0x30, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x1c(%rbp), %eax
sarl $0x3, %eax
andl $0x7, %eax
addl $0x30, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x1c(%rbp), %eax
andl $0x7, %eax
addl $0x30, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x464d
movl -0x1c(%rbp), %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x464f
jmp 0x453e
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x28(%rbp)
movslq %ecx, %rcx
movb $0x22, (%rax,%rcx)
jmp 0x470d
movl $0x2, -0x28(%rbp)
movl -0x24(%rbp), %ecx
xorl %eax, %eax
cmpl -0xc(%rbp), %ecx
movb %al, -0x29(%rbp)
jge 0x468d
cmpl $0x0, -0x28(%rbp)
setg %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
testb $0x1, %al
jne 0x4696
jmp 0x470b
movq -0x8(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x24(%rbp)
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x22, -0x1c(%rbp)
je 0x46bb
cmpl $0x5c, -0x1c(%rbp)
jne 0x46c4
movl $0x2, -0x20(%rbp)
jmp 0x46e7
movl -0x1c(%rbp), %eax
andl $0x7f, %eax
cmpl $0x20, %eax
jl 0x46d5
cmpl $0x7f, -0x1c(%rbp)
jne 0x46de
movl $0x4, -0x20(%rbp)
jmp 0x46e5
movl $0x1, -0x20(%rbp)
jmp 0x46e7
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subl -0x28(%rbp), %eax
cmpl -0x20(%rbp), %eax
jle 0x46ff
movl -0x20(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x4706
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
jmp 0x4676
jmp 0x470d
movl -0x28(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)