// File: /workspace/github_c_makefile_star2_O2/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, (%rsp)
xorl %r14d, %r14d
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0x23a0
xorl %ebx, %ebx
pushq $0x1
popq %rdi
pushq $0x18
popq %rsi
callq 0x21a0
testq %rax, %rax
je 0x3fba
testq %r14, %r14
cmoveq %rax, %r14
movq %r14, 0x18(%rsp)
testq %rbx, %rbx
je 0x3e5a
movq %rax, 0x10(%rbx)
movq %rax, 0x10(%rsp)
movq (%rsp), %rax
movq 0x28(%rax), %rbp
xorl %r15d, %r15d
xorl %r14d, %r14d
movq $0x0, 0x8(%rsp)
xorl %r13d, %r13d
xorl %ebx, %ebx
movq (%rsp), %rax
movl 0x20(%rax), %eax
cmpq %rax, %r15
jae 0x3f3f
pushq $0x1
popq %rdi
pushq $0x30
popq %rsi
callq 0x21a0
movq %rax, %r12
testq %r13, %r13
cmoveq %rax, %r13
testq %rbx, %rbx
je 0x3ea9
movq %r12, 0x28(%rbx)
movq %r13, 0x20(%rsp)
testq %r14, %r14
je 0x3ebb
movq %r14, %rdi
callq 0x387a
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x23a0
movl $0x0, %r13d
testq %rbp, %rbp
je 0x3ee4
movq (%rsp), %rax
movq 0x18(%rax), %rax
movq %rbp, %rdi
callq *(%rax,%r15,8)
movq %rax, %r13
leaq 0x28(%rsp), %rdi
xorl %esi, %esi
callq 0x23a0
testq %r13, %r13
je 0x3f10
movq 0x8(%rbp), %rax
movq %rax, 0x18(%r12)
movq 0x8(%r13), %rax
movq %rax, 0x20(%r12)
movl $0x1, 0x10(%r12)
movq %r12, %rdi
leaq 0x28(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x3a3b
incq %r15
movq 0x8(%rsp), %r14
movq %r13, 0x8(%rsp)
movq %r12, %rbx
movq %r13, %rbp
movq 0x20(%rsp), %r13
jmp 0x3e7b
testq %r14, %r14
je 0x3f4c
movq %r14, %rdi
callq 0x387a
movq 0x8(%rsp), %r15
testq %r15, %r15
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %rbx
je 0x3f8a
movq (%rsp), %rax
movq 0x30(%rax), %rdi
pushq $0x1
popq %rcx
testq %rdi, %rdi
je 0x3f7f
movq %r15, %rsi
callq 0x390f
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl %ecx, 0x8(%rbx)
movq %r15, %rdi
callq 0x387a
movq %r13, (%rbx)
movq (%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x48(%rsp), %rdx
callq 0x3abb
testl %eax, %eax
jne 0x3e31
movq %r14, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x35eb(%rip), %rdi      # 0x75ac
leaq 0x3520(%rip), %rsi      # 0x74e8
leaq 0x35e5(%rip), %rcx      # 0x75b4
movl $0x209, %edx            # imm = 0x209
callq 0x2190