	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function apply_periodic_ad_state
_apply_periodic_ad_state:               ## @apply_periodic_ad_state
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -24
	movq	_ADF_PERIODIC@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%rdi)
	je	LBB0_2
## %bb.1:
	movq	%rdi, %rbx
	callq	_reinsert_retarget_ad_last
	movq	_log_last_ts@GOTPCREL(%rip), %rax
	movq	_RETARGET_AD_TIMEOUT@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	cmpl	$3601, %ecx                     ## imm = 0xE11
	movl	$3600, %edx                     ## imm = 0xE10
	cmovgel	%ecx, %edx
	addl	(%rax), %edx
	movslq	%edx, %rax
	imulq	$-1851608123, %rax, %rcx        ## imm = 0x91A2B3C5
	shrq	$32, %rcx
	addl	%ecx, %eax
	movl	%eax, %ecx
	shrl	$31, %ecx
	sarl	$11, %eax
	addl	%ecx, %eax
	imull	$3600, %eax, %r8d               ## imm = 0xE10
	movl	%r8d, 4(%rbx)
	movq	_verbosity@GOTPCREL(%rip), %rax
	cmpl	$2, (%rax)
	jl	LBB0_2
## %bb.3:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	8(%rbx), %edx
	leaq	L_.str(%rip), %rsi
	movq	%rbx, %rcx
	addq	$8, %rsp
	popq	%rbx
	popq	%rbp
	jmp	_fprintf                        ## TAILCALL
LBB0_2:
	addq	$8, %rsp
	popq	%rbx
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_ADF_PERIODIC,4,2               ## @ADF_PERIODIC
	.comm	_log_last_ts,4,2                ## @log_last_ts
	.comm	_RETARGET_AD_TIMEOUT,4,2        ## @RETARGET_AD_TIMEOUT
	.comm	_verbosity,4,2                  ## @verbosity
	.comm	_stderr,4,2                     ## @stderr
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"inserting ad #%d (%p) into retarget queue, retarget_time=%d\n"

	.no_dead_strip	_apply_periodic_ad_state
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function apply_periodic_ad_state
_apply_periodic_ad_state:               ; @apply_periodic_ad_state
	.cfi_startproc
; %bb.0:
	stp	x20, x19, [sp, #-32]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 32
	stp	x29, x30, [sp, #16]             ; 16-byte Folded Spill
	add	x29, sp, #16
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	ldr	w8, [x0]
Lloh0:
	adrp	x9, _ADF_PERIODIC@GOTPAGE
Lloh1:
	ldr	x9, [x9, _ADF_PERIODIC@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_3
; %bb.1:
	mov	x19, x0
	bl	_reinsert_retarget_ad_last
Lloh3:
	adrp	x8, _log_last_ts@GOTPAGE
Lloh4:
	ldr	x8, [x8, _log_last_ts@GOTPAGEOFF]
Lloh5:
	adrp	x9, _RETARGET_AD_TIMEOUT@GOTPAGE
Lloh6:
	ldr	x9, [x9, _RETARGET_AD_TIMEOUT@GOTPAGEOFF]
Lloh7:
	ldr	w8, [x8]
Lloh8:
	ldr	w9, [x9]
	mov	w10, #3600
	cmp	w9, #3600
	csel	w9, w9, w10, gt
	mov	w11, #46021
	movk	w11, #37282, lsl #16
	add	w8, w9, w8
	smull	x9, w8, w11
	lsr	x9, x9, #32
	add	w8, w9, w8
	asr	w9, w8, #11
	add	w8, w9, w8, lsr #31
	mul	w4, w8, w10
	str	w4, [x19, #4]
Lloh9:
	adrp	x8, _verbosity@GOTPAGE
Lloh10:
	ldr	x8, [x8, _verbosity@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	cmp	w8, #2
	b.lt	LBB0_3
; %bb.2:
Lloh12:
	adrp	x8, _stderr@GOTPAGE
Lloh13:
	ldr	x8, [x8, _stderr@GOTPAGEOFF]
Lloh14:
	ldr	w0, [x8]
Lloh15:
	adrp	x1, l_.str@PAGE
Lloh16:
	add	x1, x1, l_.str@PAGEOFF
	ldr	w2, [x19, #8]
	mov	x3, x19
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp], #32             ; 16-byte Folded Reload
	b	_fprintf
LBB0_3:
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp], #32             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh7
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.cfi_endproc
                                        ; -- End function
	.comm	_ADF_PERIODIC,4,2               ; @ADF_PERIODIC
	.comm	_log_last_ts,4,2                ; @log_last_ts
	.comm	_RETARGET_AD_TIMEOUT,4,2        ; @RETARGET_AD_TIMEOUT
	.comm	_verbosity,4,2                  ; @verbosity
	.comm	_stderr,4,2                     ; @stderr
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"inserting ad #%d (%p) into retarget queue, retarget_time=%d\n"

	.no_dead_strip	_apply_periodic_ad_state
.subsections_via_symbols
