	.file	"432005.c"
	.intel_syntax noprefix
	.text
	.globl	x_mutex
	.bss
	.align 32
	.type	x_mutex, @object
	.size	x_mutex, 40
x_mutex:
	.zero	40
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	test_ready
	.align 4
	.type	test_ready, @object
	.size	test_ready, 4
test_ready:
	.zero	4
	.section	.rodata
.LC0:
	.string	"error in thread %d create\n"
.LC1:
	.string	"error in thread %d join\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	sub	rsp, 64
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR -8[rbp], rax
	xor	eax, eax
	mov	esi, 0
	lea	rdi, x_mutex[rip]
	call	pthread_mutex_init@PLT
	mov	DWORD PTR -56[rbp], 0
	jmp	.L2
.L4:
	mov	eax, DWORD PTR -56[rbp]
	cdqe
	mov	rdx, rax
	lea	rcx, -48[rbp]
	mov	eax, DWORD PTR -56[rbp]
	cdqe
	sal	rax, 3
	add	rax, rcx
	mov	rcx, rdx
	lea	rdx, thread_function[rip]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_create@PLT
	mov	DWORD PTR -52[rbp], eax
	cmp	DWORD PTR -52[rbp], 0
	je	.L3
	mov	rax, QWORD PTR stderr[rip]
	mov	edx, DWORD PTR -56[rbp]
	lea	rsi, .LC0[rip]
	mov	rdi, rax
	mov	eax, 0
	call	fprintf@PLT
	call	abort@PLT
.L3:
	add	DWORD PTR -56[rbp], 1
.L2:
	cmp	DWORD PTR -56[rbp], 3
	jle	.L4
	mov	DWORD PTR -56[rbp], 0
	jmp	.L5
.L7:
	mov	eax, DWORD PTR -56[rbp]
	cdqe
	mov	rax, QWORD PTR -48[rbp+rax*8]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_join@PLT
	mov	DWORD PTR -52[rbp], eax
	cmp	DWORD PTR -52[rbp], 0
	je	.L6
	mov	rax, QWORD PTR stderr[rip]
	mov	edx, DWORD PTR -56[rbp]
	lea	rsi, .LC1[rip]
	mov	rdi, rax
	mov	eax, 0
	call	fprintf@PLT
	call	abort@PLT
.L6:
	add	DWORD PTR -56[rbp], 1
.L5:
	cmp	DWORD PTR -56[rbp], 3
	jle	.L7
	mov	edi, 0
	call	exit@PLT
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.globl	thread_started
	.type	thread_started, @function
thread_started:
.LFB7:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	nop
	pop	rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	thread_started, .-thread_started
	.section	.rodata
	.align 8
.LC2:
	.string	"Thread %ld changing x %d -> %d\n"
	.text
	.globl	thread_function
	.type	thread_function, @function
thread_function:
.LFB8:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	sub	rsp, 32
	mov	QWORD PTR -24[rbp], rdi
	mov	eax, 0
	call	thread_started
	jmp	.L11
.L12:
	mov	edi, 1
	call	usleep@PLT
.L11:
	mov	eax, DWORD PTR test_ready[rip]
	test	eax, eax
	je	.L12
	mov	DWORD PTR -4[rbp], 0
	jmp	.L13
.L14:
	lea	rdi, x_mutex[rip]
	call	pthread_mutex_lock@PLT
	mov	eax, DWORD PTR x[rip]
	lea	ecx, 1[rax]
	mov	edx, DWORD PTR x[rip]
	mov	rax, QWORD PTR -24[rbp]
	mov	rsi, rax
	lea	rdi, .LC2[rip]
	mov	eax, 0
	call	printf@PLT
	mov	eax, DWORD PTR x[rip]
	add	eax, 1
	mov	DWORD PTR x[rip], eax
	mov	edi, 1
	call	usleep@PLT
	lea	rdi, x_mutex[rip]
	call	pthread_mutex_unlock@PLT
	add	DWORD PTR -4[rbp], 1
.L13:
	cmp	DWORD PTR -4[rbp], 9
	jle	.L14
	mov	edi, 0
	call	pthread_exit@PLT
	.cfi_endproc
.LFE8:
	.size	thread_function, .-thread_function
	.ident	"GCC: (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.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, 6
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"432005.c"
	.text
	.comm	x_mutex,24,4
	.comm	x,4,4
	.global	test_ready
	.bss
	.align	2
	.type	test_ready, %object
	.size	test_ready, 4
test_ready:
	.space	4
	.section	.rodata
	.align	2
.LC0:
	.ascii	"error in thread %d create\012\000"
	.align	2
.LC1:
	.ascii	"error in thread %d join\012\000"
	.align	2
.LC2:
	.word	__stack_chk_guard
	.text
	.align	2
	.global	main
	.syntax unified
	.arm
	.fpu softvfp
	.type	main, %function
main:
	@ args = 0, pretend = 0, frame = 32
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #32
	ldr	r3, .L9
	ldr	r3, [r3]
	str	r3, [fp, #-8]
	mov	r3,#0
	mov	r1, #0
	ldr	r0, .L9+4
	bl	pthread_mutex_init
	mov	r3, #0
	str	r3, [fp, #-32]
	b	.L2
.L4:
	sub	r2, fp, #24
	ldr	r3, [fp, #-32]
	lsl	r3, r3, #2
	add	r0, r2, r3
	ldr	r3, [fp, #-32]
	ldr	r2, .L9+8
	mov	r1, #0
	bl	pthread_create
	str	r0, [fp, #-28]
	ldr	r3, [fp, #-28]
	cmp	r3, #0
	beq	.L3
	ldr	r3, .L9+12
	ldr	r3, [r3]
	ldr	r2, [fp, #-32]
	ldr	r1, .L9+16
	mov	r0, r3
	bl	fprintf
	bl	abort
.L3:
	ldr	r3, [fp, #-32]
	add	r3, r3, #1
	str	r3, [fp, #-32]
.L2:
	ldr	r3, [fp, #-32]
	cmp	r3, #3
	ble	.L4
	mov	r3, #0
	str	r3, [fp, #-32]
	b	.L5
.L7:
	ldr	r3, [fp, #-32]
	lsl	r3, r3, #2
	sub	r2, fp, #4
	add	r3, r2, r3
	ldr	r3, [r3, #-20]
	mov	r1, #0
	mov	r0, r3
	bl	pthread_join
	str	r0, [fp, #-28]
	ldr	r3, [fp, #-28]
	cmp	r3, #0
	beq	.L6
	ldr	r3, .L9+12
	ldr	r3, [r3]
	ldr	r2, [fp, #-32]
	ldr	r1, .L9+20
	mov	r0, r3
	bl	fprintf
	bl	abort
.L6:
	ldr	r3, [fp, #-32]
	add	r3, r3, #1
	str	r3, [fp, #-32]
.L5:
	ldr	r3, [fp, #-32]
	cmp	r3, #3
	ble	.L7
	mov	r0, #0
	bl	exit
.L10:
	.align	2
.L9:
	.word	.LC2
	.word	x_mutex
	.word	thread_function
	.word	stderr
	.word	.LC0
	.word	.LC1
	.size	main, .-main
	.align	2
	.global	thread_started
	.syntax unified
	.arm
	.fpu softvfp
	.type	thread_started, %function
thread_started:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 1, uses_anonymous_args = 0
	@ link register save eliminated.
	str	fp, [sp, #-4]!
	add	fp, sp, #0
	nop
	add	sp, fp, #0
	@ sp needed
	ldr	fp, [sp], #4
	bx	lr
	.size	thread_started, .-thread_started
	.section	.rodata
	.align	2
.LC3:
	.ascii	"Thread %ld changing x %d -> %d\012\000"
	.text
	.align	2
	.global	thread_function
	.syntax unified
	.arm
	.fpu softvfp
	.type	thread_function, %function
thread_function:
	@ args = 0, pretend = 0, frame = 16
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #16
	str	r0, [fp, #-16]
	bl	thread_started
	b	.L13
.L14:
	mov	r0, #1
	bl	usleep
.L13:
	ldr	r3, .L17
	ldr	r3, [r3]
	cmp	r3, #0
	beq	.L14
	mov	r3, #0
	str	r3, [fp, #-8]
	b	.L15
.L16:
	ldr	r0, .L17+4
	bl	pthread_mutex_lock
	ldr	r1, [fp, #-16]
	ldr	r3, .L17+8
	ldr	r2, [r3]
	ldr	r3, .L17+8
	ldr	r3, [r3]
	add	r3, r3, #1
	ldr	r0, .L17+12
	bl	printf
	ldr	r3, .L17+8
	ldr	r3, [r3]
	add	r3, r3, #1
	ldr	r2, .L17+8
	str	r3, [r2]
	mov	r0, #1
	bl	usleep
	ldr	r0, .L17+4
	bl	pthread_mutex_unlock
	ldr	r3, [fp, #-8]
	add	r3, r3, #1
	str	r3, [fp, #-8]
.L15:
	ldr	r3, [fp, #-8]
	cmp	r3, #9
	ble	.L16
	mov	r0, #0
	bl	pthread_exit
.L18:
	.align	2
.L17:
	.word	test_ready
	.word	x_mutex
	.word	x
	.word	.LC3
	.size	thread_function, .-thread_function
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
