// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %edx, %ebx
movq %rsi, %r12
movq %rdi, %r14
movq 0x7963(%rip), %rax      # 0xdc08
xorl %esi, %esi
xorl %edx, %edx
callq *(%rax)
movq %rax, %rbp
movq $0x3e8, 0x20(%rsp)      # imm = 0x3E8
movq 0x7b2a(%rip), %rax      # 0xdde8
movq %r14, %rdi
callq *(%rax)
cmpq $0x0, 0x10(%rbp)
je 0x64c8
movq %r14, 0x10(%rsp)
movq 0x7a96(%rip), %rcx      # 0xdd70
movslq %ebx, %r13
movq %r13, %rdi
shlq $0x4, %rdi
addq $0x20, %rdi
movq %rax, %rbx
callq *(%rcx)
movq %rax, %r14
leaq (%rax,%r13,8), %r15
movq 0x10(%rbp), %rcx
movslq 0x88(%rcx), %rsi
movq %rbx, 0x18(%rsp)
movq %rbx, %rax
cqto
idivq %rsi
imulq $0x38, %rdx, %rax
addq 0x90(%rcx), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x18(%rbp)
je 0x634f
movq 0x7cae(%rip), %rax      # 0xdfd8
movq (%r12), %rdi
leaq 0x48(%rsp), %rbx
movq %rbx, %rsi
callq *(%rax)
movq 0x18(%rbp), %rdi
movq (%rbx), %rdx
leaq 0x20(%rsp), %rcx
movq %rax, %rsi
movq %rbx, %r8
callq 0x51d0
leal 0x2(%r13), %eax
movl %eax, 0xc(%rsp)
leaq (%r14,%r13,8), %rax
addq $0x10, %rax
movq %rax, 0x30(%rsp)
leaq 0x70(%rsp), %rdi
movq %rdi, (%r14)
leaq 0x4b0a(%rip), %rdx      # 0xae7d
movq %r13, 0x28(%rsp)
xorl %r13d, %r13d
pushq $0x20
popq %rsi
movq 0x18(%rsp), %rcx
xorl %eax, %eax
callq 0x50f0
cltq
movq %rax, 0x10(%r15)
leaq 0x50(%rsp), %rax
movq %rax, 0x8(%r14)
movq 0x20(%rsp), %r8
movq 0x8(%rbp), %rbx
movq 0x10(%rbp), %rax
movq %rax, (%rsp)
leaq 0x1(%rbx), %rax
movq %rax, 0x8(%rbp)
movq 0x787f(%rip), %rax      # 0xdc38
leaq 0x822(%rip), %rsi       # 0x6be2
leaq 0x859(%rip), %rdx       # 0x6c20
leaq 0x8f7(%rip), %rcx       # 0x6cc5
movq 0x10(%rsp), %rdi
callq *(%rax)
movq (%rsp), %rcx
movq 0x98(%rcx), %rdi
pushq $0x8
popq %rdx
movq %rbx, %rsi
movq %rax, %rcx
movq %rdx, %r8
callq 0x53d0
movq %rbp, (%rsp)
movq 0x10(%rbp), %rax
movq 0xa0(%rax), %rdi
movq 0x18(%rsp), %rsi
pushq $0x8
popq %rdx
movq %rbx, %rcx
movq %rdx, %r8
callq 0x53d0
leaq 0x50(%rsp), %rdi
pushq $0x20
popq %rsi
leaq 0x4a5b(%rip), %rdx      # 0xae7d
movq %rbx, %rcx
xorl %eax, %eax
callq 0x50f0
cltq
movq %rax, 0x18(%r15)
addq $0x20, %r15
movq 0x28(%rsp), %rax
testl %eax, %eax
movl $0x0, %ebx
cmovgl %eax, %ebx
shlq $0x3, %rbx
movq 0x7b88(%rip), %rbp      # 0xdfd8
cmpq %r13, %rbx
je 0x646b
movq (%r12,%r13), %rdi
leaq (%r15,%r13), %rsi
callq *(%rbp)
movq %rax, 0x10(%r14,%r13)
addq $0x8, %r13
jmp 0x6450
movq (%rsp), %rax
movq 0x20(%rax), %rdi
movl 0xc(%rsp), %esi
movq %r14, %rdx
movq 0x30(%rsp), %rcx
callq 0x5320
movq %rax, %r12
movq 0x38(%rsp), %r15
movl 0x24(%r15), %ebx
movq %rax, 0x40(%rsp)
leaq 0x10(%r15), %r13
cmpq $0x0, 0x10(%r15)
je 0x64f2
leaq 0x8(%r15), %rdi
leaq 0x18(%r15), %rdx
addq $0x20, %r15
movq %r13, %rsi
movq %r15, %rcx
movq %r12, %r8
callq 0x50b0
movq 0x7757(%rip), %rax      # 0xdc18
movq %r14, %rdi
callq *(%rax)
jmp 0x64de
movq 0x79d1(%rip), %rax      # 0xdea0
movq 0x7a42(%rip), %rcx      # 0xdf18
movq (%rcx), %rsi
movq %r14, %rdi
callq *(%rax)
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq 0xc(%r12), %rbp
movslq 0x8(%r12), %rax
subq %rax, %rbp
leaq (%r12,%rax), %rsi
addq $0x20, %rsi
movl %ebx, %edi
movq %rbp, %rdx
callq 0x5090
cmpl %eax, %ebp
jne 0x6524
leaq 0x40(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x50e0
jmp 0x64ba
testl %eax, %eax
jle 0x652d
addl %eax, 0x8(%r12)
cmpq $0x0, (%r13)
jne 0x64a0
movq 0x7669(%rip), %rax      # 0xdba8
leaq 0x867(%rip), %rcx       # 0x6dad
pushq $0x2
popq %rdx
movq 0x10(%rsp), %rdi
movl %ebx, %esi
movq %r15, %r8
callq *(%rax)
jmp 0x64a0