// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x2270
xorl %edi, %edi
leaq -0xc0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x2030
cmpl $0x0, %eax
jge 0x41d1
jmp 0x41ac
callq 0x2060
movl (%rax), %edi
leaq 0x2ba1(%rip), %rsi      # 0x6d5b
leaq 0x221f(%rip), %rdx      # 0x63e0
leaq 0x2baa(%rip), %rcx      # 0x6d72
movb $0x0, %al
callq 0x4d50
jmp 0x41d1
callq 0x4490
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq $0x0, -0x40(%rbp)
movl 0x5217(%rip), %eax      # 0x9404
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq %rax, -0x38(%rbp)
movl $0x1, %edi
leaq -0x20(%rbp), %rsi
callq 0x20d0
movl %eax, -0xcc(%rbp)
cmpl $0x0, -0xcc(%rbp)
je 0x423b
jmp 0x4217
movl -0xcc(%rbp), %edi
leaq 0x2b55(%rip), %rsi      # 0x6d79
leaq 0x21b5(%rip), %rdx      # 0x63e0
leaq 0x2b40(%rip), %rcx      # 0x6d72
movb $0x0, %al
callq 0x4d50
jmp 0x423b
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movl 0x2d73(%rip), %eax      # 0x6fc4
movl %eax, -0xd0(%rbp)
movl 0x5247(%rip), %eax      # 0x94a4
movl %eax, -0xd0(%rbp)
movl -0xd0(%rbp), %eax
movl %eax, -0xd4(%rbp)
cmpl $0x0, -0xd4(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x4284
jmp 0x4480
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x44b0
movq %rax, -0xe8(%rbp)
movq %rdx, -0xe0(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0xe0(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x1, %esi
leaq -0x30(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
movl %esi, %edi
callq 0x23c0
movl %eax, -0xcc(%rbp)
cmpl $0x0, -0xcc(%rbp)
je 0x4306
jmp 0x42e2
movl -0xcc(%rbp), %edi
leaq 0x2aa3(%rip), %rsi      # 0x6d92
leaq 0x20ea(%rip), %rdx      # 0x63e0
leaq 0x2a75(%rip), %rcx      # 0x6d72
movb $0x0, %al
callq 0x4d50
jmp 0x4306
movl $0x1, %edi
leaq -0x20(%rbp), %rsi
callq 0x20d0
movl %eax, -0xcc(%rbp)
cmpl $0x0, -0xcc(%rbp)
je 0x4349
jmp 0x4325
movl -0xcc(%rbp), %edi
leaq 0x2a47(%rip), %rsi      # 0x6d79
leaq 0x20a7(%rip), %rdx      # 0x63e0
leaq 0x2a32(%rip), %rcx      # 0x6d72
movb $0x0, %al
callq 0x4d50
jmp 0x4349
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x4520
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jbe 0x4385
movq -0xc8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0xc8(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x43a5
movq -0xc8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x40(%rax)
movq -0xc8(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x38(%rax), %rcx
movq %rcx, 0x38(%rax)
movq -0xc8(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x28(%rcx), %ecx
cmpq %rcx, %rax
jae 0x43f6
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0xc8(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x441d
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0xc8(%rbp), %rcx
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x4b20
movq -0xc8(%rbp), %rax
cmpq 0x4fcd(%rip), %rax      # 0x93f8
jbe 0x445d
movq -0xc8(%rbp), %rdi
callq 0x4570
movl 0x2b81(%rip), %eax      # 0x6fc0
movl %eax, -0xec(%rbp)
movl -0xec(%rbp), %eax
movl %eax, 0x5053(%rip)      # 0x94a4
movl -0xec(%rbp), %eax
movl %eax, -0xf0(%rbp)
cmpl $0x0, 0x4fb4(%rip)      # 0x9418
jbe 0x447b
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movl 0x4fa4(%rip), %ecx      # 0x9418
cmpq %rcx, %rax
jb 0x447b
jmp 0x4480
jmp 0x424b
xorl %eax, %eax
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax,%rax)