	.file	"extr_rtc-rs5c348.c_rs5c348_rtc_set_time.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	rs5c348_rtc_set_time, @function
rs5c348_rtc_set_time:
.LFB0:
	.cfi_startproc
	endbr64
	push	r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	push	r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	push	r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	push	rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	push	rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	mov	rbx, rsi
	sub	rsp, 64
	.cfi_def_cfa_offset 112
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR 56[rsp], rax
	xor	eax, eax
	lea	r12, 20[rsp]
	call	to_spi_device@PLT
	mov	edi, DWORD PTR RS5C348_REG_CTL2[rip]
	mov	r13, QWORD PTR [rax]
	mov	rbp, rax
	call	RS5C348_CMD_R@PLT
	mov	edi, DWORD PTR RS5C348_REG_CTL2[rip]
	mov	DWORD PTR 4[rsp], 0
	mov	DWORD PTR [rsp], eax
	call	RS5C348_CMD_R@PLT
	mov	rdi, QWORD PTR RS5C348_REG_SECS[rip]
	mov	DWORD PTR 12[rsp], 0
	mov	DWORD PTR 8[rsp], eax
	call	RS5C348_CMD_MW@PLT
	mov	edi, DWORD PTR [rbx]
	mov	DWORD PTR 16[rsp], eax
	mov	rax, QWORD PTR RS5C348_REG_SECS[rip]
	lea	r14, [r12+rax*4]
	call	bin2bcd@PLT
	mov	edi, DWORD PTR 4[rbx]
	mov	DWORD PTR [r14], eax
	mov	rax, QWORD PTR RS5C348_REG_MINS[rip]
	lea	r14, [r12+rax*4]
	call	bin2bcd@PLT
	cmp	QWORD PTR 0[r13], 0
	mov	DWORD PTR [r14], eax
	je	.L2
	mov	rax, QWORD PTR RS5C348_REG_HOURS[rip]
	mov	edi, DWORD PTR 8[rbx]
	lea	r13, [r12+rax*4]
	call	bin2bcd@PLT
	mov	DWORD PTR 0[r13], eax
.L3:
	mov	rax, QWORD PTR RS5C348_REG_WDAY[rip]
	mov	edi, DWORD PTR 12[rbx]
	lea	r13, [r12+rax*4]
	call	bin2bcd@PLT
	mov	edi, DWORD PTR 16[rbx]
	mov	DWORD PTR 0[r13], eax
	mov	rax, QWORD PTR RS5C348_REG_DAY[rip]
	lea	r13, [r12+rax*4]
	call	bin2bcd@PLT
	mov	DWORD PTR 0[r13], eax
	mov	eax, DWORD PTR 20[rbx]
	lea	edi, 1[rax]
	call	bin2bcd@PLT
	mov	edi, DWORD PTR 24[rbx]
	cmp	edi, 99
	jle	.L5
	or	eax, DWORD PTR RS5C348_BIT_Y2K[rip]
.L5:
	mov	rdx, QWORD PTR RS5C348_REG_MONTH[rip]
	mov	r13, rsp
	mov	DWORD PTR 20[rsp+rdx*4], eax
	mov	rax, QWORD PTR RS5C348_REG_YEAR[rip]
	mov	edx, edi
	sar	edx, 31
	lea	rbx, [r12+rax*4]
	movsx	rax, edi
	imul	rax, rax, 1374389535
	sar	rax, 37
	sub	eax, edx
	imul	eax, eax, 100
	sub	edi, eax
	call	bin2bcd@PLT
	xor	r8d, r8d
	xor	ecx, ecx
	mov	edx, 48
	mov	DWORD PTR [rbx], eax
	mov	rsi, r13
	mov	rdi, rbp
	call	spi_write_then_read@PLT
	mov	edi, 62
	mov	r12d, eax
	call	udelay@PLT
	mov	rax, QWORD PTR 56[rsp]
	xor	rax, QWORD PTR fs:40
	jne	.L9
	add	rsp, 64
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	mov	eax, r12d
	pop	rbx
	.cfi_def_cfa_offset 40
	pop	rbp
	.cfi_def_cfa_offset 32
	pop	r12
	.cfi_def_cfa_offset 24
	pop	r13
	.cfi_def_cfa_offset 16
	pop	r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	.cfi_restore_state
	mov	eax, DWORD PTR 8[rbx]
	lea	edi, 11[rax]
	movsx	rax, edi
	mov	edx, edi
	imul	rax, rax, 715827883
	sar	edx, 31
	sar	rax, 33
	sub	eax, edx
	lea	eax, [rax+rax*2]
	sal	eax, 2
	sub	edi, eax
	add	edi, 1
	call	bin2bcd@PLT
	cmp	DWORD PTR 8[rbx], 11
	jle	.L4
	or	eax, DWORD PTR RS5C348_BIT_PM[rip]
.L4:
	mov	rdx, QWORD PTR RS5C348_REG_HOURS[rip]
	mov	DWORD PTR 20[rsp+rdx*4], eax
	jmp	.L3
.L9:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE0:
	.size	rs5c348_rtc_set_time, .-rs5c348_rtc_set_time
	.comm	RS5C348_REG_YEAR,8,8
	.comm	RS5C348_REG_WDAY,8,8
	.comm	RS5C348_REG_SECS,8,8
	.comm	RS5C348_REG_MONTH,8,8
	.comm	RS5C348_REG_MINS,8,8
	.comm	RS5C348_REG_HOURS,8,8
	.comm	RS5C348_REG_DAY,8,8
	.comm	RS5C348_REG_CTL2,4,4
	.comm	RS5C348_BIT_Y2K,4,4
	.comm	RS5C348_BIT_PM,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 2
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"extr_rtc-rs5c348.c_rs5c348_rtc_set_time.c"
	.text
	.section	.rodata.cst4,"aM",%progbits,4
	.align	2
.LC0:
	.word	__stack_chk_guard
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	rs5c348_rtc_set_time, %function
rs5c348_rtc_set_time:
	@ args = 0, pretend = 0, frame = 56
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, lr}
	ldr	r3, .L10
	sub	sp, sp, #64
	mov	r4, r1
	ldr	r3, [r3]
	str	r3, [sp, #60]
	mov	r3,#0
	bl	to_spi_device
	ldr	r5, .L10+4
	ldr	r8, [r0]
	mov	r6, r0
	ldr	r0, [r5]
	bl	RS5C348_CMD_R
	mov	r7, #0
	mov	r3, r0
	ldr	r0, [r5]
	str	r3, [sp, #12]
	str	r7, [sp, #16]
	bl	RS5C348_CMD_R
	mov	r3, r0
	ldr	r5, .L10+8
	str	r7, [sp, #24]
	ldr	r0, [r5]
	str	r3, [sp, #20]
	bl	RS5C348_CMD_MW
	mov	r3, r0
	ldr	r0, [r4]
	ldr	r7, [r5]
	str	r3, [sp, #28]
	bl	bin2bcd
	add	r5, sp, #32
	ldr	r3, .L10+12
	str	r0, [r5, r7, lsl #2]
	ldr	r0, [r4, #4]
	ldr	r7, [r3]
	bl	bin2bcd
	ldr	r3, [r8]
	str	r0, [r5, r7, lsl #2]
	cmp	r3, #0
	beq	.L2
	ldr	r3, .L10+16
	ldr	r0, [r4, #8]
	ldr	r7, [r3]
	bl	bin2bcd
	str	r0, [r5, r7, lsl #2]
.L3:
	ldr	r3, .L10+20
	ldr	r0, [r4, #12]
	ldr	r7, [r3]
	bl	bin2bcd
	ldr	r3, .L10+24
	str	r0, [r5, r7, lsl #2]
	ldr	r0, [r4, #16]
	ldr	r7, [r3]
	bl	bin2bcd
	ldr	r3, [r4, #20]
	str	r0, [r5, r7, lsl #2]
	add	r0, r3, #1
	bl	bin2bcd
	mov	r2, r0
	ldr	r1, [r4, #24]
	ldr	lr, .L10+28
	cmp	r1, #99
	ldrgt	r3, .L10+32
	ldr	r4, [lr]
	ldrgt	r3, [r3]
	orrgt	r2, r0, r3
	ldr	r0, .L10+36
	asr	r3, r1, #31
	smull	ip, r0, r1, r0
	ldr	ip, .L10+40
	rsb	r3, r3, r0, asr #5
	add	r3, r3, r3, lsl #2
	ldr	ip, [ip]
	add	r3, r3, r3, lsl #2
	sub	r0, r1, r3, lsl #2
	add	r3, sp, #64
	add	ip, r3, ip, lsl #2
	str	r2, [ip, #-32]
	bl	bin2bcd
	mov	r3, #0
	mov	ip, r0
	str	r3, [sp]
	mov	r2, #48
	str	ip, [r5, r4, lsl #2]
	add	r1, sp, #12
	mov	r0, r6
	bl	spi_write_then_read
	mov	r4, r0
	mov	r0, #62
	bl	udelay
	ldr	r3, .L10
	ldr	r2, [r3]
	ldr	r3, [sp, #60]
	eors	r2, r3, r2
	mov	r3, #0
	bne	.L9
	mov	r0, r4
	add	sp, sp, #64
	@ sp needed
	pop	{r4, r5, r6, r7, r8, pc}
.L2:
	ldr	r0, [r4, #8]
	ldr	r3, .L10+44
	add	r0, r0, #11
	smull	r1, r2, r3, r0
	asr	r3, r0, #31
	rsb	r3, r3, r2, asr #1
	add	r3, r3, r3, lsl #1
	sub	r0, r0, r3, lsl #2
	add	r0, r0, #1
	bl	bin2bcd
	ldr	r3, [r4, #8]
	add	r2, sp, #64
	cmp	r3, #11
	ldrgt	r3, .L10+48
	ldrgt	r3, [r3]
	orrgt	r0, r0, r3
	ldr	r3, .L10+16
	ldr	r3, [r3]
	add	r3, r2, r3, lsl #2
	str	r0, [r3, #-32]
	b	.L3
.L9:
	bl	__stack_chk_fail
.L11:
	.align	2
.L10:
	.word	.LC0
	.word	RS5C348_REG_CTL2
	.word	RS5C348_REG_SECS
	.word	RS5C348_REG_MINS
	.word	RS5C348_REG_HOURS
	.word	RS5C348_REG_WDAY
	.word	RS5C348_REG_DAY
	.word	RS5C348_REG_YEAR
	.word	RS5C348_BIT_Y2K
	.word	1374389535
	.word	RS5C348_REG_MONTH
	.word	715827883
	.word	RS5C348_BIT_PM
	.size	rs5c348_rtc_set_time, .-rs5c348_rtc_set_time
	.comm	RS5C348_REG_YEAR,4,4
	.comm	RS5C348_REG_WDAY,4,4
	.comm	RS5C348_REG_SECS,4,4
	.comm	RS5C348_REG_MONTH,4,4
	.comm	RS5C348_REG_MINS,4,4
	.comm	RS5C348_REG_HOURS,4,4
	.comm	RS5C348_REG_DAY,4,4
	.comm	RS5C348_REG_CTL2,4,4
	.comm	RS5C348_BIT_Y2K,4,4
	.comm	RS5C348_BIT_PM,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
