// File: /workspace/github_c_makefile_star2_O0/redis-force[P]rpm/module/rpm.c
// Function: rpm_context_create
static rpm_context *rpm_context_create(RedisModuleCtx *ctx, int argc, RedisModuleString **argv)
{
  int idx, didx, is_config, last_is_command = 0;
  int64_t timeout;
  size_t len;
  const char *arg;
  rpm_context *rpm = RedisModule_Calloc(1, sizeof(rpm_context));
  hash_map *command_timeout = NULL;
  const rpm_context_config_descriptor *config;
  rpm->allocator = allocator_create(rpm_allocator_malloc, rpm_allocator_calloc,
    rpm_allocator_realloc, rpm_allocator_free, rpm_allocator_destroy, rpm);
  for (idx = 0; idx + 1 < argc; idx++) {
    is_config = 0;
    arg = RedisModule_StringPtrLen(argv[idx], &len);
    for (config = rpm_config_descriptors; config->name != NULL; ++config) {
      if (strcasecmp(config->name, arg) == 0 && argc - 2 - idx >= config->argc) {
        config->parser(rpm_context_field_at_offset(rpm, config->offset), argv + idx + 1);
        idx += config->argc;
        is_config = 1;
        last_is_command = 0;
        break;
      }
    }
    if (is_config) {
      continue;
    }
    if (strcasecmp("--command", arg) == 0) {
      /* consume the next argument */
      arg = RedisModule_StringPtrLen(argv[++idx], &len);
      if (RedisModule_CreateCommand(ctx, arg, rpm_worker_upstream_write_command, "", 0, 0, 0) == REDISMODULE_ERR) {
        RedisModule_Log(ctx, "warning", "could not register command %s", arg);
      }
      last_is_command = 1;
    } else if (strcasecmp("--timeout", arg) == 0) {
      /* consume the next argument */
      arg = RedisModule_StringPtrLen(argv[++idx], &len);
      timeout = strtol(arg, NULL, 10);
      if (!last_is_command) {
        RedisModule_Log(ctx, "warning", "--command <cmd> is required before --timeout");
      } else {
        arg = RedisModule_StringPtrLen(argv[idx - 2], &len);
        if (command_timeout == NULL) {
          command_timeout_map.allocator = rpm->allocator;
          rpm->command_timeout = command_timeout = hash_map_create(&command_timeout_map, 128);
        }
        hash_map_set(command_timeout, arg, len, hash_map_int_ptr(timeout), sizeof(timeout));
      }
      last_is_command = 0;
    } else {
      last_is_command = 0;
      break;
    }
  }
  if (argc == idx) {
    goto cleanup_exit;
  }
  rpm->argv = RedisModule_Alloc(sizeof(const char *) * (argc - idx + 1));
  for (didx = 0; idx < argc; ++didx, ++idx) {
    arg = RedisModule_StringPtrLen(argv[idx], &len);
    rpm->argv[didx] = RedisModule_Calloc(1, len + 1);
    memcpy(rpm->argv[didx], arg, len + 1);
  }
  rpm->argv[didx] = NULL;

  if (rpm->num_downstreams <= 0) {
    rpm->num_downstreams = RPM_DEFAULT_DOWNSTREAM;
  } else if (rpm->num_downstreams > RPM_MAX_DOWNSTREAM) {
    rpm->num_downstreams = RPM_MAX_DOWNSTREAM;
  }
  if (rpm->num_upstreams <= 0) {
    rpm->num_upstreams = RPM_DEFAULT_UPSTREAM;
  } else if (rpm->num_upstreams > RPM_MAX_UPSTREAM) {
    rpm->num_upstreams = RPM_MAX_UPSTREAM;
  }
  if (rpm->retry_timeout <= 0) {
    rpm->retry_timeout = 0x7FFFFFFF;
  }
  if (rpm->retry_attempts <= 0) {
    rpm->retry_attempts = 0x7FFFFFFF;
  }
  rpm->restart_timer = -1;
  time(&rpm->restart_count_reset_time);
  if ((rpm->worker = rpm_worker_create(ctx, rpm)) == NULL) {
    goto cleanup_exit;
  }
  return rpm;
cleanup_exit:
  if (rpm != NULL) {
    rpm_context_destroy(ctx, rpm);
  }
  return NULL;
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x68(%rsp)
movl %esi, 0x64(%rsp)
movq %rdx, 0x58(%rsp)
movl $0x0, 0x48(%rsp)
movl $0x1, %edi
movl $0x58, %esi
movq 0xab25(%rip), %rax      # 0x10c60
callq *(%rax)
movq %rax, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x28(%rsp), %r9
leaq 0x629(%rip), %rdi       # 0x6780
leaq 0x652(%rip), %rsi       # 0x67b0
leaq 0x67b(%rip), %rdx       # 0x67e0
leaq 0x6a4(%rip), %rcx       # 0x6810
leaq 0x6cd(%rip), %r8        # 0x6840
callq 0x51c0
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x20(%rax)
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
addl $0x1, %eax
cmpl 0x64(%rsp), %eax
jge 0x6479
movl $0x0, 0x4c(%rsp)
movq 0xae34(%rip), %rax      # 0x10fe0
movq (%rax), %rax
movq 0x58(%rsp), %rcx
movslq 0x54(%rsp), %rdx
movq (%rcx,%rdx,8), %rdi
leaq 0x38(%rsp), %rsi
callq *%rax
movq %rax, 0x30(%rsp)
leaq 0xa7c0(%rip), %rax      # 0x10990
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
cmpq $0x0, (%rax)
je 0x6286
movq 0x18(%rsp), %rax
movq (%rax), %rdi
movq 0x30(%rsp), %rsi
callq 0x5020
cmpl $0x0, %eax
jne 0x6271
movl 0x64(%rsp), %eax
subl $0x2, %eax
subl 0x54(%rsp), %eax
movq 0x18(%rsp), %rcx
cmpl 0x8(%rcx), %eax
jl 0x6271
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x28(%rsp), %rdi
movq 0x18(%rsp), %rax
movl 0xc(%rax), %esi
callq 0x6850
movq %rax, %rdi
movq 0x10(%rsp), %rax
movq 0x58(%rsp), %rsi
movslq 0x54(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rsi
addq $0x8, %rsi
callq *%rax
movq 0x18(%rsp), %rax
movl 0x8(%rax), %eax
addl 0x54(%rsp), %eax
movl %eax, 0x54(%rsp)
movl $0x1, 0x4c(%rsp)
movl $0x0, 0x48(%rsp)
jmp 0x6286
jmp 0x6273
movq 0x18(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x18(%rsp)
jmp 0x61d5
cmpl $0x0, 0x4c(%rsp)
je 0x6292
jmp 0x6469
movq 0x30(%rsp), %rsi
leaq 0x7b1c(%rip), %rdi      # 0xddba
callq 0x5020
cmpl $0x0, %eax
jne 0x6343
movq 0xad2d(%rip), %rax      # 0x10fe0
movq (%rax), %rax
movq 0x58(%rsp), %rcx
movl 0x54(%rsp), %edx
addl $0x1, %edx
movl %edx, 0x54(%rsp)
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rdi
leaq 0x38(%rsp), %rsi
callq *%rax
movq %rax, 0x30(%rsp)
movq 0xac20(%rip), %rax      # 0x10f00
movq (%rax), %rax
movq 0x68(%rsp), %rdi
movq 0x30(%rsp), %rsi
leaq 0x57c(%rip), %rdx       # 0x6870
leaq 0x801e(%rip), %rcx      # 0xe319
xorl %r9d, %r9d
movl %r9d, %r8d
movl $0x0, (%rsp)
callq *%rax
cmpl $0x1, %eax
jne 0x6336
movq 0xab5a(%rip), %rax      # 0x10e70
movq (%rax), %r8
movq 0x68(%rsp), %rdi
movq 0x30(%rsp), %rcx
leaq 0x7a9a(%rip), %rsi      # 0xddc4
leaq 0x7a9b(%rip), %rdx      # 0xddcc
movb $0x0, %al
callq *%r8
movl $0x1, 0x48(%rsp)
jmp 0x6467
movq 0x30(%rsp), %rsi
leaq 0x7abe(%rip), %rdi      # 0xde0d
callq 0x5020
cmpl $0x0, %eax
jne 0x645b
movq 0xac7c(%rip), %rax      # 0x10fe0
movq (%rax), %rax
movq 0x58(%rsp), %rcx
movl 0x54(%rsp), %edx
addl $0x1, %edx
movl %edx, 0x54(%rsp)
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rdi
leaq 0x38(%rsp), %rsi
callq *%rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x5210
movq %rax, 0x40(%rsp)
cmpl $0x0, 0x48(%rsp)
jne 0x63cf
movq 0xaac0(%rip), %rax      # 0x10e70
movq (%rax), %rcx
movq 0x68(%rsp), %rdi
leaq 0x7a05(%rip), %rsi      # 0xddc4
leaq 0x7a24(%rip), %rdx      # 0xddea
movb $0x0, %al
callq *%rcx
jmp 0x6451
movq 0xac0a(%rip), %rax      # 0x10fe0
movq (%rax), %rax
movq 0x58(%rsp), %rcx
movl 0x54(%rsp), %edx
subl $0x2, %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rdi
leaq 0x38(%rsp), %rsi
callq *%rax
movq %rax, 0x30(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0x6432
movq 0x28(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0xae58(%rip)      # 0x11268
leaq 0xae21(%rip), %rdi      # 0x11238
movl $0x80, %esi
callq 0x5250
movq %rax, %rcx
movq %rcx, 0x20(%rsp)
movq 0x28(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x20(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq 0x40(%rsp), %rcx
movl $0x8, %r8d
callq 0x53d0
movl $0x0, 0x48(%rsp)
jmp 0x6465
movl $0x0, 0x48(%rsp)
jmp 0x6479
jmp 0x6467
jmp 0x6469
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x618c
movl 0x64(%rsp), %eax
cmpl 0x54(%rsp), %eax
jne 0x6488
jmp 0x6646
movq 0xa8e9(%rip), %rax      # 0x10d78
movq (%rax), %rax
movl 0x64(%rsp), %ecx
subl 0x54(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rdi
shlq $0x3, %rdi
callq *%rax
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, (%rax)
movl $0x0, 0x50(%rsp)
movl 0x54(%rsp), %eax
cmpl 0x64(%rsp), %eax
jge 0x6558
movq 0xab12(%rip), %rax      # 0x10fe0
movq (%rax), %rax
movq 0x58(%rsp), %rcx
movslq 0x54(%rsp), %rdx
movq (%rcx,%rdx,8), %rdi
leaq 0x38(%rsp), %rsi
callq *%rax
movq %rax, 0x30(%rsp)
movq 0xa76e(%rip), %rax      # 0x10c60
movq (%rax), %rax
movq 0x38(%rsp), %rsi
addq $0x1, %rsi
movl $0x1, %edi
callq *%rax
movq %rax, %rdx
movq 0x28(%rsp), %rax
movq (%rax), %rax
movslq 0x50(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x28(%rsp), %rax
movq (%rax), %rax
movslq 0x50(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq $0x1, %rdx
callq 0x5220
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x64b9
movq 0x28(%rsp), %rax
movq (%rax), %rax
movslq 0x50(%rsp), %rcx
movq $0x0, (%rax,%rcx,8)
movq 0x28(%rsp), %rax
cmpl $0x0, 0x28(%rax)
jg 0x6586
movq 0x28(%rsp), %rax
movl $0x4, 0x28(%rax)
jmp 0x659f
movq 0x28(%rsp), %rax
cmpl $0x10, 0x28(%rax)
jle 0x659d
movq 0x28(%rsp), %rax
movl $0x10, 0x28(%rax)
jmp 0x659f
movq 0x28(%rsp), %rax
cmpl $0x0, 0x2c(%rax)
jg 0x65b8
movq 0x28(%rsp), %rax
movl $0x4, 0x2c(%rax)
jmp 0x65d1
movq 0x28(%rsp), %rax
cmpl $0x10, 0x2c(%rax)
jle 0x65cf
movq 0x28(%rsp), %rax
movl $0x10, 0x2c(%rax)
jmp 0x65d1
movq 0x28(%rsp), %rax
cmpl $0x0, 0x34(%rax)
jg 0x65e8
movq 0x28(%rsp), %rax
movl $0x7fffffff, 0x34(%rax) # imm = 0x7FFFFFFF
movq 0x28(%rsp), %rax
cmpl $0x0, 0x38(%rax)
jg 0x65ff
movq 0x28(%rsp), %rax
movl $0x7fffffff, 0x38(%rax) # imm = 0x7FFFFFFF
movq 0x28(%rsp), %rax
movq $-0x1, 0x50(%rax)
movq 0x28(%rsp), %rdi
addq $0x40, %rdi
callq 0x5240
movq 0x68(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x6b60
movq 0x28(%rsp), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
jne 0x663a
jmp 0x6646
movq 0x28(%rsp), %rax
movq %rax, 0x70(%rsp)
jmp 0x6666
cmpq $0x0, 0x28(%rsp)
je 0x665d
movq 0x68(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x6670
movq $0x0, 0x70(%rsp)
movq 0x70(%rsp), %rax
addq $0x78, %rsp
retq