// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: handle_put
static void handle_put(struct connection *conn, const char *path) {
  file_stat_t st;
  const char *range, *cl_hdr = mg_get_header(&conn->mg_conn, "Content-Length");
  int64_t r1, r2;
  int rc;

  conn->mg_conn.status_code = !stat(path, &st) ? 200 : 201;
  if ((rc = put_dir(path)) == 0) {
    mg_printf(&conn->mg_conn, "HTTP/1.1 %d OK\r\n\r\n",
              conn->mg_conn.status_code);
    close_local_endpoint(conn);
  } else if (rc == -1) {
    send_http_error(conn, 500, "put_dir: %s", strerror(errno));
  } else if (cl_hdr == NULL) {
    send_http_error(conn, 411, NULL);
  } else if ((conn->endpoint.fd =
              open(path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0644)) < 0) {
    send_http_error(conn, 500, "open(%s): %s", path, strerror(errno));
  } else {
    DBG(("PUT [%s] %lu", path, (unsigned long) conn->ns_conn->recv_iobuf.len));
    conn->endpoint_type = EP_PUT;
    ns_set_close_on_exec(conn->endpoint.fd);
    range = mg_get_header(&conn->mg_conn, "Content-Range");
    conn->cl = to64(cl_hdr);
    r1 = r2 = 0;
    if (range != NULL && parse_range_header(range, &r1, &r2) > 0) {
      conn->mg_conn.status_code = 206;
      lseek(conn->endpoint.fd, r1, SEEK_SET);
      conn->cl = r2 > r1 ? r2 - r1 + 1: conn->cl - r1;
    }
    mg_printf(&conn->mg_conn, "HTTP/1.1 %d OK\r\nContent-Length: 0\r\n\r\n",
              conn->mg_conn.status_code);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
leaq 0x5b33(%rip), %rsi      # 0xc2e35
callq 0xb0fe0
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0xdd10
cmpl $0x0, %eax
setne %dl
xorb $-0x1, %dl
movl $0xc9, %ecx
movl $0xc8, %eax
testb $0x1, %dl
cmovnel %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x284(%rax)
movq -0x10(%rbp), %rdi
callq 0xbd8b0
movl %eax, -0xc4(%rbp)
cmpl $0x0, %eax
jne 0xbd383
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
movq -0x8(%rbp), %rax
movl 0x284(%rax), %edx
leaq 0xad5e(%rip), %rsi      # 0xc80cc
movb $0x0, %al
callq 0xb0cb0
movq -0x8(%rbp), %rdi
callq 0xb23e0
jmp 0xbd597
cmpl $-0x1, -0xc4(%rbp)
jne 0xbd3c5
movq -0x8(%rbp), %rax
movq %rax, -0xd0(%rbp)
callq 0xdcc0
movl (%rax), %edi
callq 0xda00
movq -0xd0(%rbp), %rdi
movq %rax, %rcx
movl $0x1f4, %esi            # imm = 0x1F4
leaq 0xad26(%rip), %rdx      # 0xc80df
movb $0x0, %al
callq 0xb3db0
jmp 0xbd595
cmpq $0x0, -0xb0(%rbp)
jne 0xbd3e8
movq -0x8(%rbp), %rdi
movl $0x19b, %esi            # imm = 0x19B
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0xb3db0
jmp 0xbd593
movq -0x10(%rbp), %rdi
movl $0x242, %esi            # imm = 0x242
movl $0x1a4, %edx            # imm = 0x1A4
movb $0x0, %al
callq 0xdf10
movq -0x8(%rbp), %rcx
movl %eax, 0x2b0(%rcx)
cmpl $0x0, %eax
jge 0xbd457
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
callq 0xdcc0
movl (%rax), %edi
callq 0xda00
movq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rcx
movq %rax, %r8
movl $0x1f4, %esi            # imm = 0x1F4
leaq 0xa76d(%rip), %rdx      # 0xc7bb8
movb $0x0, %al
callq 0xb3db0
jmp 0xbd591
movq -0x8(%rbp), %rax
movl $0x4, 0x2b8(%rax)
movq -0x8(%rbp), %rax
movl 0x2b0(%rax), %edi
callq 0xaf170
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
leaq 0xac68(%rip), %rsi      # 0xc80eb
callq 0xb0fe0
movq %rax, -0xa8(%rbp)
movq -0xb0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0xd9f0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x2d8(%rax)
movq $0x0, -0xc0(%rbp)
movq $0x0, -0xb8(%rbp)
cmpq $0x0, -0xa8(%rbp)
je 0xbd571
movq -0xa8(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
callq 0xb8e80
cmpl $0x0, %eax
jle 0xbd571
movq -0x8(%rbp), %rax
movl $0xce, 0x284(%rax)
movq -0x8(%rbp), %rax
movl 0x2b0(%rax), %edi
movq -0xb8(%rbp), %rsi
xorl %edx, %edx
callq 0xdbd0
movq -0xc0(%rbp), %rax
cmpq -0xb8(%rbp), %rax
jle 0xbd546
movq -0xc0(%rbp), %rax
subq -0xb8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xe8(%rbp)
jmp 0xbd55f
movq -0x8(%rbp), %rax
movq 0x2d8(%rax), %rax
subq -0xb8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x2d8(%rax)
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
movq -0x8(%rbp), %rax
movl 0x284(%rax), %edx
leaq 0xab6f(%rip), %rsi      # 0xc80f9
movb $0x0, %al
callq 0xb0cb0
jmp 0xbd593
jmp 0xbd595
jmp 0xbd597
addq $0xf0, %rsp
popq %rbp
retq