// File: /workspace/github_c_makefile_star2_O0/redis-force[P]rpm/module/rpm.c
// Function: rpm_worker_upstream_write_command
static int rpm_worker_upstream_write_command(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
  int idx;
  size_t len;
  char *tmp, client_id_buffer[32], request_id_buffer[32];
  chained_buffer *cmd;
  const char **args;
  size_t *num_args;
  rpm_context *rpm;
  long long timeout, client_id;
  worker_pipe *upstream;

  rpm = rpm_context_get(ctx);
  timeout = RPM_DEFAULT_TIMEOUT;
  client_id = RedisModule_GetClientId(ctx);
  if (rpm->worker == NULL) {
    RedisModule_ReplyWithError(ctx, RPM_BAD_GATEWAY);
    return REDISMODULE_OK;
  }
  args = RedisModule_Alloc((sizeof(char *) + sizeof(size_t)) * (argc + 2));
  num_args = (size_t *) (args + argc + 2);
  upstream = rpm->worker->upstreams + (client_id % rpm->worker->num_upstreams);
  if (rpm->command_timeout) {
    tmp = (char *) RedisModule_StringPtrLen(argv[0], &len);
    hash_map_find(rpm->command_timeout, tmp, len, (const void **) &timeout, &len);
  }
  args[0] = client_id_buffer;
  num_args[0] = snprintf(client_id_buffer, sizeof(client_id_buffer), "%lld", client_id);
  args[1] = request_id_buffer;
  num_args[1] = snprintf(request_id_buffer, sizeof(request_id_buffer), "%lld", rpm_worker_process_request(ctx, rpm, timeout, client_id));
  for (idx = 0; idx < argc; ++idx) {
    args[idx + 2] = RedisModule_StringPtrLen(argv[idx], num_args + idx + 2);
  }
  cmd = redis_format_command(rpm->allocator, argc + 2, args, num_args);
  rpm_worker_upstream_write(ctx, upstream, upstream->pipe[0], cmd);
  RedisModule_Free(args);
  return REDISMODULE_OK;
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xb8(%rsp)
movq %rsi, 0xb0(%rsp)
movl %edx, 0xac(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x7240
movq %rax, 0x30(%rsp)
movq $0x3e8, 0x28(%rsp)      # imm = 0x3E8
movq 0xa540(%rip), %rax      # 0x10df0
movq (%rax), %rax
movq 0xb8(%rsp), %rdi
callq *%rax
movq %rax, 0x20(%rsp)
movq 0x30(%rsp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x68fc
movq 0xa5d3(%rip), %rax      # 0x10ea8
movq (%rax), %rax
movq 0xb8(%rsp), %rdi
movq 0xa639(%rip), %rcx      # 0x10f20
movq (%rcx), %rsi
callq *%rax
movl $0x0, 0xc4(%rsp)
jmp 0x6b4a
movq 0xa475(%rip), %rax      # 0x10d78
movq (%rax), %rax
movl 0xac(%rsp), %ecx
addl $0x2, %ecx
movslq %ecx, %rdi
shlq $0x4, %rdi
callq *%rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movslq 0xac(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
addq $0x10, %rax
movq %rax, 0x38(%rsp)
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x90(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
movq 0x10(%rcx), %rcx
movslq 0x88(%rcx), %rcx
cqto
idivq %rcx
movq 0x10(%rsp), %rax
imulq $0x38, %rdx, %rcx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x30(%rsp), %rax
cmpq $0x0, 0x18(%rax)
je 0x69d9
movq 0xa652(%rip), %rax      # 0x10fe0
movq (%rax), %rax
movq 0xb0(%rsp), %rcx
movq (%rcx), %rdi
leaq 0xa0(%rsp), %rsi
callq *%rax
movq %rax, 0x98(%rsp)
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
leaq 0x28(%rsp), %rcx
leaq 0xa0(%rsp), %r8
callq 0x51d0
leaq 0x70(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, (%rax)
leaq 0x70(%rsp), %rdi
movq 0x20(%rsp), %rcx
movl $0x20, %esi
leaq 0x7471(%rip), %rdx      # 0xde6d
movb $0x0, %al
callq 0x50f0
movslq %eax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, (%rax)
leaq 0x50(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x8(%rax)
leaq 0x50(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xb8(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq 0x7260
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl $0x20, %esi
leaq 0x7417(%rip), %rdx      # 0xde6d
movb $0x0, %al
callq 0x50f0
movslq %eax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x8(%rax)
movl $0x0, 0xa8(%rsp)
movl 0xa8(%rsp), %eax
cmpl 0xac(%rsp), %eax
jge 0x6ae8
movq 0xa555(%rip), %rax      # 0x10fe0
movq (%rax), %rax
movq 0xb0(%rsp), %rcx
movslq 0xa8(%rsp), %rdx
movq (%rcx,%rdx,8), %rdi
movq 0x38(%rsp), %rsi
movslq 0xa8(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rsi
addq $0x10, %rsi
callq *%rax
movq %rax, %rdx
movq 0x40(%rsp), %rax
movl 0xa8(%rsp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl 0xa8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa8(%rsp)
jmp 0x6a74
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rdi
movl 0xac(%rsp), %esi
addl $0x2, %esi
movq 0x40(%rsp), %rdx
movq 0x38(%rsp), %rcx
callq 0x5320
movq %rax, 0x48(%rsp)
movq 0xb8(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x18(%rsp), %rax
movl 0x24(%rax), %edx
movq 0x48(%rsp), %rcx
callq 0x7330
movq 0xa0eb(%rip), %rax      # 0x10c20
movq (%rax), %rax
movq 0x40(%rsp), %rdi
callq *%rax
movl $0x0, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
addq $0xc8, %rsp
retq
nopl (%rax)