// File: /workspace/github_c_makefile_star2_O3/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 0x790a(%rip), %rax      # 0xdc08
xorl %esi, %esi
xorl %edx, %edx
callq *(%rax)
movq %rax, %r15
movq $0x3e8, 0x20(%rsp)      # imm = 0x3E8
movq 0x7ad1(%rip), %rax      # 0xdde8
movq %r14, %rdi
callq *(%rax)
cmpq $0x0, 0x10(%r15)
je 0x6531
movq %r14, 0x10(%rsp)
movq 0x7a3d(%rip), %rcx      # 0xdd70
movl %ebx, 0x8(%rsp)
movslq %ebx, %rbx
movq %rbx, %rdi
shlq $0x4, %rdi
addq $0x20, %rdi
movq %rax, %r13
callq *(%rcx)
movq %rax, %r14
movq %rbx, 0x30(%rsp)
leaq (%rax,%rbx,8), %rbp
movq 0x10(%r15), %rcx
movslq 0x88(%rcx), %rsi
movq %r13, 0x18(%rsp)
movq %r13, %rax
cqto
idivq %rsi
imulq $0x38, %rdx, %rax
addq 0x90(%rcx), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x18(%r15)
je 0x63b1
movq 0x7c4c(%rip), %rax      # 0xdfd8
movq (%r12), %rdi
leaq 0x48(%rsp), %rbx
movq %rbx, %rsi
callq *(%rax)
movq 0x18(%r15), %rdi
movq (%rbx), %rdx
leaq 0x20(%rsp), %rcx
movq %rax, %rsi
movq %rbx, %r8
callq 0x51c0
movq 0x30(%rsp), %r13
leal 0x2(%r13), %eax
movl %eax, 0xc(%rsp)
leaq (%r14,%r13,8), %rax
addq $0x10, %rax
movq %rax, 0x28(%rsp)
leaq 0x70(%rsp), %rdi
movq %rdi, (%r14)
leaq 0x4aa3(%rip), %rdx      # 0xae7d
movl $0x20, %esi
movq 0x18(%rsp), %rcx
xorl %eax, %eax
callq 0x50e0
cltq
movq %rax, 0x10(%rbp)
leaq 0x50(%rsp), %rax
movq %rax, 0x8(%r14)
movq 0x20(%rsp), %r8
movq 0x8(%r15), %rbx
movq 0x10(%r15), %rax
movq %rax, (%rsp)
leaq 0x1(%rbx), %rax
movq %rax, 0x8(%r15)
movq 0x781e(%rip), %rax      # 0xdc38
leaq 0x63c(%rip), %rsi       # 0x6a5d
leaq 0x673(%rip), %rdx       # 0x6a9b
leaq 0x70c(%rip), %rcx       # 0x6b3b
movq 0x10(%rsp), %rdi
callq *(%rax)
movq (%rsp), %rcx
movq 0x98(%rcx), %rdi
movl $0x8, %edx
movl $0x8, %r8d
movq %rbx, %rsi
movq %rax, %rcx
callq 0x53c0
movq %r15, (%rsp)
movq 0x10(%r15), %rax
movq 0xa0(%rax), %rdi
movl $0x8, %edx
movl $0x8, %r8d
movq 0x18(%rsp), %rsi
movq %rbx, %rcx
callq 0x53c0
movl $0x20, %esi
leaq 0x50(%rsp), %rdi
leaq 0x49ee(%rip), %rdx      # 0xae7d
movq %rbx, %rcx
xorl %eax, %eax
callq 0x50e0
cltq
movq %rax, 0x18(%rbp)
testl %r13d, %r13d
jle 0x64d4
addq $0x20, %rbp
movl 0x8(%rsp), %ebx
shlq $0x3, %rbx
xorl %r15d, %r15d
movq 0x7b1e(%rip), %r13      # 0xdfd8
movq (%r12,%r15), %rdi
leaq (%r15,%rbp), %rsi
callq *(%r13)
movq %rax, 0x10(%r14,%r15)
addq $0x8, %r15
cmpq %r15, %rbx
jne 0x64ba
movq (%rsp), %rax
movq 0x20(%rax), %rdi
movl 0xc(%rsp), %esi
movq %r14, %rdx
movq 0x28(%rsp), %rcx
callq 0x5310
movq %rax, %r12
movq 0x38(%rsp), %r15
movl 0x24(%r15), %ebx
movq %rax, 0x40(%rsp)
leaq 0x10(%r15), %r13
cmpq $0x0, 0x10(%r15)
je 0x655b
leaq 0x8(%r15), %rdi
leaq 0x18(%r15), %rdx
addq $0x20, %r15
movq %r13, %rsi
movq %r15, %rcx
movq %r12, %r8
callq 0x50a0
movq 0x76ee(%rip), %rax      # 0xdc18
movq %r14, %rdi
callq *(%rax)
jmp 0x6547
movq 0x7968(%rip), %rax      # 0xdea0
movq 0x79d9(%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 0x5080
cmpl %eax, %ebp
jne 0x658f
leaq 0x40(%rsp), %rdi
movl $0x1, %esi
callq 0x50d0
jmp 0x6523
testl %eax, %eax
jle 0x6598
addl %eax, 0x8(%r12)
cmpq $0x0, (%r13)
jne 0x6509
movq 0x75fe(%rip), %rax      # 0xdba8
leaq 0x677(%rip), %rcx       # 0x6c28
movq 0x10(%rsp), %rdi
movl %ebx, %esi
movl $0x2, %edx
movq %r15, %r8
callq *(%rax)
jmp 0x6509