// File: /workspace/github_cpp_makefile_star2_O2/solaldunckel[P]webserv/srcs/HTTP/CGI.cpp
// Function: CGI::init(int)
void CGI::init(int worker_id) {
  char *cwd = getcwd(NULL, 0);
  if (!cwd)
    return ;
  cwd_ = cwd;
  free(cwd);

  env_ = NULL;
  argv_[0] = NULL;
  argv_[1] = NULL;
  argv_[2] = NULL;
  extension_ = file_.getMimeExtension();
  cgi_exe_ = config_.getCGI()[extension_];
  if (config_.getCGIBin()[0] == '/') {
    cgi_path_ = config_.getCGIBin() + "/" + cgi_exe_;
  } else {
    cgi_path_ = cwd_ + "/" + config_.getCGIBin() + "/" + cgi_exe_;
  }
  std::string cgi_path = "/tmp/webserv_cgi_tmp_" + ft::to_string(worker_id);
  tmp_file_.set_path(cgi_path.c_str());
  tmp_file_.open(true);
  if (worker_id)
    Log.print(DEBUG, "worker[" + ft::to_string(worker_id) + "] : CGI -> " + cgi_path_);
  else
    Log.print(DEBUG, "server : CGI -> " + cgi_path_);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movl %esi, %ebp
movq %rdi, %rbx
xorl %edi, %edi
xorl %esi, %esi
callq 0x4220
testq %rax, %rax
je 0xcf2f
movq %rax, %r14
leaq 0x78(%rbx), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x4830
movq %r14, %rdi
callq 0x4540
xorps %xmm0, %xmm0
movups %xmm0, 0x1d8(%rbx)
movups %xmm0, 0x1c8(%rbx)
movq (%rbx), %rdi
callq 0x17be8
leaq 0x58(%rbx), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x4240
movq 0x8(%rbx), %rdi
callq 0x8df2
movq %rax, %rdi
movq %r14, %rsi
callq 0xb208
leaq 0x38(%rbx), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x4240
movq 0x8(%rbx), %rdi
callq 0x8dfc
movq (%rax), %rax
cmpb $0x2f, (%rax)
jne 0xcce9
movq 0x8(%rbx), %rdi
callq 0x8dfc
leaq 0xf8d8(%rip), %rdx      # 0x1c57e
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x60d3
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x5273
leaq 0x18(%rbx), %rdi
leaq 0x68(%rsp), %r14
movq %r14, %rsi
callq 0x4560
movq %r14, %rdi
callq 0x4898
leaq 0x8(%rsp), %rdi
jmp 0xcd72
leaq 0xf88e(%rip), %rdx      # 0x1c57e
leaq 0x28(%rsp), %rdi
movq %r15, %rsi
callq 0x60d3
movq 0x8(%rbx), %rdi
callq 0x8dfc
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq %rax, %rdx
callq 0x5273
leaq 0xf85f(%rip), %rdx      # 0x1c57e
leaq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x5292
leaq 0x68(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %r14, %rdx
callq 0x5273
leaq 0x18(%rbx), %rdi
leaq 0x68(%rsp), %r14
movq %r14, %rsi
callq 0x4560
movq %r14, %rdi
callq 0x4898
leaq 0x8(%rsp), %rdi
callq 0x4898
leaq 0x48(%rsp), %rdi
callq 0x4898
leaq 0x28(%rsp), %rdi
callq 0x4898
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movl %ebp, %esi
callq 0x6118
leaq 0xf7f3(%rip), %rsi      # 0x1c580
leaq 0x68(%rsp), %rdi
movq %r14, %rdx
callq 0x8234
leaq 0x8(%rsp), %rdi
callq 0x4898
movq 0x68(%rsp), %rsi
leaq 0x108(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x5328
leaq 0xf8(%rbx), %r14
leaq 0x108(%rsp), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x16610
leaq 0x108(%rsp), %rdi
callq 0x4898
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x16a60
testl %ebp, %ebp
je 0xceb5
leaq 0x28(%rsp), %rdi
movl %ebp, %esi
callq 0x6118
leaq 0xf78f(%rip), %rsi      # 0x1c596
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x8234
leaq 0xf781(%rip), %rdx      # 0x1c59e
leaq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x5292
addq $0x18, %rbx
leaq 0xe8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %rbx, %rdx
callq 0x5273
leaq 0xf1ce(%rip), %rsi      # 0x1c01a
leaq 0xc8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x5328
leaq 0x1e683(%rip), %rdi     # 0x2b4e8
pushq $0x2
popq %rsi
leaq 0xe8(%rsp), %rdx
leaq 0xc8(%rsp), %rcx
xorl %r8d, %r8d
callq 0x18e1e
leaq 0xc8(%rsp), %rdi
callq 0x4898
leaq 0xe8(%rsp), %rdi
callq 0x4898
leaq 0x8(%rsp), %rdi
callq 0x4898
leaq 0x48(%rsp), %rdi
callq 0x4898
leaq 0x28(%rsp), %rdi
jmp 0xcf20
addq $0x18, %rbx
leaq 0xf6ea(%rip), %rsi      # 0x1c5aa
leaq 0xa8(%rsp), %rdi
movq %rbx, %rdx
callq 0x52b1
leaq 0xf143(%rip), %rsi      # 0x1c01a
leaq 0x88(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x5328
leaq 0x1e5f8(%rip), %rdi     # 0x2b4e8
pushq $0x2
popq %rsi
leaq 0xa8(%rsp), %rdx
leaq 0x88(%rsp), %rcx
xorl %r8d, %r8d
callq 0x18e1e
leaq 0x88(%rsp), %rdi
callq 0x4898
leaq 0xa8(%rsp), %rdi
callq 0x4898
leaq 0x68(%rsp), %rdi
callq 0x4898
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x4898
jmp 0xcf52
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
jmp 0xcfd5
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4898
jmp 0xcf6e
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x4898
jmp 0xcfeb
jmp 0xcfde
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x4898
jmp 0xcf91
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x4898
jmp 0xcfa3
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4898
jmp 0xcfb2
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x4898
jmp 0xcfc1
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0xcfd5
jmp 0xcff2
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x4898
jmp 0xcff5
jmp 0xcff2
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
jmp 0xcffa
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0xcffa
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x4898
movq %rbx, %rdi
callq 0x4750
nop