// File: /workspace/github_c_makefile_star2_O3/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, %r14
xorl %r15d, %r15d
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0x23a0
leaq 0x28(%rsp), %r13
xorl %r12d, %r12d
movq %r12, %rbx
movl $0x1, %edi
movl $0x18, %esi
callq 0x21a0
testq %rax, %rax
je 0x41c6
movq %rax, %r12
testq %r15, %r15
cmoveq %rax, %r15
testq %rbx, %rbx
je 0x4038
movq %r12, 0x10(%rbx)
cmpl $0x0, 0x20(%r14)
je 0x417d
movq %r12, 0x10(%rsp)
movq %r15, 0x18(%rsp)
movq 0x28(%r14), %rdx
xorl %r12d, %r12d
xorl %ebx, %ebx
movq $0x0, 0x8(%rsp)
xorl %eax, %eax
xorl %r15d, %r15d
movq %r14, %r13
movq %rax, 0x20(%rsp)
movq %rbx, %r14
movq %rdx, %rbp
movl $0x1, %edi
movl $0x30, %esi
callq 0x21a0
movq %rax, %rbx
movq 0x8(%rsp), %rax
testq %rax, %rax
cmoveq %rbx, %rax
movq %rax, 0x8(%rsp)
testq %r14, %r14
je 0x409e
movq %rbx, 0x28(%r14)
testq %r15, %r15
je 0x40ab
movq %r15, %rdi
callq 0x39c5
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x23a0
testq %rbp, %rbp
movq %r13, %r14
jne 0x40d2
leaq 0x28(%rsp), %r13
movq %r13, %rdi
xorl %esi, %esi
callq 0x23a0
xorl %eax, %eax
jmp 0x4113
movq 0x18(%r14), %rax
movq %rbp, %rdi
callq *(%rax,%r12,8)
movq %rax, %r15
leaq 0x28(%rsp), %r13
movq %r13, %rdi
xorl %esi, %esi
callq 0x23a0
movl $0x0, %eax
testq %r15, %r15
je 0x4113
movq 0x8(%rbp), %rax
movq %rax, 0x18(%rbx)
movq 0x8(%r15), %rax
movq %rax, 0x20(%rbx)
movl $0x1, 0x10(%rbx)
movq %r15, %rax
movq %rbx, %rdi
movq %rax, %rbp
movq %r13, %rsi
leaq 0x38(%rsp), %rdx
callq 0x3bc6
movq %rbp, %rdx
incq %r12
movl 0x20(%r14), %ecx
movq %rbp, %rax
cmpq %rcx, %r12
movq 0x20(%rsp), %r15
jb 0x4064
testq %r15, %r15
je 0x4151
movq %r15, %rdi
callq 0x39c5
movq %rbp, %rdx
testq %rdx, %rdx
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %r12
je 0x4193
movq 0x30(%r14), %rdi
testq %rdi, %rdi
je 0x4181
movq %rbp, %rsi
callq 0x3a6b
movq %rbp, %rdx
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
jmp 0x4186
xorl %eax, %eax
jmp 0x4198
movl $0x1, %ecx
movl %ecx, 0x8(%r12)
movq %rdx, %rdi
callq 0x39c5
movq 0x8(%rsp), %rax
movq %rax, (%r12)
movq %r14, %rdi
movq %r13, %rsi
leaq 0x48(%rsp), %rdx
callq 0x3c52
testl %eax, %eax
jne 0x400a
movq %r15, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x43e7(%rip), %rdi      # 0x85b4
leaq 0x431c(%rip), %rsi      # 0x84f0
leaq 0x43e1(%rip), %rcx      # 0x85bc
movl $0x209, %edx            # imm = 0x209
callq 0x2190