	.file	"562029.c"
	.intel_syntax noprefix
	.text
	.globl	process_semaphore
	.bss
	.align 8
	.type	process_semaphore, @object
	.size	process_semaphore, 8
process_semaphore:
	.zero	8
	.globl	thread_barrier
	.align 32
	.type	thread_barrier, @object
	.size	thread_barrier, 32
thread_barrier:
	.zero	32
	.globl	number_of_threads
	.data
	.align 4
	.type	number_of_threads, @object
	.size	number_of_threads, 4
number_of_threads:
	.long	10
	.section	.rodata
.LC2:
	.string	"sem_wait"
	.align 8
.LC4:
	.string	"fase 1, thread id=%lu, sleep period=%lfsecondi\n"
.LC5:
	.string	"sem_post"
	.align 8
.LC6:
	.string	"fase 2, thread id=%lu, dopo la barriera\n"
.LC7:
	.string	"thread id=%lu bye!\n"
	.text
	.globl	thread_function
	.type	thread_function, @function
thread_function:
.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, 48
	mov	QWORD PTR -40[rbp], rdi
	call	pthread_self@PLT
	mov	QWORD PTR -16[rbp], rax
	call	random@PLT
	pxor	xmm0, xmm0
	cvtsi2sd	xmm0, rax
	movsd	xmm2, QWORD PTR .LC0[rip]
	movapd	xmm1, xmm0
	divsd	xmm1, xmm2
	movsd	xmm0, QWORD PTR .LC1[rip]
	mulsd	xmm0, xmm1
	cvttsd2si	eax, xmm0
	mov	DWORD PTR -20[rbp], eax
	mov	eax, DWORD PTR -20[rbp]
	mov	edi, eax
	call	usleep@PLT
	mov	rax, QWORD PTR process_semaphore[rip]
	mov	rdi, rax
	call	sem_wait@PLT
	cmp	eax, -1
	jne	.L2
	lea	rdi, .LC2[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L2:
	pxor	xmm0, xmm0
	cvtsi2sd	xmm0, DWORD PTR -20[rbp]
	movsd	xmm1, QWORD PTR .LC3[rip]
	divsd	xmm0, xmm1
	movsd	QWORD PTR -8[rbp], xmm0
	mov	rdx, QWORD PTR -8[rbp]
	mov	rax, QWORD PTR -16[rbp]
	movq	xmm0, rdx
	mov	rsi, rax
	lea	rdi, .LC4[rip]
	mov	eax, 1
	call	printf@PLT
	mov	rax, QWORD PTR process_semaphore[rip]
	mov	rdi, rax
	call	sem_post@PLT
	cmp	eax, -1
	jne	.L3
	lea	rdi, .LC5[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L3:
	lea	rdi, thread_barrier[rip]
	call	pthread_barrier_wait@PLT
	mov	rax, QWORD PTR -16[rbp]
	mov	rsi, rax
	lea	rdi, .LC6[rip]
	mov	eax, 0
	call	printf@PLT
	mov	edi, 10000
	call	usleep@PLT
	mov	rax, QWORD PTR -16[rbp]
	mov	rsi, rax
	lea	rdi, .LC7[rip]
	mov	eax, 0
	call	printf@PLT
	mov	eax, 0
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	thread_function, .-thread_function
	.section	.rodata
.LC8:
	.string	"output.txt"
.LC9:
	.string	"open()"
.LC10:
	.string	"problema con dup2"
.LC11:
	.string	"close"
.LC12:
	.string	"sem_init"
.LC13:
	.string	"pthread_barrier_init"
.LC14:
	.string	"pthread_create"
.LC15:
	.string	"pthread_join"
.LC16:
	.string	"pthread_barrier_destroy"
.LC17:
	.string	"bye"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	add	rsp, -128
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR -8[rbp], rax
	xor	eax, eax
	lea	rax, .LC8[rip]
	mov	QWORD PTR -104[rbp], rax
	mov	rax, QWORD PTR -104[rbp]
	mov	edx, 384
	mov	esi, 577
	mov	rdi, rax
	mov	eax, 0
	call	open@PLT
	mov	DWORD PTR -112[rbp], eax
	cmp	DWORD PTR -112[rbp], -1
	jne	.L6
	lea	rdi, .LC9[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L6:
	mov	eax, DWORD PTR -112[rbp]
	mov	esi, 1
	mov	edi, eax
	call	dup2@PLT
	cmp	eax, -1
	jne	.L7
	lea	rdi, .LC10[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L7:
	mov	eax, DWORD PTR -112[rbp]
	mov	edi, eax
	call	close@PLT
	cmp	eax, -1
	jne	.L8
	lea	rdi, .LC11[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L8:
	mov	edi, 32
	call	malloc@PLT
	mov	QWORD PTR process_semaphore[rip], rax
	mov	rax, QWORD PTR process_semaphore[rip]
	mov	edx, 1
	mov	esi, 0
	mov	rdi, rax
	call	sem_init@PLT
	mov	DWORD PTR -108[rbp], eax
	cmp	DWORD PTR -108[rbp], -1
	jne	.L9
	lea	rdi, .LC12[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L9:
	mov	edx, 10
	mov	esi, 0
	lea	rdi, thread_barrier[rip]
	call	pthread_barrier_init@PLT
	mov	DWORD PTR -108[rbp], eax
	cmp	DWORD PTR -108[rbp], -1
	jne	.L10
	lea	rdi, .LC13[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L10:
	mov	DWORD PTR -120[rbp], 0
	jmp	.L11
.L13:
	lea	rdx, -96[rbp]
	mov	eax, DWORD PTR -120[rbp]
	cdqe
	sal	rax, 3
	add	rax, rdx
	mov	ecx, 0
	lea	rdx, thread_function[rip]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_create@PLT
	mov	DWORD PTR -108[rbp], eax
	cmp	DWORD PTR -108[rbp], 0
	je	.L12
	lea	rdi, .LC14[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L12:
	add	DWORD PTR -120[rbp], 1
.L11:
	mov	eax, DWORD PTR number_of_threads[rip]
	cmp	DWORD PTR -120[rbp], eax
	jl	.L13
	mov	DWORD PTR -116[rbp], 0
	jmp	.L14
.L16:
	mov	eax, DWORD PTR -116[rbp]
	cdqe
	mov	rax, QWORD PTR -96[rbp+rax*8]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_join@PLT
	mov	DWORD PTR -108[rbp], eax
	cmp	DWORD PTR -108[rbp], 0
	je	.L15
	lea	rdi, .LC15[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L15:
	add	DWORD PTR -116[rbp], 1
.L14:
	mov	eax, DWORD PTR number_of_threads[rip]
	cmp	DWORD PTR -116[rbp], eax
	jl	.L16
	lea	rdi, thread_barrier[rip]
	call	pthread_barrier_destroy@PLT
	mov	DWORD PTR -108[rbp], eax
	cmp	DWORD PTR -108[rbp], -1
	jne	.L17
	lea	rdi, .LC16[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L17:
	lea	rdi, .LC17[rip]
	call	puts@PLT
	mov	eax, 0
	mov	rcx, QWORD PTR -8[rbp]
	sub	rcx, QWORD PTR fs:40
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	main, .-main
	.section	.rodata
	.align 8
.LC0:
	.long	-4194304
	.long	1105199103
	.align 8
.LC1:
	.long	0
	.long	1095164768
	.align 8
.LC3:
	.long	0
	.long	1093567616
	.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	"562029.c"
	.text
	.comm	process_semaphore,4,4
	.comm	thread_barrier,20,4
	.global	number_of_threads
	.data
	.align	2
	.type	number_of_threads, %object
	.size	number_of_threads, 4
number_of_threads:
	.word	10
	.global	__aeabi_i2d
	.global	__aeabi_ddiv
	.global	__aeabi_dmul
	.global	__aeabi_d2iz
	.section	.rodata
	.align	2
.LC0:
	.ascii	"sem_wait\000"
	.align	2
.LC1:
	.ascii	"fase 1, thread id=%lu, sleep period=%lfsecondi\012\000"
	.align	2
.LC2:
	.ascii	"sem_post\000"
	.align	2
.LC3:
	.ascii	"fase 2, thread id=%lu, dopo la barriera\012\000"
	.align	2
.LC4:
	.ascii	"thread id=%lu bye!\012\000"
	.text
	.align	2
	.global	thread_function
	.syntax unified
	.arm
	.fpu softvfp
	.type	thread_function, %function
thread_function:
	@ args = 0, pretend = 0, frame = 24
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #24
	str	r0, [fp, #-24]
	bl	pthread_self
	mov	r3, r0
	str	r3, [fp, #-20]
	bl	random
	mov	r3, r0
	mov	r0, r3
	bl	__aeabi_i2d
	ldr	r2, .L5
	ldr	r3, .L5+4
	bl	__aeabi_ddiv
	mov	r2, r0
	mov	r3, r1
	mov	r0, r2
	mov	r1, r3
	mov	r2, #0
	ldr	r3, .L5+8
	bl	__aeabi_dmul
	mov	r2, r0
	mov	r3, r1
	mov	r0, r2
	mov	r1, r3
	bl	__aeabi_d2iz
	mov	r3, r0
	str	r3, [fp, #-16]
	ldr	r3, [fp, #-16]
	mov	r0, r3
	bl	usleep
	ldr	r3, .L5+12
	ldr	r3, [r3]
	mov	r0, r3
	bl	sem_wait
	mov	r3, r0
	cmn	r3, #1
	bne	.L2
	ldr	r0, .L5+16
	bl	perror
	mov	r0, #1
	bl	exit
.L2:
	ldr	r0, [fp, #-16]
	bl	__aeabi_i2d
	mov	r2, #0
	ldr	r3, .L5+20
	bl	__aeabi_ddiv
	mov	r2, r0
	mov	r3, r1
	str	r2, [fp, #-12]
	str	r3, [fp, #-8]
	sub	r3, fp, #12
	ldmia	r3, {r2-r3}
	ldr	r1, [fp, #-20]
	ldr	r0, .L5+24
	bl	printf
	ldr	r3, .L5+12
	ldr	r3, [r3]
	mov	r0, r3
	bl	sem_post
	mov	r3, r0
	cmn	r3, #1
	bne	.L3
	ldr	r0, .L5+28
	bl	perror
	mov	r0, #1
	bl	exit
.L3:
	ldr	r0, .L5+32
	bl	pthread_barrier_wait
	ldr	r1, [fp, #-20]
	ldr	r0, .L5+36
	bl	printf
	ldr	r0, .L5+40
	bl	usleep
	ldr	r1, [fp, #-20]
	ldr	r0, .L5+44
	bl	printf
	mov	r3, #0
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L6:
	.align	2
.L5:
	.word	-4194304
	.word	1105199103
	.word	1095164768
	.word	process_semaphore
	.word	.LC0
	.word	1093567616
	.word	.LC1
	.word	.LC2
	.word	thread_barrier
	.word	.LC3
	.word	10000
	.word	.LC4
	.size	thread_function, .-thread_function
	.section	.rodata
	.align	2
.LC5:
	.ascii	"output.txt\000"
	.align	2
.LC6:
	.ascii	"open()\000"
	.align	2
.LC7:
	.ascii	"problema con dup2\000"
	.align	2
.LC8:
	.ascii	"close\000"
	.align	2
.LC9:
	.ascii	"sem_init\000"
	.align	2
.LC10:
	.ascii	"pthread_barrier_init\000"
	.align	2
.LC11:
	.ascii	"pthread_create\000"
	.align	2
.LC12:
	.ascii	"pthread_join\000"
	.align	2
.LC13:
	.ascii	"pthread_barrier_destroy\000"
	.align	2
.LC14:
	.ascii	"bye\000"
	.align	2
.LC15:
	.word	__stack_chk_guard
	.text
	.align	2
	.global	main
	.syntax unified
	.arm
	.fpu softvfp
	.type	main, %function
main:
	@ args = 0, pretend = 0, frame = 64
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #64
	ldr	r3, .L22
	ldr	r3, [r3]
	str	r3, [fp, #-8]
	mov	r3,#0
	ldr	r3, .L22+4
	str	r3, [fp, #-60]
	mov	r2, #384
	ldr	r1, .L22+8
	ldr	r0, [fp, #-60]
	bl	open
	str	r0, [fp, #-56]
	ldr	r3, [fp, #-56]
	cmn	r3, #1
	bne	.L8
	ldr	r0, .L22+12
	bl	perror
	mov	r0, #1
	bl	exit
.L8:
	mov	r1, #1
	ldr	r0, [fp, #-56]
	bl	dup2
	mov	r3, r0
	cmn	r3, #1
	bne	.L9
	ldr	r0, .L22+16
	bl	perror
	mov	r0, #1
	bl	exit
.L9:
	ldr	r0, [fp, #-56]
	bl	close
	mov	r3, r0
	cmn	r3, #1
	bne	.L10
	ldr	r0, .L22+20
	bl	perror
	mov	r0, #1
	bl	exit
.L10:
	mov	r0, #16
	bl	malloc
	mov	r3, r0
	mov	r2, r3
	ldr	r3, .L22+24
	str	r2, [r3]
	ldr	r3, .L22+24
	ldr	r3, [r3]
	mov	r2, #1
	mov	r1, #0
	mov	r0, r3
	bl	sem_init
	str	r0, [fp, #-52]
	ldr	r3, [fp, #-52]
	cmn	r3, #1
	bne	.L11
	ldr	r0, .L22+28
	bl	perror
	mov	r0, #1
	bl	exit
.L11:
	mov	r2, #10
	mov	r1, #0
	ldr	r0, .L22+32
	bl	pthread_barrier_init
	str	r0, [fp, #-52]
	ldr	r3, [fp, #-52]
	cmn	r3, #1
	bne	.L12
	ldr	r0, .L22+36
	bl	perror
	mov	r0, #1
	bl	exit
.L12:
	mov	r3, #0
	str	r3, [fp, #-68]
	b	.L13
.L15:
	sub	r2, fp, #48
	ldr	r3, [fp, #-68]
	lsl	r3, r3, #2
	add	r0, r2, r3
	mov	r3, #0
	ldr	r2, .L22+40
	mov	r1, #0
	bl	pthread_create
	str	r0, [fp, #-52]
	ldr	r3, [fp, #-52]
	cmp	r3, #0
	beq	.L14
	ldr	r0, .L22+44
	bl	perror
	mov	r0, #1
	bl	exit
.L14:
	ldr	r3, [fp, #-68]
	add	r3, r3, #1
	str	r3, [fp, #-68]
.L13:
	ldr	r3, .L22+48
	ldr	r3, [r3]
	ldr	r2, [fp, #-68]
	cmp	r2, r3
	blt	.L15
	mov	r3, #0
	str	r3, [fp, #-64]
	b	.L16
.L18:
	ldr	r3, [fp, #-64]
	lsl	r3, r3, #2
	sub	r2, fp, #4
	add	r3, r2, r3
	ldr	r3, [r3, #-44]
	mov	r1, #0
	mov	r0, r3
	bl	pthread_join
	str	r0, [fp, #-52]
	ldr	r3, [fp, #-52]
	cmp	r3, #0
	beq	.L17
	ldr	r0, .L22+52
	bl	perror
	mov	r0, #1
	bl	exit
.L17:
	ldr	r3, [fp, #-64]
	add	r3, r3, #1
	str	r3, [fp, #-64]
.L16:
	ldr	r3, .L22+48
	ldr	r3, [r3]
	ldr	r2, [fp, #-64]
	cmp	r2, r3
	blt	.L18
	ldr	r0, .L22+32
	bl	pthread_barrier_destroy
	str	r0, [fp, #-52]
	ldr	r3, [fp, #-52]
	cmn	r3, #1
	bne	.L19
	ldr	r0, .L22+56
	bl	perror
	mov	r0, #1
	bl	exit
.L19:
	ldr	r0, .L22+60
	bl	puts
	mov	r3, #0
	ldr	r2, .L22
	ldr	r1, [r2]
	ldr	r2, [fp, #-8]
	eors	r1, r2, r1
	mov	r2, #0
	beq	.L21
	bl	__stack_chk_fail
.L21:
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L23:
	.align	2
.L22:
	.word	.LC15
	.word	.LC5
	.word	577
	.word	.LC6
	.word	.LC7
	.word	.LC8
	.word	process_semaphore
	.word	.LC9
	.word	thread_barrier
	.word	.LC10
	.word	thread_function
	.word	.LC11
	.word	number_of_threads
	.word	.LC12
	.word	.LC13
	.word	.LC14
	.size	main, .-main
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
