// File: /workspace/github_c_makefile_star2_O2/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, %r15d
movq %rdi, %rbx
leaq -0x1030(%rbp), %r14
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdi
callq 0x22b0
testl %eax, %eax
setne %cl
cmpl $0x1000, %eax           # imm = 0x1000
setl %dl
testb %dl, %cl
jne 0x949b
movl $0x2000, %edi           # imm = 0x2000
callq 0x2290
testq %rax, %rax
je 0x94da
movq %rax, %r14
movl $0x2000, %esi           # imm = 0x2000
movq %rax, %rdi
movq %r13, %rdx
movq %r12, %rcx
callq 0x22b0
testl %eax, %eax
setne %cl
cmpl $0x2000, %eax           # imm = 0x2000
setl %dl
testb %dl, %cl
jne 0x949b
movq %r14, %rdi
callq 0x2060
movl $0x10000, %edi          # imm = 0x10000
callq 0x2290
testq %rax, %rax
je 0x94f9
movq %rax, %r14
movl $0x10000, %esi          # imm = 0x10000
movq %rax, %rdi
movq %r13, %rdx
movq %r12, %rcx
callq 0x22b0
testl %eax, %eax
setne %cl
cmpl $0x10000, %eax          # imm = 0x10000
setl %dl
testb %dl, %cl
jne 0x949b
movq %r14, %rdi
callq 0x2060
movl $0x100000, %edi         # imm = 0x100000
callq 0x2290
testq %rax, %rax
je 0x9518
movq %rax, %r14
movl $0x100000, %esi         # imm = 0x100000
movq %rax, %rdi
movq %r13, %rdx
movq %r12, %rcx
callq 0x22b0
testl %eax, %eax
je 0x9537
cmpl $0x100000, %eax         # imm = 0x100000
jge 0x9537
movq %rbx, %rdi
movq %r14, %rsi
movl %eax, %edx
testl %r15d, %r15d
je 0x94af
callq 0x91b5
jmp 0x94b4
callq 0x910b
leaq -0x1030(%rbp), %rax
cmpq %rax, %r14
je 0x94c8
movq %r14, %rdi
callq 0x2060
addq $0x1008, %rsp           # imm = 0x1008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2f52(%rip), %rdi      # 0xc433
leaq 0x2e8d(%rip), %rsi      # 0xc375
leaq 0x2f64(%rip), %rcx      # 0xc453
movl $0x13d, %edx            # imm = 0x13D
callq 0x21b0
leaq 0x2f33(%rip), %rdi      # 0xc433
leaq 0x2e6e(%rip), %rsi      # 0xc375
leaq 0x2f45(%rip), %rcx      # 0xc453
movl $0x142, %edx            # imm = 0x142
callq 0x21b0
leaq 0x2f14(%rip), %rdi      # 0xc433
leaq 0x2e4f(%rip), %rsi      # 0xc375
leaq 0x2f26(%rip), %rcx      # 0xc453
movl $0x147, %edx            # imm = 0x147
callq 0x21b0
movq %r14, %rdi
callq 0x2060
movq 0x6ab2(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x2f45(%rip), %rsi      # 0xc495
movl $0x100000, %edx         # imm = 0x100000
xorl %eax, %eax
callq 0x2230
pushq $0x1
popq %rdi
callq 0x2340