// File: /workspace/github_c_makefile_star2_O0/uhlin[P]enhanced-duc/source/main.c
// Function: start_update_cycle
static void
start_update_cycle(void)
{
	hostname_array_init();

#if defined(OpenBSD) && OpenBSD >= 201811
	if (unveil(enhanced_duc_dir, "r") == -1)
	    fatal(errno, "unveil");
	log_msg("restricted filesystem view to: %s", enhanced_duc_dir);

	struct whitelist_tag {
		const char	*path;
		const char	*permissions;
	} whitelist[] = {
		{ "/etc/ssl/cert.pem", "r" },
	};

	for (struct whitelist_tag *wl_p = &whitelist[0];
	    wl_p < &whitelist[nitems(whitelist)];
	    wl_p++) {
		errno = 0;

		if (unveil(wl_p->path, wl_p->permissions) == -1 &&
		    errno != ENOENT) {
			fatal(errno, "unveil(%s, %s)",
			    wl_p->path,
			    wl_p->permissions);
		}
	}
#endif

#if defined(OpenBSD) && OpenBSD >= 201605
	if (pledge("dns inet rpath stdio", NULL) == -1)
		fatal(errno, "pledge");
	log_msg("forced into a restricted service operating mode (good)");
#endif

	do {
		bool updateRequestAfter30Min = false;

		if (!Cycle || net_check_for_ip_change() == IP_HAS_CHANGED) {
			hostname_array_assign();

			FOREACH_HOSTNAME() {
				if (! (*ar_p))
					break;
				if (updateRequestAfter30Min)
					break;

				log_msg("trying to update %s", *ar_p);

				if (!update_host(*ar_p, setting("ip_addr"),
						 &updateRequestAfter30Min)) {
					log_warn(0, "failed to update "
					    "hostname");
				}
			}

			hostname_array_destroy();
		}
		if (Cycle) {
			struct integer_context ctx = {
				.setting_name = "update_interval_seconds",
				.lo_limit     = 600,    /* 10 minutes */
				.hi_limit     = 172800, /* 2 days */
				.fallback_val = 1800,   /* 30 minutes */
			};
			struct timespec ts = {
				.tv_sec = ((updateRequestAfter30Min)
					   ? 1800
					   : setting_integer(&ctx)),
				.tv_nsec = 0,
			};

			log_debug("sleeping for %ld seconds",
			    ((long int) ts.tv_sec));
			(void) nanosleep(&ts, NULL);
		}
	} while (Cycle);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
callq 0x6a50
movb $0x0, -0x1(%rbp)
testb $0x1, 0x9b98(%rip)      # 0x10490
je 0x6908
callq 0x86f0
cmpl $0x0, %eax
jne 0x69a5
callq 0x6a90
leaq 0xa08c(%rip), %rax      # 0x109a0
movq %rax, -0x10(%rbp)
leaq 0xa081(%rip), %rax      # 0x109a0
addq $0x50, %rax
cmpq %rax, -0x10(%rbp)
jae 0x69a0
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x6935
jmp 0x69a0
testb $0x1, -0x1(%rbp)
je 0x693d
jmp 0x69a0
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0x5272(%rip), %rdi      # 0xbbbd
movb $0x0, %al
callq 0x6260
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
leaq 0x526d(%rip), %rdi      # 0xbbd1
callq 0x9060
movq -0x48(%rbp), %rdi
movq %rax, %rsi
leaq -0x1(%rbp), %rdx
callq 0x6be0
testb $0x1, %al
jne 0x698d
xorl %edi, %edi
leaq 0x5253(%rip), %rsi      # 0xbbd9
movb $0x0, %al
callq 0x6300
jmp 0x698f
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
jmp 0x6918
callq 0x6d60
testb $0x1, 0x9ae4(%rip)      # 0x10490
je 0x6a36
movq 0x92f7(%rip), %rax      # 0xfcb0
movq %rax, -0x30(%rbp)
movq 0x92f4(%rip), %rax      # 0xfcb8
movq %rax, -0x28(%rbp)
movq 0x92f1(%rip), %rax      # 0xfcc0
movq %rax, -0x20(%rbp)
movq 0x92ee(%rip), %rax      # 0xfcc8
movq %rax, -0x18(%rbp)
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
testb $0x1, -0x1(%rbp)
je 0x69f7
movl $0x708, %eax            # imm = 0x708
movq %rax, -0x58(%rbp)
jmp 0x6a04
leaq -0x30(%rbp), %rdi
callq 0x9110
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rcx, (%rax)
movq $0x0, -0x38(%rbp)
movq -0x40(%rbp), %rsi
leaq 0x51e9(%rip), %rdi      # 0xbc0b
movb $0x0, %al
callq 0x6170
leaq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4120
jmp 0x6a38
testb $0x1, 0x9a51(%rip)      # 0x10490
jne 0x68ed
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)