	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_check_battery                  ## -- Begin function check_battery
	.p2align	4, 0x90
_check_battery:                         ## @check_battery
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	_battery_watch_list@GOTPCREL(%rip), %r14
	cmpq	$0, (%r14)
	je	LBB0_5
## %bb.1:
	movq	_apmnorm_fd@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_APMIO_GETINFO@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movb	_check_battery.first_time(%rip), %bl
	leaq	-56(%rbp), %rdx
	callq	_ioctl
	testb	%bl, %bl
	je	LBB0_2
## %bb.6:
	testq	%rax, %rax
	jns	LBB0_8
## %bb.7:
	leaq	L_.str(%rip), %rsi
	movl	$1, %edi
	callq	_err
LBB0_8:
	movl	_check_battery.last_state(%rip), %eax
	movq	_AC_POWER_STATE@GOTPCREL(%rip), %r15
	movl	(%r15), %ecx
	cmpl	%ecx, %eax
	jne	LBB0_10
## %bb.9:
	movq	(%r14), %rbx
	testq	%rbx, %rbx
	jne	LBB0_18
	jmp	LBB0_5
LBB0_2:
	testq	%rax, %rax
	jns	LBB0_4
## %bb.3:
	leaq	L_.str(%rip), %rsi
	movl	$1, %edi
	callq	_err
LBB0_4:
	movq	_AC_POWER_STATE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, _check_battery.last_state(%rip)
	movb	$1, _check_battery.first_time(%rip)
LBB0_5:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_10:
	movq	_soft_power_state_change@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_13
## %bb.11:
	xorl	%eax, %eax
	callq	_fork
	testq	%rax, %rax
	je	LBB0_34
## %bb.12:
	movl	(%r15), %ecx
LBB0_13:
	movl	%ecx, _check_battery.last_state(%rip)
	movq	(%r14), %rbx
	testq	%rbx, %rbx
	je	LBB0_5
## %bb.14:
	movq	%rbx, %rax
	.p2align	4, 0x90
LBB0_15:                                ## =>This Inner Loop Header: Depth=1
	movq	$0, 24(%rax)
	movq	32(%rax), %rax
	testq	%rax, %rax
	jne	LBB0_15
## %bb.16:
	movl	%ecx, %eax
	testq	%rbx, %rbx
	je	LBB0_5
LBB0_18:
	movq	_BATTERY_PERCENT@GOTPCREL(%rip), %r12
	movq	_verbose@GOTPCREL(%rip), %r13
	movq	_BATTERY_MINUTES@GOTPCREL(%rip), %r14
	cmpl	%eax, (%rbx)
	jne	LBB0_32
	.p2align	4, 0x90
LBB0_20:
	cmpq	$0, 24(%rbx)
	jne	LBB0_32
## %bb.21:
	movq	8(%rbx), %rsi
	movq	(%r12), %r9
	cmpq	%r9, %rsi
	jne	LBB0_23
## %bb.22:
	movl	16(%rbx), %ecx
	cmpl	-48(%rbp), %ecx
	je	LBB0_25
LBB0_23:
	cmpq	(%r14), %rsi
	jne	LBB0_32
## %bb.24:
	movl	16(%rbx), %ecx
	movslq	-56(%rbp), %rdx
	imulq	$-2004318071, %rdx, %rdi        ## imm = 0x88888889
	shrq	$32, %rdi
	addl	%edx, %edi
	movl	%edi, %edx
	shrl	$31, %edx
	sarl	$5, %edi
	addl	%edx, %edi
	cmpl	%edi, %ecx
	jne	LBB0_32
LBB0_25:
	movq	$1, 24(%rbx)
	cmpq	$0, (%r13)
	je	LBB0_31
## %bb.26:
	leaq	L_.str.2(%rip), %rdx
	movq	_BATTERY_CHARGING@GOTPCREL(%rip), %rdi
	cmpl	(%rdi), %eax
	je	LBB0_28
## %bb.27:
	leaq	L_.str.3(%rip), %rdx
LBB0_28:
	leaq	L_.str.4(%rip), %r8
	cmpq	%r9, %rsi
	je	LBB0_30
## %bb.29:
	leaq	L_.str.5(%rip), %r8
LBB0_30:
	movq	_LOG_NOTICE@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str.1(%rip), %rsi
	callq	_syslog
LBB0_31:
	xorl	%eax, %eax
	callq	_fork
	testq	%rax, %rax
	je	LBB0_35
	.p2align	4, 0x90
LBB0_32:                                ## =>This Inner Loop Header: Depth=1
	movq	32(%rbx), %rbx
	testq	%rbx, %rbx
	je	LBB0_5
## %bb.33:                              ##   in Loop: Header=BB0_32 Depth=1
	movl	(%r15), %eax
	cmpl	%eax, (%rbx)
	je	LBB0_20
	jmp	LBB0_32
LBB0_35:
	movl	20(%rbx), %edi
	callq	_exec_run_cmd
	movl	%eax, %edi
	callq	_exit
LBB0_34:
	movq	_events@GOTPCREL(%rip), %rax
	movq	_PMEV_POWERSTATECHANGE@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rdi
	shlq	$2, %rdi
	addq	(%rax), %rdi
	callq	_exec_event_cmd
	movl	%eax, %edi
	callq	_exit
	.cfi_endproc
                                        ## -- End function
.zerofill __DATA,__bss,_check_battery.first_time,1,2 ## @check_battery.first_time
.zerofill __DATA,__bss,_check_battery.last_state,4,2 ## @check_battery.last_state
	.comm	_battery_watch_list,8,3         ## @battery_watch_list
	.comm	_apmnorm_fd,4,2                 ## @apmnorm_fd
	.comm	_APMIO_GETINFO,4,2              ## @APMIO_GETINFO
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"cannot check battery state."

	.comm	_AC_POWER_STATE,4,2             ## @AC_POWER_STATE
	.comm	_soft_power_state_change,8,3    ## @soft_power_state_change
	.comm	_events,8,3                     ## @events
	.comm	_PMEV_POWERSTATECHANGE,8,3      ## @PMEV_POWERSTATECHANGE
	.comm	_BATTERY_PERCENT,8,3            ## @BATTERY_PERCENT
	.comm	_BATTERY_MINUTES,8,3            ## @BATTERY_MINUTES
	.comm	_verbose,8,3                    ## @verbose
	.comm	_LOG_NOTICE,4,2                 ## @LOG_NOTICE
L_.str.1:                               ## @.str.1
	.asciz	"Caught battery event: %s, %d%s"

	.comm	_BATTERY_CHARGING,4,2           ## @BATTERY_CHARGING
L_.str.2:                               ## @.str.2
	.asciz	"charging"

L_.str.3:                               ## @.str.3
	.asciz	"discharging"

L_.str.4:                               ## @.str.4
	.asciz	"%"

L_.str.5:                               ## @.str.5
	.asciz	" minutes"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_check_battery                  ; -- Begin function check_battery
	.p2align	2
_check_battery:                         ; @check_battery
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
Lloh0:
	adrp	x19, _battery_watch_list@GOTPAGE
Lloh1:
	ldr	x19, [x19, _battery_watch_list@GOTPAGEOFF]
	ldr	x8, [x19]
	cbz	x8, LBB0_29
; %bb.1:
	adrp	x20, _check_battery.first_time@PAGE
	ldrb	w21, [x20, _check_battery.first_time@PAGEOFF]
Lloh2:
	adrp	x8, _apmnorm_fd@GOTPAGE
Lloh3:
	ldr	x8, [x8, _apmnorm_fd@GOTPAGEOFF]
Lloh4:
	ldr	w0, [x8]
Lloh5:
	adrp	x8, _APMIO_GETINFO@GOTPAGE
Lloh6:
	ldr	x8, [x8, _APMIO_GETINFO@GOTPAGEOFF]
Lloh7:
	ldr	w1, [x8]
	mov	x2, sp
	bl	_ioctl
	tbz	w21, #0, LBB0_6
; %bb.2:
	tbz	x0, #63, LBB0_4
; %bb.3:
Lloh8:
	adrp	x1, l_.str@PAGE
Lloh9:
	add	x1, x1, l_.str@PAGEOFF
	mov	w0, #1
	bl	_err
LBB0_4:
	adrp	x21, _check_battery.last_state@PAGE
	ldr	w8, [x21, _check_battery.last_state@PAGEOFF]
Lloh10:
	adrp	x20, _AC_POWER_STATE@GOTPAGE
Lloh11:
	ldr	x20, [x20, _AC_POWER_STATE@GOTPAGEOFF]
	ldr	w9, [x20]
	cmp	w8, w9
	b.ne	LBB0_9
; %bb.5:
	ldr	x21, [x19]
	b	LBB0_16
LBB0_6:
	tbz	x0, #63, LBB0_8
; %bb.7:
Lloh12:
	adrp	x1, l_.str@PAGE
Lloh13:
	add	x1, x1, l_.str@PAGEOFF
	mov	w0, #1
	bl	_err
LBB0_8:
Lloh14:
	adrp	x8, _AC_POWER_STATE@GOTPAGE
Lloh15:
	ldr	x8, [x8, _AC_POWER_STATE@GOTPAGEOFF]
Lloh16:
	ldr	w8, [x8]
	adrp	x9, _check_battery.last_state@PAGE
	str	w8, [x9, _check_battery.last_state@PAGEOFF]
	mov	w8, #1
	strb	w8, [x20, _check_battery.first_time@PAGEOFF]
	b	LBB0_29
LBB0_9:
Lloh17:
	adrp	x8, _soft_power_state_change@GOTPAGE
Lloh18:
	ldr	x8, [x8, _soft_power_state_change@GOTPAGEOFF]
Lloh19:
	ldr	x8, [x8]
	cbz	x8, LBB0_12
; %bb.10:
	bl	_fork
	cbz	x0, LBB0_31
; %bb.11:
	ldr	w8, [x20]
	b	LBB0_13
LBB0_12:
	mov	x8, x9
LBB0_13:
	str	w8, [x21, _check_battery.last_state@PAGEOFF]
	ldr	x21, [x19]
	cbz	x21, LBB0_29
; %bb.14:
	mov	x9, x21
LBB0_15:                                ; =>This Inner Loop Header: Depth=1
	str	xzr, [x9, #24]
	ldr	x9, [x9, #32]
	cbnz	x9, LBB0_15
LBB0_16:
	cbz	x21, LBB0_29
; %bb.17:
Lloh20:
	adrp	x22, _BATTERY_PERCENT@GOTPAGE
Lloh21:
	ldr	x22, [x22, _BATTERY_PERCENT@GOTPAGEOFF]
Lloh22:
	adrp	x23, _verbose@GOTPAGE
Lloh23:
	ldr	x23, [x23, _verbose@GOTPAGEOFF]
Lloh24:
	adrp	x28, l_.str.5@PAGE
Lloh25:
	add	x28, x28, l_.str.5@PAGEOFF
Lloh26:
	adrp	x24, l_.str.4@PAGE
Lloh27:
	add	x24, x24, l_.str.4@PAGEOFF
	mov	w25, #1
Lloh28:
	adrp	x26, _BATTERY_MINUTES@GOTPAGE
Lloh29:
	ldr	x26, [x26, _BATTERY_MINUTES@GOTPAGEOFF]
	mov	x27, #-30583
	movk	x27, #34952, lsl #16
Lloh30:
	adrp	x19, l_.str.1@PAGE
Lloh31:
	add	x19, x19, l_.str.1@PAGEOFF
LBB0_18:                                ; =>This Inner Loop Header: Depth=1
	ldr	w9, [x21]
	cmp	w9, w8
	b.ne	LBB0_27
; %bb.19:                               ;   in Loop: Header=BB0_18 Depth=1
	ldr	x9, [x21, #24]
	cbnz	x9, LBB0_27
; %bb.20:                               ;   in Loop: Header=BB0_18 Depth=1
	ldr	x9, [x21, #8]
	ldr	x10, [x22]
	cmp	x9, x10
	b.ne	LBB0_22
; %bb.21:                               ;   in Loop: Header=BB0_18 Depth=1
	ldr	w3, [x21, #16]
	ldr	w11, [sp, #8]
	cmp	w3, w11
	b.eq	LBB0_24
LBB0_22:                                ;   in Loop: Header=BB0_18 Depth=1
	ldr	x11, [x26]
	cmp	x9, x11
	b.ne	LBB0_27
; %bb.23:                               ;   in Loop: Header=BB0_18 Depth=1
	ldr	w3, [x21, #16]
	ldrsw	x11, [sp]
	mul	x12, x11, x27
	lsr	x12, x12, #32
	add	w11, w12, w11
	asr	w12, w11, #5
	add	w11, w12, w11, lsr #31
	cmp	w3, w11
	b.ne	LBB0_27
LBB0_24:                                ;   in Loop: Header=BB0_18 Depth=1
	str	x25, [x21, #24]
	ldr	x11, [x23]
	cbz	x11, LBB0_26
; %bb.25:                               ;   in Loop: Header=BB0_18 Depth=1
Lloh32:
	adrp	x11, _LOG_NOTICE@GOTPAGE
Lloh33:
	ldr	x11, [x11, _LOG_NOTICE@GOTPAGEOFF]
Lloh34:
	ldr	w0, [x11]
Lloh35:
	adrp	x11, _BATTERY_CHARGING@GOTPAGE
Lloh36:
	ldr	x11, [x11, _BATTERY_CHARGING@GOTPAGEOFF]
Lloh37:
	ldr	w11, [x11]
	cmp	w8, w11
Lloh38:
	adrp	x8, l_.str.3@PAGE
Lloh39:
	add	x8, x8, l_.str.3@PAGEOFF
Lloh40:
	adrp	x11, l_.str.2@PAGE
Lloh41:
	add	x11, x11, l_.str.2@PAGEOFF
	csel	x2, x11, x8, eq
	cmp	x9, x10
	csel	x4, x24, x28, eq
	mov	x1, x19
	bl	_syslog
LBB0_26:                                ;   in Loop: Header=BB0_18 Depth=1
	bl	_fork
	cbz	x0, LBB0_30
LBB0_27:                                ;   in Loop: Header=BB0_18 Depth=1
	ldr	x21, [x21, #32]
	cbz	x21, LBB0_29
; %bb.28:                               ;   in Loop: Header=BB0_18 Depth=1
	ldr	w8, [x20]
	b	LBB0_18
LBB0_29:
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_30:
	ldr	w0, [x21, #20]
	bl	_exec_run_cmd
	bl	_exit
LBB0_31:
Lloh42:
	adrp	x8, _events@GOTPAGE
Lloh43:
	ldr	x8, [x8, _events@GOTPAGEOFF]
Lloh44:
	ldr	x8, [x8]
Lloh45:
	adrp	x9, _PMEV_POWERSTATECHANGE@GOTPAGE
Lloh46:
	ldr	x9, [x9, _PMEV_POWERSTATECHANGE@GOTPAGEOFF]
Lloh47:
	ldr	x9, [x9]
	add	x0, x8, x9, lsl #2
	bl	_exec_event_cmd
	bl	_exit
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpAdd	Lloh30, Lloh31
	.loh AdrpLdrGot	Lloh28, Lloh29
	.loh AdrpAdd	Lloh26, Lloh27
	.loh AdrpAdd	Lloh24, Lloh25
	.loh AdrpLdrGot	Lloh22, Lloh23
	.loh AdrpLdrGot	Lloh20, Lloh21
	.loh AdrpAdd	Lloh40, Lloh41
	.loh AdrpAdd	Lloh38, Lloh39
	.loh AdrpLdrGotLdr	Lloh35, Lloh36, Lloh37
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.loh AdrpLdrGotLdr	Lloh45, Lloh46, Lloh47
	.loh AdrpLdrGotLdr	Lloh42, Lloh43, Lloh44
	.cfi_endproc
                                        ; -- End function
.zerofill __DATA,__bss,_check_battery.first_time,1,2 ; @check_battery.first_time
.zerofill __DATA,__bss,_check_battery.last_state,4,2 ; @check_battery.last_state
	.comm	_battery_watch_list,8,3         ; @battery_watch_list
	.comm	_apmnorm_fd,4,2                 ; @apmnorm_fd
	.comm	_APMIO_GETINFO,4,2              ; @APMIO_GETINFO
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"cannot check battery state."

	.comm	_AC_POWER_STATE,4,2             ; @AC_POWER_STATE
	.comm	_soft_power_state_change,8,3    ; @soft_power_state_change
	.comm	_events,8,3                     ; @events
	.comm	_PMEV_POWERSTATECHANGE,8,3      ; @PMEV_POWERSTATECHANGE
	.comm	_BATTERY_PERCENT,8,3            ; @BATTERY_PERCENT
	.comm	_BATTERY_MINUTES,8,3            ; @BATTERY_MINUTES
	.comm	_verbose,8,3                    ; @verbose
	.comm	_LOG_NOTICE,4,2                 ; @LOG_NOTICE
l_.str.1:                               ; @.str.1
	.asciz	"Caught battery event: %s, %d%s"

	.comm	_BATTERY_CHARGING,4,2           ; @BATTERY_CHARGING
l_.str.2:                               ; @.str.2
	.asciz	"charging"

l_.str.3:                               ; @.str.3
	.asciz	"discharging"

l_.str.4:                               ; @.str.4
	.asciz	"%"

l_.str.5:                               ; @.str.5
	.asciz	" minutes"

.subsections_via_symbols
