// File: /workspace/github_c_makefile_star2_O0/sprt[P]lossless-transport/src/sender.c
// Function: main
int main(int argc, char **argv) {
	parse_args(argc, argv, &hostname, &port, &filename);

	/* Initial window assumed to be 1, will be updated on ACKs */
	w = window_create(1, MAX_WINDOW_SIZE, 255);
	if (w == NULL) {
		exit_msg("Could not create window\n");
	}

	struct sockaddr_in6 dst_addr;
	const char *err = real_address(hostname, &dst_addr);
	if (err != NULL) {
		exit_msg("real_address: %s\n", err);
	}

	/* Connect the socket. This tells the socket both to send to this
	 * address by default and to only receive from this address. */
	sockfd = create_socket(NULL, -1, &dst_addr, port);
	if (sockfd == -1) {
		exit_msg("Could not create socket\n");
	}

	if (filename == NULL) {
		infile = stdin;
	} else {
		infile = fopen(filename, "rb");
		if (infile == NULL) {
			exit_perror("fopen");
		}
	}

	/* If we haven't sent the EOF packet, we still have data to read.
	 * If the window isn't empty, there are still unacknowledged packets
	 * that we'll potentially have to resend. */
	while (!sent_eof || !window_empty(w)) {
		/* This is probably the line you're looking for */
		main_loop();
	}

	log_msg("EOF acknowledged, quitting\n");

	window_free(w);
	fclose(infile);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x3bac(%rip), %rdx      # 0x7590
leaq 0x3bad(%rip), %rcx      # 0x7598
leaq 0x3bae(%rip), %r8       # 0x75a0
callq 0x2020
movl $0x1, %edi
movl $0x1f, %esi
movl $0xff, %edx
callq 0x25a0
movq %rax, 0x3b66(%rip)      # 0x7578
cmpq $0x0, 0x3b5e(%rip)      # 0x7578
jne 0x3a2a
leaq 0xb29(%rip), %rdi       # 0x454c
movb $0x0, %al
callq 0x1db0
movq 0x3b5f(%rip), %rdi      # 0x7590
leaq -0x2c(%rbp), %rsi
callq 0x2170
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x3a57
movq -0x38(%rbp), %rsi
leaq 0xb15(%rip), %rdi       # 0x4565
movb $0x0, %al
callq 0x1db0
movzwl 0x3b3a(%rip), %ecx      # 0x7598
xorl %eax, %eax
movl %eax, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq -0x2c(%rbp), %rdx
callq 0x2240
movl %eax, 0x36c6(%rip)      # 0x713c
cmpl $-0x1, 0x36bf(%rip)     # 0x713c
jne 0x3a8d
leaq 0xaf1(%rip), %rdi       # 0x4577
movb $0x0, %al
callq 0x1db0
cmpq $0x0, 0x3b0b(%rip)      # 0x75a0
jne 0x3aaa
movq 0x352a(%rip), %rax      # 0x6fc8
movq (%rax), %rax
movq %rax, 0x3ae0(%rip)      # 0x7588
jmp 0x3adc
movq 0x3aef(%rip), %rdi      # 0x75a0
leaq 0xad8(%rip), %rsi       # 0x4590
callq 0x1180
movq %rax, 0x3ac4(%rip)      # 0x7588
cmpq $0x0, 0x3abc(%rip)      # 0x7588
jne 0x3ada
leaq 0xabe(%rip), %rdi       # 0x4593
callq 0x1e60
jmp 0x3adc
jmp 0x3ade
movb $0x1, %al
testb $0x1, 0x3a99(%rip)      # 0x7580
movb %al, -0x39(%rbp)
je 0x3afd
movq 0x3a85(%rip), %rdi      # 0x7578
callq 0x2a00
xorb $-0x1, %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x3b06
jmp 0x3b0d
callq 0x3180
jmp 0x3ade
leaq 0xa85(%rip), %rdi       # 0x4599
movb $0x0, %al
callq 0x1ce0
movq 0x3a56(%rip), %rdi      # 0x7578
callq 0x2630
movq 0x3a5a(%rip), %rdi      # 0x7588
callq 0x10b0
xorl %eax, %eax
addq $0x40, %rsp
popq %rbp
retq