// File: romkatv[P]action-chain/src/action_chain_test.cc
// Function: romkatv::(anonymous namespace)::ParseFlags(char const* const*, char const* const*)
Flags ParseFlags(const char* const* begin, const char* const* end) {
  auto Match = [&](const char* name, auto* flag) -> bool {
    if (std::strncmp(*begin + 2, name, std::strlen(name))) return false;
    const char* val = *begin + 2 + std::strlen(name);
    if (*val == '\0') {
      ++begin;
      CHECK(begin != end);
      val = *begin;
    } else if (*val == '=') {
      ++val;
    } else {
      return false;
    }
    ParseFlag(flag, val);
    return true;
  };
  Flags res;
  for (; begin != end; ++begin) {
    CHECK(!std::strncmp(*begin, "--", 2));
    CHECK(Match("sync", &res.sync) || Match("actions", &res.actions) ||
          Match("threads", &res.threads) || Match("ops-per-action", &res.ops_per_action));
  }
  if (!res.actions) {
    res.actions = (128 / (res.ops_per_action / 32 + 1)) << 20;
  }

  return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x50(%rbp)
movq %rdi, %rax
movq %rax, -0x48(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movb $0x0, -0x29(%rbp)
callq 0x4e00
movq -0x10(%rbp), %rax
cmpq -0x18(%rbp), %rax
je 0x3abd
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x982f(%rip), %rsi      # 0xd1b3
movl $0x2, %edx
callq 0x3110
cmpl $0x0, %eax
je 0x39c3
movq 0x10636(%rip), %rax     # 0x13fd0
movq (%rax), %rdi
leaq 0x97d6(%rip), %rsi      # 0xd17a
leaq 0x97e0(%rip), %rdx      # 0xd18b
movl $0x6c, %ecx
leaq 0x97ff(%rip), %r8       # 0xd1b6
movb $0x0, %al
callq 0x3320
callq 0x3140
jmp 0x39c5
movq -0x50(%rbp), %rdx
leaq 0x9805(%rip), %rsi      # 0xd1d5
leaq -0x28(%rbp), %rdi
callq 0x4e80
movb %al, -0x51(%rbp)
jmp 0x39de
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x3aa8
jmp 0x39eb
movq -0x50(%rbp), %rdx
addq $0x30, %rdx
leaq 0x995f(%rip), %rsi      # 0xd359
leaq -0x28(%rbp), %rdi
callq 0x4fd0
movb %al, -0x52(%rbp)
jmp 0x3a08
movb -0x52(%rbp), %al
testb $0x1, %al
jne 0x3aa8
jmp 0x3a15
movq -0x50(%rbp), %rdx
addq $0x20, %rdx
leaq 0x97b6(%rip), %rsi      # 0xd1da
leaq -0x28(%rbp), %rdi
callq 0x4fd0
movb %al, -0x53(%rbp)
jmp 0x3a32
movb -0x53(%rbp), %al
testb $0x1, %al
jne 0x3aa8
jmp 0x3a3b
movq -0x50(%rbp), %rdx
addq $0x28, %rdx
leaq 0x9798(%rip), %rsi      # 0xd1e2
leaq -0x28(%rbp), %rdi
callq 0x4fd0
movb %al, -0x54(%rbp)
jmp 0x3a58
movb -0x54(%rbp), %al
testb $0x1, %al
jne 0x3aa8
jmp 0x3a61
movq 0x10568(%rip), %rax     # 0x13fd0
movq (%rax), %rdi
leaq 0x9708(%rip), %rsi      # 0xd17a
leaq 0x9712(%rip), %rdx      # 0xd18b
movl $0x6e, %ecx
leaq 0x976c(%rip), %r8       # 0xd1f1
movb $0x0, %al
callq 0x3320
callq 0x3140
movq -0x50(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x4de0
jmp 0x3b0e
jmp 0x3aaa
jmp 0x3aac
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
jmp 0x3968
movq -0x50(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x3af1
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rcx
shrq $0x5, %rcx
addq $0x1, %rcx
movl $0x80, %eax
xorl %edx, %edx
divq %rcx
movq %rax, %rcx
movq -0x50(%rbp), %rax
shlq $0x14, %rcx
movq %rcx, 0x30(%rax)
movb $0x1, -0x29(%rbp)
testb $0x1, -0x29(%rbp)
jne 0x3b04
movq -0x50(%rbp), %rdi
callq 0x4de0
movq -0x48(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x33d0
nopw (%rax,%rax)