// File: /workspace/github_c_makefile_star2_O1/alexgirao[P]aimant/str.c
// Function: str_formattime
void str_formattime(struct str *sa, int cat, const char *fmt, struct tm *tm)
{
  char buf0[0x0fff + 1 /* 4096 */], *buf;
  int buf_len;
  int n;

  buf = buf0;
  buf_len = sizeof(buf0);

  n = strftime(buf, buf_len, fmt, tm);
  if (n == 0 || n >= buf_len) {
    /* try with more space
     */
    buf_len = 0x1fff + 1 /* 8192 */;
    assert((buf = malloc(buf_len)) != NULL);
    n = strftime(buf, buf_len, fmt, tm);
    if (n == 0 || n >= buf_len) {
      free(buf);
      buf_len = 0xffff + 1 /* 64K */;
      assert((buf = malloc(buf_len)) != NULL);
      n = strftime(buf, buf_len, fmt, tm);
      if (n == 0 || n >= buf_len) {
        free(buf);
        buf_len = 0xfffff + 1; /* 1M */
        assert((buf = malloc(buf_len)) != NULL);
        n = strftime(buf, buf_len, fmt, tm);
        if (n == 0 || n >= buf_len) {
          /* give up */
          free(buf);
          fprintf(stderr, "error: str_vformattime(): too large input (> %i)\n", 0xfffff + 1);
          exit(1);
        }
      }
    }
  }

  assert(buf != NULL);

  if (cat) {
    str_catn(sa, buf, n);
  } else {
    str_copyn(sa, buf, n);
  }

  if (buf && buf != buf0) {
    free(buf);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1008, %rsp           # imm = 0x1008
movq %rcx, %r12
movq %rdx, %r13
movl %esi, -0x2c(%rbp)
movq %rdi, %rbx
leaq -0x1030(%rbp), %r14
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdi
callq 0x22c0
movq %rax, %r15
testl %r15d, %r15d
setne %al
cmpl $0x1000, %r15d          # imm = 0x1000
setl %cl
testb %cl, %al
jne 0xa128
movl $0x2000, %edi           # imm = 0x2000
callq 0x22a0
testq %rax, %rax
je 0xa18d
movq %rax, %r14
movl $0x2000, %esi           # imm = 0x2000
movq %rax, %rdi
movq %r13, %rdx
movq %r12, %rcx
callq 0x22c0
movq %rax, %r15
testl %r15d, %r15d
setne %al
cmpl $0x2000, %r15d          # imm = 0x2000
setl %cl
testb %cl, %al
jne 0xa128
movq %r14, %rdi
callq 0x2060
movl $0x10000, %edi          # imm = 0x10000
callq 0x22a0
testq %rax, %rax
je 0xa1ac
movq %rax, %r14
movl $0x10000, %esi          # imm = 0x10000
movq %rax, %rdi
movq %r13, %rdx
movq %r12, %rcx
callq 0x22c0
movq %rax, %r15
testl %r15d, %r15d
setne %al
cmpl $0x10000, %r15d         # imm = 0x10000
setl %cl
testb %cl, %al
jne 0xa128
movq %r14, %rdi
callq 0x2060
movl $0x100000, %edi         # imm = 0x100000
callq 0x22a0
testq %rax, %rax
je 0xa1cb
movq %rax, %r14
movl $0x100000, %esi         # imm = 0x100000
movq %rax, %rdi
movq %r13, %rdx
movq %r12, %rcx
callq 0x22c0
movq %rax, %r15
testl %r15d, %r15d
je 0xa1ea
cmpl $0x100000, %r15d        # imm = 0x100000
jge 0xa1ea
cmpl $0x0, -0x2c(%rbp)
je 0xa13e
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x9e2f
jmp 0xa167
leal 0x1(%r15), %esi
movq %rbx, %rdi
callq 0x9c54
movq (%rbx), %rdi
movslq %r15d, %r12
movq %r14, %rsi
movq %r12, %rdx
callq 0x2270
movl %r15d, 0x8(%rbx)
movq (%rbx), %rax
movb $0x0, (%rax,%r12)
leaq -0x1030(%rbp), %rax
cmpq %rax, %r14
je 0xa17b
movq %r14, %rdi
callq 0x2060
addq $0x1008, %rsp           # imm = 0x1008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3292(%rip), %rdi      # 0xd426
leaq 0x31cd(%rip), %rsi      # 0xd368
leaq 0x32a4(%rip), %rcx      # 0xd446
movl $0x13d, %edx            # imm = 0x13D
callq 0x21b0
leaq 0x3273(%rip), %rdi      # 0xd426
leaq 0x31ae(%rip), %rsi      # 0xd368
leaq 0x3285(%rip), %rcx      # 0xd446
movl $0x142, %edx            # imm = 0x142
callq 0x21b0
leaq 0x3254(%rip), %rdi      # 0xd426
leaq 0x318f(%rip), %rsi      # 0xd368
leaq 0x3266(%rip), %rcx      # 0xd446
movl $0x147, %edx            # imm = 0x147
callq 0x21b0
movq %r14, %rdi
callq 0x2dda