// File: /workspace/github_c_makefile_star2_O2/igaw[P]jitterdebugger/jitterdebugger.c
// Function: worker
static void *worker(void *arg)
{
	struct stats *s = arg;
	struct timespec now, next, interval;
	sigset_t mask;
	uint64_t diff;
	int err;

	/* Don't handle any signals */
	sigfillset(&mask);
	if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0)
		err_handler(errno, "sigprocmask()");

	s->tid = __gettid();

	interval.tv_sec = 0;
	interval.tv_nsec = sleep_interval_us * NSEC_PER_US;

	err = clock_gettime(CLOCK_MONOTONIC, &now);
	if (err)
		err_handler(err, "clock_gettime()");

	next = now;

	while (!READ_ONCE(jd_shutdown)) {
		next = ts_add(next, interval);

		err = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME,
					&next, NULL);
		if (err)
			err_handler(err, "clock_nanosleep()");

		err = clock_gettime(CLOCK_MONOTONIC, &now);
		if (err)
			err_handler(err, "clock_gettime()");

		/* Update the statistics */
		diff = ts_sub(now, next);
		if (diff > s->max)
			s->max = diff;

		if (diff < s->min)
			s->min = diff;

		s->count++;
		s->total += diff;

		if (diff < s->hist_size)
			s->hist[diff]++;

		if (s->rb)
			ringbuffer_write(s->rb, now, diff);

		if (diff > break_val) {
			stop_tracer(diff);
			WRITE_ONCE(jd_shutdown, 1);
		}

		if (max_loops > 0 && s->count >= max_loops)
			break;
	}

	return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdi, %rbx
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
callq 0x2280
xorl %edi, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2030
testl %eax, %eax
jns 0x3bf2
callq 0x2070
movl (%rax), %edi
leaq 0x1b51(%rip), %rsi      # 0x572e
leaq 0x1683(%rip), %rdx      # 0x5267
leaq 0x1b5a(%rip), %rcx      # 0x5745
xorl %eax, %eax
callq 0x3ee1
movl $0xba, %edi
xorl %eax, %eax
callq 0x2240
movl %eax, 0x8(%rbx)
movl 0x4808(%rip), %r14d     # 0x8410
pushq $0x1
popq %rdi
leaq 0x10(%rsp), %rsi
callq 0x20e0
testl %eax, %eax
je 0x3c37
leaq 0x1b2c(%rip), %rsi      # 0x574c
leaq 0x1640(%rip), %rdx      # 0x5267
leaq 0x1b17(%rip), %rcx      # 0x5745
movl %eax, %edi
xorl %eax, %eax
callq 0x3ee1
imulq $0x3e8, %r14, %r13      # imm = 0x3E8
leaq 0x10(%rsp), %rax
movdqu (%rax), %xmm0
movq %rsp, %rax
movdqa %xmm0, (%rax)
movl $0x3b9aca00, %r12d      # imm = 0x3B9ACA00
pushq $0x1
popq %rbp
leaq 0x1609(%rip), %r14      # 0x5267
cmpl $0x0, 0x484f(%rip)      # 0x84b4
jne 0x3dfd
movq 0x8(%rsp), %rcx
addq %r13, %rcx
cmpq %r12, %rcx
movl $0x3b9ac9ff, %eax       # imm = 0x3B9AC9FF
cmovgeq %rcx, %rax
xorl %edx, %edx
divq %r12
imulq $-0x3b9aca00, %rax, %rdx # imm = 0xC4653600
addq %rcx, %rdx
addq %rax, (%rsp)
movq %rdx, 0x8(%rsp)
movl %ebp, %edi
movl %ebp, %esi
movq %rsp, %rdx
xorl %ecx, %ecx
callq 0x23d0
testl %eax, %eax
je 0x3cc3
movl %eax, %edi
leaq 0x1ab3(%rip), %rsi      # 0x5765
movq %r14, %rdx
leaq 0x1a89(%rip), %rcx      # 0x5745
xorl %eax, %eax
callq 0x3ee1
movl %ebp, %edi
leaq 0x10(%rsp), %rsi
callq 0x20e0
testl %eax, %eax
je 0x3ced
movl %eax, %edi
leaq 0x1a70(%rip), %rsi      # 0x574c
movq %r14, %rdx
leaq 0x1a5f(%rip), %rcx      # 0x5745
xorl %eax, %eax
callq 0x3ee1
movl 0x10(%rsp), %eax
movl 0x18(%rsp), %ecx
subl (%rsp), %eax
cltq
imulq $0x3b9aca00, %rax, %rdx # imm = 0x3B9ACA00
subl 0x8(%rsp), %ecx
movslq %ecx, %rax
addq %rdx, %rax
cmpb $0x0, 0x471a(%rip)      # 0x842c
movl $0x3e8, %ecx            # imm = 0x3E8
pushq $0x1
popq %rdx
cmovneq %rdx, %rcx
cqto
idivq %rcx
movq %rax, %r15
cmpq 0x10(%rbx), %rax
jbe 0x3d30
movq %r15, 0x10(%rbx)
cmpq 0x18(%rbx), %r15
jae 0x3d3a
movq %r15, 0x18(%rbx)
movdqu 0x38(%rbx), %xmm0
movq %r15, %xmm1
shufpd $0x2, 0x1303(%rip), %xmm1 # xmm1 = xmm1[0],mem[1]
paddq %xmm0, %xmm1
movdqu %xmm1, 0x38(%rbx)
movl 0x28(%rbx), %eax
cmpq %rax, %r15
jae 0x3d66
movq 0x30(%rbx), %rax
incq (%rax,%r15,8)
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x3d81
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r15, %rcx
callq 0x3e6d
cmpq 0x4680(%rip), %r15      # 0x8408
jbe 0x3de4
movl $0x80, %esi
movq %r14, %r12
leaq 0x20(%rsp), %r14
movq %r14, %rdi
leaq 0x19df(%rip), %rdx      # 0x5780
movq %r15, %rcx
xorl %eax, %eax
callq 0x2160
movl 0x4663(%rip), %edi      # 0x8414
movslq %eax, %rdx
movq %r14, %rsi
movq %r12, %r14
movl $0x3b9aca00, %r12d      # imm = 0x3B9ACA00
callq 0x20f0
movl 0x464d(%rip), %edi      # 0x8418
leaq 0x19be(%rip), %rsi      # 0x5790
pushq $0x2
popq %rdx
callq 0x20f0
movl $0x1, 0x46d0(%rip)      # 0x84b4
movl 0x463e(%rip), %eax      # 0x8428
testq %rax, %rax
je 0x3c5e
cmpq %rax, 0x40(%rbx)
jb 0x3c5e
xorl %eax, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)