	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_sys_dup3                       ## -- Begin function sys_dup3
	.p2align	4, 0x90
_sys_dup3:                              ## @sys_dup3
	.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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%edx, %r14d
	movq	%rsi, %r13
	movq	%rdi, %rbx
	leaq	L_.str(%rip), %rdi
	movq	%rbx, %rsi
	movq	%r13, %rdx
	movl	%r14d, %ecx
	callq	_STRACE
	movq	_current@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	(%rax), %r15
	movq	%rbx, %rdi
	callq	_f_get
	testq	%rax, %rax
	je	LBB0_1
## %bb.2:
	movq	%rax, %r12
	movq	%r15, %rdi
	movq	%r13, %rsi
	callq	_fdtable_expand
	testl	%eax, %eax
	js	LBB0_3
## %bb.4:
	movq	%r12, %rdi
	callq	_fd_retain
	movq	%r13, %rdi
	callq	_f_close
	movq	8(%r15), %rax
	movq	%r12, (%rax,%r13,8)
	movq	_O_CLOEXEC_@GOTPCREL(%rip), %rax
	testl	%r14d, (%rax)
	je	LBB0_6
## %bb.5:
	movl	(%r15), %esi
	movq	%r13, %rdi
	callq	_bit_set
	jmp	LBB0_6
LBB0_1:
	movq	__EBADF@GOTPCREL(%rip), %rax
	movl	(%rax), %r13d
	jmp	LBB0_6
LBB0_3:
	movl	%eax, %r13d
LBB0_6:
	movl	%r13d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"dup3(%d, %d, %d)"

	.comm	_current,8,3                    ## @current
	.comm	__EBADF,4,2                     ## @_EBADF
	.comm	_O_CLOEXEC_,4,2                 ## @O_CLOEXEC_
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_sys_dup3                       ; -- Begin function sys_dup3
	.p2align	2
_sys_dup3:                              ; @sys_dup3
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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
	mov	x20, x2
	mov	x19, x1
	mov	x22, x0
Lloh0:
	adrp	x0, l_.str@PAGE
Lloh1:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x22
	mov	x2, x19
	mov	x3, x20
	bl	_STRACE
Lloh2:
	adrp	x8, _current@GOTPAGE
Lloh3:
	ldr	x8, [x8, _current@GOTPAGEOFF]
Lloh4:
	ldr	x8, [x8]
	ldr	x21, [x8]
	mov	x0, x22
	bl	_f_get
	cbz	x0, LBB0_4
; %bb.1:
	mov	x22, x0
	mov	x0, x21
	mov	x1, x19
	bl	_fdtable_expand
	tbnz	w0, #31, LBB0_5
; %bb.2:
	mov	x0, x22
	bl	_fd_retain
	mov	x0, x19
	bl	_f_close
	ldr	x8, [x21, #8]
	str	x22, [x8, x19, lsl #3]
Lloh5:
	adrp	x8, _O_CLOEXEC_@GOTPAGE
Lloh6:
	ldr	x8, [x8, _O_CLOEXEC_@GOTPAGEOFF]
Lloh7:
	ldr	w8, [x8]
	tst	w8, w20
	b.eq	LBB0_6
; %bb.3:
	ldr	w1, [x21]
	mov	x0, x19
	bl	_bit_set
	b	LBB0_6
LBB0_4:
Lloh8:
	adrp	x8, __EBADF@GOTPAGE
Lloh9:
	ldr	x8, [x8, __EBADF@GOTPAGEOFF]
Lloh10:
	ldr	w19, [x8]
	b	LBB0_6
LBB0_5:
	mov	x19, x0
LBB0_6:
	mov	x0, x19
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"dup3(%d, %d, %d)"

	.comm	_current,8,3                    ; @current
	.comm	__EBADF,4,2                     ; @_EBADF
	.comm	_O_CLOEXEC_,4,2                 ; @O_CLOEXEC_
.subsections_via_symbols
