// File: /workspace/github_c_makefile_star2_O1/tomcatzh[P]RealityBenchmark/benchmark.c
// Function: loopThread
static void *loopThread(void *arg) {
  TEST *t = (TEST *)arg;

  const CONTENTS* input;
  CONTENTS *output, *needFree;

  struct timeval start, loopTime, now;
  gettimeofday(&start, NULL);

  LOOP *headLoop, *loop, *newLoop;
  RUN *headRun, *run, *newRun;

  loop = headLoop = NULL;

  do {
    newLoop = (LOOP *)calloc(1, sizeof(LOOP));
    assert(newLoop);
    if (!headLoop) headLoop = newLoop;
    if (loop) loop->next = newLoop;
    loop = newLoop;

    input = t->input;
    output = needFree = NULL;
    run = headRun = NULL;

    for (unsigned int i = 0; i < t->runCount; i ++) {
      newRun = (RUN *)calloc(1, sizeof(RUN));
      if (!headRun) headRun = newRun;
      if (run) run->next = newRun;
      run = newRun;

      if (needFree) {
        destroyContents(needFree);
        needFree = NULL;
      }
      if (output) {
        needFree = output;
        output = NULL;
      }

      gettimeofday(&loopTime, NULL);
      if (input) {
        output = (*(t->run[i]))(input);
      }
      gettimeofday(&now, NULL);

      if (output) {
        run->inputBytes = input->size;
        run->outputBytes = output->size;
        run->success = 1;
      }

      timevalSubtract(&(run->interval), &now, &loopTime);
      
      input = output;
    }

    if (needFree) {
      destroyContents(needFree);
    }

    if (output) {
      if (t->verifyData) {
        loop->correct = !(compareContents(t->verifyData, output));
      } else {
        loop->correct = 1;
      }

      destroyContents(output);
    }

    loop->runs = headRun;
  } while (timevalBeforeTimeout(&(t->timeout), &now, &start));

  return headLoop;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r15
xorl %r14d, %r14d
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0x23b0
xorl %ebx, %ebx
movq %r15, 0x8(%rsp)
movl $0x1, %edi
movl $0x18, %esi
callq 0x21a0
testq %rax, %rax
je 0x41d5
testq %r14, %r14
cmoveq %rax, %r14
testq %rbx, %rbx
je 0x4061
movq %rax, 0x10(%rbx)
movq %rax, 0x10(%rsp)
movq %r14, 0x18(%rsp)
cmpl $0x0, 0x20(%r15)
je 0x414d
movq 0x28(%r15), %r15
xorl %r12d, %r12d
xorl %r13d, %r13d
movq $0x0, (%rsp)
xorl %r14d, %r14d
xorl %ebp, %ebp
movq %r14, 0x20(%rsp)
movl $0x1, %edi
movl $0x30, %esi
callq 0x21a0
movq %rax, %rbx
movq (%rsp), %rax
testq %rax, %rax
cmoveq %rbx, %rax
movq %rax, (%rsp)
testq %r13, %r13
je 0x40bc
movq %rbx, 0x28(%r13)
testq %rbp, %rbp
je 0x40c9
movq %rbp, %rdi
callq 0x39d1
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x23b0
movl $0x0, %r14d
testq %r15, %r15
movq 0x8(%rsp), %r13
je 0x40f3
movq 0x18(%r13), %rax
movq %r15, %rdi
callq *(%rax,%r12,8)
movq %rax, %r14
leaq 0x28(%rsp), %rdi
xorl %esi, %esi
callq 0x23b0
testq %r14, %r14
je 0x411b
movq 0x8(%r15), %rax
movq %rax, 0x18(%rbx)
movq 0x8(%r14), %rax
movq %rax, 0x20(%rbx)
movl $0x1, 0x10(%rbx)
movq %rbx, %rdi
leaq 0x28(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x3bd2
incq %r12
movl 0x20(%r13), %eax
movq %r14, %r15
movq %rbx, %r13
movq 0x20(%rsp), %rdi
movq %rdi, %rbp
cmpq %rax, %r12
jb 0x408d
jmp 0x415a
xorl %edi, %edi
xorl %r14d, %r14d
movq $0x0, (%rsp)
testq %rdi, %rdi
movq 0x10(%rsp), %rbx
je 0x4169
callq 0x39d1
testq %r14, %r14
movq 0x8(%rsp), %r15
je 0x419d
movq 0x30(%r15), %rdi
testq %rdi, %rdi
je 0x418d
movq %r14, %rsi
callq 0x3a77
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
jmp 0x4192
movl $0x1, %ecx
movl %ecx, 0x8(%rbx)
movq %r14, %rdi
callq 0x39d1
movq (%rsp), %rax
movq %rax, (%rbx)
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
leaq 0x48(%rsp), %rdx
callq 0x3c5b
testl %eax, %eax
movq 0x18(%rsp), %r14
jne 0x4039
movq %r14, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x43d8(%rip), %rdi      # 0x85b4
leaq 0x430d(%rip), %rsi      # 0x84f0
leaq 0x43d2(%rip), %rcx      # 0x85bc
movl $0x209, %edx            # imm = 0x209
callq 0x2190