// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]tundra/src/DagGenerator.cpp
// Function: t2::RunExternalTool(char const*, ...)
static bool RunExternalTool(const char* options, ...)
{
  char dag_gen_path[kMaxPathLength];

  if (const char* env_option = getenv("TUNDRA_DAGTOOL"))
  {
    strncpy(dag_gen_path, env_option, sizeof dag_gen_path);
    dag_gen_path[sizeof(dag_gen_path)-1] = '\0';
  }
  else
  {
    // Figure out the path to the default t2-lua DAG generator.
    PathBuffer pbuf;
    PathInit(&pbuf, GetExePath());
    PathStripLast(&pbuf);
    PathConcat(&pbuf, "t2-lua" TUNDRA_EXE_SUFFIX);
    PathFormat(dag_gen_path, &pbuf);
  }


  const char* cmdline_to_use;

  char option_str[1024];
  char cmdline[1024];
  va_list args;
  va_start(args, options);
  vsnprintf(option_str, sizeof option_str, options, args);
  va_end(args);
  option_str[sizeof(option_str)-1] = '\0';

  EnvVariable env_var;
  env_var.m_Name = "TUNDRA_FRONTEND_OPTIONS";
  env_var.m_Value = option_str;

  if (const char* env_option = getenv("TUNDRA_DAGTOOL_FULLCOMMANDLINE"))
  {
    cmdline_to_use = env_option;
  }
  else
  {
    const char* quotes = "";
    if (strchr(dag_gen_path, ' '))
      quotes = "\"";

    snprintf(cmdline, sizeof cmdline, "%s%s%s %s", quotes, dag_gen_path, quotes, option_str);
    cmdline[sizeof(cmdline)-1] = '\0';

    cmdline_to_use = cmdline;
  }

  const bool echo = (GetLogFlags() & kDebug) ? true : false;

  ExecResult result = ExecuteProcess(cmdline_to_use, 1, &env_var, 0, echo, nullptr);

  if (0 != result.m_ReturnCode)
  {
    Log(kError, "DAG generator driver failed: %s", cmdline_to_use);
    return false;
  }

  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xdc0, %rsp            # imm = 0xDC0
testb %al, %al
je 0x87d7
movaps %xmm0, -0xd80(%rbp)
movaps %xmm1, -0xd70(%rbp)
movaps %xmm2, -0xd60(%rbp)
movaps %xmm3, -0xd50(%rbp)
movaps %xmm4, -0xd40(%rbp)
movaps %xmm5, -0xd30(%rbp)
movaps %xmm6, -0xd20(%rbp)
movaps %xmm7, -0xd10(%rbp)
movq %r9, -0xd88(%rbp)
movq %r8, -0xd90(%rbp)
movq %rcx, -0xd98(%rbp)
movq %rdx, -0xda0(%rbp)
movq %rsi, -0xda8(%rbp)
movq %rdi, -0x10(%rbp)
leaq 0x1b807(%rip), %rdi     # 0x2400c
callq 0x3400
movq %rax, -0x218(%rbp)
cmpq $0x0, -0x218(%rbp)
je 0x8839
leaq -0x210(%rbp), %rdi
movq -0x218(%rbp), %rsi
movl $0x200, %edx            # imm = 0x200
callq 0x31b0
movb $0x0, -0x11(%rbp)
jmp 0x8881
callq 0x7c40
movq %rax, %rsi
leaq -0x4a4(%rbp), %rdi
xorl %edx, %edx
callq 0x18e70
leaq -0x4a4(%rbp), %rdi
callq 0x19370
leaq -0x4a4(%rbp), %rdi
leaq 0x1b7b2(%rip), %rsi     # 0x2401b
callq 0x193d0
leaq -0x210(%rbp), %rdi
leaq -0x4a4(%rbp), %rsi
callq 0x195c0
leaq -0xcd0(%rbp), %rax
leaq -0xdb0(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x8, (%rax)
leaq -0x8b0(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq -0xcd0(%rbp), %rcx
movl $0x400, %esi            # imm = 0x400
callq 0x3210
leaq -0xcd0(%rbp), %rax
movb $0x0, -0x4b1(%rbp)
leaq 0x1b749(%rip), %rax     # 0x24022
movq %rax, -0xce0(%rbp)
leaq -0x8b0(%rbp), %rax
movq %rax, -0xcd8(%rbp)
leaq 0x1b745(%rip), %rdi     # 0x2403a
callq 0x3400
movq %rax, -0xce8(%rbp)
cmpq $0x0, -0xce8(%rbp)
je 0x891e
movq -0xce8(%rbp), %rax
movq %rax, -0x4b0(%rbp)
jmp 0x89a0
leaq 0x1bab6(%rip), %rax     # 0x243db
movq %rax, -0xcf0(%rbp)
leaq -0x210(%rbp), %rdi
movl $0x20, %esi
callq 0x3130
cmpq $0x0, %rax
je 0x8951
leaq 0x1b442(%rip), %rax     # 0x23d8c
movq %rax, -0xcf0(%rbp)
leaq -0xcb0(%rbp), %rdi
movq -0xcf0(%rbp), %rcx
leaq -0x210(%rbp), %r8
movq -0xcf0(%rbp), %r9
leaq -0x8b0(%rbp), %rax
movl $0x400, %esi            # imm = 0x400
leaq 0x1b6d9(%rip), %rdx     # 0x24059
movq %rax, (%rsp)
movb $0x0, %al
callq 0x3540
movb $0x0, -0x8b1(%rbp)
leaq -0xcb0(%rbp), %rax
movq %rax, -0x4b0(%rbp)
callq 0x7a30
movl %eax, %ecx
xorl %eax, %eax
btl $0x3, %ecx
sbbl %eax, %eax
andb $0x1, %al
movb %al, -0xcf1(%rbp)
movq -0x4b0(%rbp), %rdi
movb -0xcf1(%rbp), %al
andb $0x1, %al
movzbl %al, %r8d
movl $0x1, %esi
leaq -0xce0(%rbp), %rdx
xorl %ecx, %ecx
xorl %eax, %eax
movl %eax, %r9d
callq 0x1ebe0
movq %rax, -0xcfc(%rbp)
xorl %eax, %eax
cmpl -0xcfc(%rbp), %eax
je 0x8a13
movq -0x4b0(%rbp), %rdx
movl $0x1, %edi
leaq 0x1b65d(%rip), %rsi     # 0x24063
movb $0x0, %al
callq 0x7a60
movb $0x0, -0x1(%rbp)
jmp 0x8a17
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0xdc0, %rsp            # imm = 0xDC0
popq %rbp
retq
nopw %cs:(%rax,%rax)