// File: /workspace/github_c_makefile_star2_O1/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 0x7941(%rip), %rax      # 0xdc08
xorl %esi, %esi
xorl %edx, %edx
callq *(%rax)
movq %rax, %r15
movq $0x3e8, 0x28(%rsp)      # imm = 0x3E8
movq 0x7b08(%rip), %rax      # 0xdde8
movq %r14, %rdi
callq *(%rax)
cmpq $0x0, 0x10(%r15)
je 0x6526
movq %r14, 0x18(%rsp)
movq 0x7a74(%rip), %rcx      # 0xdd70
movl %ebx, 0x10(%rsp)
movslq %ebx, %rbx
movq %rbx, %rdi
shlq $0x4, %rdi
addq $0x20, %rdi
movq %rax, %r13
callq *(%rcx)
movq %rax, %r14
movq %rbx, 0x38(%rsp)
leaq (%rax,%rbx,8), %rbp
movq 0x10(%r15), %rcx
movslq 0x88(%rcx), %rsi
movq %r13, 0x20(%rsp)
movq %r13, %rax
cqto
idivq %rsi
imulq $0x38, %rdx, %rax
addq 0x90(%rcx), %rax
movq %rax, 0x40(%rsp)
cmpq $0x0, 0x18(%r15)
je 0x637a
movq 0x7c83(%rip), %rax      # 0xdfd8
movq (%r12), %rdi
leaq 0x48(%rsp), %rbx
movq %rbx, %rsi
callq *(%rax)
movq 0x18(%r15), %rdi
movq (%rbx), %rdx
leaq 0x28(%rsp), %rcx
movq %rax, %rsi
movq %rbx, %r8
callq 0x51c0
movq 0x38(%rsp), %r13
leal 0x2(%r13), %eax
movl %eax, 0x14(%rsp)
leaq (%r14,%r13,8), %rax
addq $0x10, %rax
movq %rax, 0x30(%rsp)
leaq 0x70(%rsp), %rdi
movq %rdi, (%r14)
leaq 0x4ada(%rip), %rdx      # 0xae7d
movl $0x20, %esi
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x50e0
cltq
movq %rax, 0x10(%rbp)
leaq 0x50(%rsp), %rax
movq %rax, 0x8(%r14)
movq 0x28(%rsp), %r8
movq 0x8(%r15), %rbx
movq 0x10(%r15), %rax
movq %rax, (%rsp)
leaq 0x1(%rbx), %rax
movq %rax, 0x8(%r15)
movq 0x7855(%rip), %rax      # 0xdc38
leaq 0x63d(%rip), %rsi       # 0x6a27
leaq 0x674(%rip), %rdx       # 0x6a65
leaq 0x70d(%rip), %rcx       # 0x6b05
movq 0x18(%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 0x20(%rsp), %rsi
movq %rbx, %rcx
callq 0x53c0
movl $0x20, %esi
leaq 0x50(%rsp), %rdi
leaq 0x4a25(%rip), %rdx      # 0xae7d
movq %rbx, %rcx
xorl %eax, %eax
callq 0x50e0
cltq
movq %rax, 0x18(%rbp)
testl %r13d, %r13d
jle 0x649d
addq $0x20, %rbp
movl 0x10(%rsp), %ebx
shlq $0x3, %rbx
xorl %r15d, %r15d
movq 0x7b55(%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 0x6483
movq (%rsp), %rax
movq 0x20(%rax), %rdi
movl 0x14(%rsp), %esi
movq %r14, %rdx
movq 0x30(%rsp), %rcx
callq 0x5310
movq 0x40(%rsp), %r15
movl 0x24(%r15), %ebx
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x10(%r15)
je 0x6550
leaq 0x10(%r15), %r13
movq 0x8(%rsp), %r12
cmpq $0x0, (%r13)
jne 0x64fe
movq 0x76c2(%rip), %rax      # 0xdba8
leaq 0x705(%rip), %rcx       # 0x6bf2
movq 0x18(%rsp), %rdi
movl %ebx, %esi
movl $0x2, %edx
movq %r15, %r8
callq *(%rax)
leaq 0x8(%r15), %rdi
leaq 0x18(%r15), %rdx
addq $0x20, %r15
movq %r13, %rsi
movq %r15, %rcx
movq %r12, %r8
callq 0x50a0
movq 0x76f9(%rip), %rax      # 0xdc18
movq %r14, %rdi
callq *(%rax)
jmp 0x653c
movq 0x7973(%rip), %rax      # 0xdea0
movq 0x79e4(%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(%rax), %r12
movslq 0x8(%rax), %rcx
subq %rcx, %r12
leaq (%rax,%rcx), %rsi
addq $0x20, %rsi
movl %ebx, %edi
movq %r12, %rdx
callq 0x5080
cmpl %eax, %r12d
jne 0x6583
leaq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0x50d0
jmp 0x6518
testl %eax, %eax
jle 0x64cf
movq 0x8(%rsp), %rcx
addl %eax, 0x8(%rcx)
jmp 0x64cf