// File: /workspace/github_c_makefile_star2_O3/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 0x22b0
movq %rax, %r15
testl %r15d, %r15d
setne %al
cmpl $0x1000, %r15d          # imm = 0x1000
setl %cl
testb %cl, %al
jne 0x9f0c
movl $0x2000, %edi           # imm = 0x2000
callq 0x2290
testq %rax, %rax
je 0x9f71
movq %rax, %r14
movl $0x2000, %esi           # imm = 0x2000
movq %rax, %rdi
movq %r13, %rdx
movq %r12, %rcx
callq 0x22b0
movq %rax, %r15
testl %r15d, %r15d
setne %al
cmpl $0x2000, %r15d          # imm = 0x2000
setl %cl
testb %cl, %al
jne 0x9f0c
movq %r14, %rdi
callq 0x2060
movl $0x10000, %edi          # imm = 0x10000
callq 0x2290
testq %rax, %rax
je 0x9f90
movq %rax, %r14
movl $0x10000, %esi          # imm = 0x10000
movq %rax, %rdi
movq %r13, %rdx
movq %r12, %rcx
callq 0x22b0
movq %rax, %r15
testl %r15d, %r15d
setne %al
cmpl $0x10000, %r15d         # imm = 0x10000
setl %cl
testb %cl, %al
jne 0x9f0c
movq %r14, %rdi
callq 0x2060
movl $0x100000, %edi         # imm = 0x100000
callq 0x2290
testq %rax, %rax
je 0x9faf
movq %rax, %r14
movl $0x100000, %esi         # imm = 0x100000
movq %rax, %rdi
movq %r13, %rdx
movq %r12, %rcx
callq 0x22b0
movq %rax, %r15
testl %r15d, %r15d
je 0x9fce
cmpl $0x100000, %r15d        # imm = 0x100000
jge 0x9fce
cmpl $0x0, -0x2c(%rbp)
je 0x9f22
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x9c11
jmp 0x9f4b
leal 0x1(%r15), %esi
movq %rbx, %rdi
callq 0x9a40
movq (%rbx), %rdi
movslq %r15d, %r12
movq %r14, %rsi
movq %r12, %rdx
callq 0x2260
movl %r15d, 0x8(%rbx)
movq (%rbx), %rax
movb $0x0, (%rax,%r12)
leaq -0x1030(%rbp), %rax
cmpq %rax, %r14
je 0x9f5f
movq %r14, %rdi
callq 0x2060
addq $0x1008, %rsp           # imm = 0x1008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x348b(%rip), %rdi      # 0xd403
leaq 0x33c6(%rip), %rsi      # 0xd345
leaq 0x349d(%rip), %rcx      # 0xd423
movl $0x13d, %edx            # imm = 0x13D
callq 0x21b0
leaq 0x346c(%rip), %rdi      # 0xd403
leaq 0x33a7(%rip), %rsi      # 0xd345
leaq 0x347e(%rip), %rcx      # 0xd423
movl $0x142, %edx            # imm = 0x142
callq 0x21b0
leaq 0x344d(%rip), %rdi      # 0xd403
leaq 0x3388(%rip), %rsi      # 0xd345
leaq 0x345f(%rip), %rcx      # 0xd423
movl $0x147, %edx            # imm = 0x147
callq 0x21b0
movq %r14, %rdi
callq 0x2d9c