// File: /workspace/github_c_makefile_star2_O0/martincameron[P]towntalk/towntalk.c
// Function: write_element
static int write_element( struct element *elem, char *output ) {
	int size, length = 0;
	if( output ) {
		while( elem ) {
			if( elem->child ) {
				output[ length++ ] = elem->str.string[ 0 ];
				length += write_element( elem->child, &output[ length ] );
				output[ length++ ] = elem->str.string[ 1 ];
			} else {
				memcpy( &output[ length ], elem->str.string, sizeof( char ) * elem->str.length );
				length += elem->str.length;
				output[ length++ ] = '\n';
			}
			elem = elem->next;
		}
	} else {
		while( elem && length >= 0 ) {
			if( elem->child ) {
				size = write_element( elem->child, NULL );
				if( size >= 0 && MAX_INTEGER - length - 2 > size ) {
					length += size + 2;
				} else {
					length = -1;
				}
			} else {
				size = elem->str.length;
				if( MAX_INTEGER - length - 1 > size ) {
					length += size + 1;
				} else {
					length = -1;
				}
			}
			elem = elem->next;
		}
	}
	return length;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x13cb6
jmp 0x13be4
cmpq $0x0, -0x8(%rbp)
je 0x13cb1
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x13c59
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movb (%rax), %dl
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x18(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
movslq -0x18(%rbp), %rax
addq %rax, %rsi
callq 0x13bc0
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movb 0x1(%rax), %dl
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x18(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x13ca0
movq -0x10(%rbp), %rdi
movslq -0x18(%rbp), %rax
addq %rax, %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x8(%rbp), %rax
movslq 0x10(%rax), %rdx
shlq $0x0, %rdx
callq 0x3170
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x18(%rbp)
movslq %ecx, %rcx
movb $0xa, (%rax,%rcx)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x13be4
jmp 0x13d6a
jmp 0x13cb8
xorl %eax, %eax
cmpq $0x0, -0x8(%rbp)
movb %al, -0x19(%rbp)
je 0x13cce
cmpl $0x0, -0x18(%rbp)
setge %al
movb %al, -0x19(%rbp)
movb -0x19(%rbp), %al
testb $0x1, %al
jne 0x13cda
jmp 0x13d68
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x13d26
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x13bc0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0x13d1d
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subl -0x18(%rbp), %eax
subl $0x2, %eax
cmpl -0x14(%rbp), %eax
jle 0x13d1d
movl -0x14(%rbp), %eax
addl $0x2, %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x13d24
movl $0xffffffff, -0x18(%rbp) # imm = 0xFFFFFFFF
jmp 0x13d57
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x14(%rbp)
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subl -0x18(%rbp), %eax
subl $0x1, %eax
cmpl -0x14(%rbp), %eax
jle 0x13d4e
movl -0x14(%rbp), %eax
addl $0x1, %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x13d55
movl $0xffffffff, -0x18(%rbp) # imm = 0xFFFFFFFF
jmp 0x13d57
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x13cb8
jmp 0x13d6a
movl -0x18(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)