	.file	"311455.c"
	.intel_syntax noprefix
	.text
	.globl	process_semaphore
	.bss
	.align 8
	.type	process_semaphore, @object
	.size	process_semaphore, 8
process_semaphore:
	.zero	8
	.globl	shared_counter
	.align 4
	.type	shared_counter, @object
	.size	shared_counter, 4
shared_counter:
	.zero	4
	.section	.rodata
.LC0:
	.string	"sem_wait"
.LC1:
	.string	"sem_post"
	.text
	.globl	thread_function_1
	.type	thread_function_1, @function
thread_function_1:
.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, 32
	mov	QWORD PTR -24[rbp], rdi
	mov	DWORD PTR -4[rbp], 0
	jmp	.L2
.L5:
	mov	rax, QWORD PTR process_semaphore[rip]
	mov	rdi, rax
	call	sem_wait@PLT
	cmp	eax, -1
	jne	.L3
	lea	rdi, .LC0[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L3:
	mov	eax, DWORD PTR shared_counter[rip]
	add	eax, 1
	mov	DWORD PTR shared_counter[rip], eax
	mov	rax, QWORD PTR process_semaphore[rip]
	mov	rdi, rax
	call	sem_post@PLT
	cmp	eax, -1
	jne	.L4
	lea	rdi, .LC1[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L4:
	add	DWORD PTR -4[rbp], 1
.L2:
	cmp	DWORD PTR -4[rbp], 9999999
	jle	.L5
	mov	eax, 0
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	thread_function_1, .-thread_function_1
	.globl	thread_function_2
	.type	thread_function_2, @function
thread_function_2:
.LFB7:
	.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	DWORD PTR -4[rbp], 0
	jmp	.L8
.L11:
	mov	rax, QWORD PTR process_semaphore[rip]
	mov	rdi, rax
	call	sem_wait@PLT
	cmp	eax, -1
	jne	.L9
	lea	rdi, .LC0[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L9:
	mov	eax, DWORD PTR shared_counter[rip]
	sub	eax, 1
	mov	DWORD PTR shared_counter[rip], eax
	mov	rax, QWORD PTR process_semaphore[rip]
	mov	rdi, rax
	call	sem_post@PLT
	cmp	eax, -1
	jne	.L10
	lea	rdi, .LC1[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L10:
	add	DWORD PTR -4[rbp], 1
.L8:
	cmp	DWORD PTR -4[rbp], 9999999
	jle	.L11
	mov	eax, 0
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	thread_function_2, .-thread_function_2
	.section	.rodata
	.align 8
.LC2:
	.string	"initial value of shared_counter=%d, NUMBER_OF_CYCLES=%d\n"
.LC3:
	.string	"sem_init"
.LC4:
	.string	"pthread_create"
.LC5:
	.string	"pthread_join"
	.align 8
.LC6:
	.string	"final value of shared_counter=%d\n"
	.align 8
.LC7:
	.string	"clock_gettime(CLOCK_PROCESS_CPUTIME_ID): dt = %ld ns\n"
	.align 8
.LC8:
	.string	"dt/NUMBER_OF_CYCLES/2 = %ld ns\n"
.LC9:
	.string	"sem_destroy"
.LC10:
	.string	"bye"
	.text
	.globl	main
	.type	main, @function
main:
.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, 112
	mov	DWORD PTR -100[rbp], edi
	mov	QWORD PTR -112[rbp], rsi
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR -8[rbp], rax
	xor	eax, eax
	mov	eax, DWORD PTR shared_counter[rip]
	mov	edx, 10000000
	mov	esi, eax
	lea	rdi, .LC2[rip]
	mov	eax, 0
	call	printf@PLT
	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 -84[rbp], eax
	cmp	DWORD PTR -84[rbp], -1
	jne	.L14
	lea	rdi, .LC3[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L14:
	lea	rax, -48[rbp]
	mov	rsi, rax
	mov	edi, 2
	call	clock_gettime@PLT
	lea	rax, -80[rbp]
	mov	ecx, 0
	lea	rdx, thread_function_1[rip]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_create@PLT
	mov	DWORD PTR -84[rbp], eax
	cmp	DWORD PTR -84[rbp], 0
	je	.L15
	lea	rdi, .LC4[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L15:
	lea	rax, -72[rbp]
	mov	ecx, 0
	lea	rdx, thread_function_2[rip]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_create@PLT
	mov	DWORD PTR -84[rbp], eax
	cmp	DWORD PTR -84[rbp], 0
	je	.L16
	lea	rdi, .LC4[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L16:
	mov	rax, QWORD PTR -80[rbp]
	lea	rdx, -64[rbp]
	mov	rsi, rdx
	mov	rdi, rax
	call	pthread_join@PLT
	mov	DWORD PTR -84[rbp], eax
	cmp	DWORD PTR -84[rbp], 0
	je	.L17
	lea	rdi, .LC5[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L17:
	mov	rax, QWORD PTR -72[rbp]
	lea	rdx, -64[rbp]
	mov	rsi, rdx
	mov	rdi, rax
	call	pthread_join@PLT
	mov	DWORD PTR -84[rbp], eax
	cmp	DWORD PTR -84[rbp], 0
	je	.L18
	lea	rdi, .LC5[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L18:
	lea	rax, -32[rbp]
	mov	rsi, rax
	mov	edi, 2
	call	clock_gettime@PLT
	mov	eax, DWORD PTR shared_counter[rip]
	mov	esi, eax
	lea	rdi, .LC6[rip]
	mov	eax, 0
	call	printf@PLT
	mov	rax, QWORD PTR -32[rbp]
	mov	rdx, QWORD PTR -48[rbp]
	sub	rax, rdx
	imul	rdx, rax, 1000000000
	mov	rax, QWORD PTR -24[rbp]
	add	rax, rdx
	mov	rdx, QWORD PTR -40[rbp]
	sub	rax, rdx
	mov	QWORD PTR -56[rbp], rax
	mov	rax, QWORD PTR -56[rbp]
	mov	rsi, rax
	lea	rdi, .LC7[rip]
	mov	eax, 0
	call	printf@PLT
	mov	rcx, QWORD PTR -56[rbp]
	movabs	rdx, -2972493582642298179
	mov	rax, rcx
	imul	rdx
	lea	rax, [rdx+rcx]
	sar	rax, 24
	sar	rcx, 63
	mov	rdx, rcx
	sub	rax, rdx
	mov	rsi, rax
	lea	rdi, .LC8[rip]
	mov	eax, 0
	call	printf@PLT
	mov	rax, QWORD PTR process_semaphore[rip]
	mov	rdi, rax
	call	sem_destroy@PLT
	mov	DWORD PTR -84[rbp], eax
	cmp	DWORD PTR -84[rbp], -1
	jne	.L19
	lea	rdi, .LC9[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L19:
	lea	rdi, .LC10[rip]
	call	puts@PLT
	mov	eax, 0
	mov	rcx, QWORD PTR -8[rbp]
	sub	rcx, QWORD PTR fs:40
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	main, .-main
	.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	"311455.c"
	.text
	.comm	process_semaphore,4,4
	.comm	shared_counter,4,4
	.section	.rodata
	.align	2
.LC0:
	.ascii	"sem_wait\000"
	.align	2
.LC1:
	.ascii	"sem_post\000"
	.text
	.align	2
	.global	thread_function_1
	.syntax unified
	.arm
	.fpu softvfp
	.type	thread_function_1, %function
thread_function_1:
	@ 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]
	mov	r3, #0
	str	r3, [fp, #-8]
	b	.L2
.L5:
	ldr	r3, .L7
	ldr	r3, [r3]
	mov	r0, r3
	bl	sem_wait
	mov	r3, r0
	cmn	r3, #1
	bne	.L3
	ldr	r0, .L7+4
	bl	perror
	mov	r0, #1
	bl	exit
.L3:
	ldr	r3, .L7+8
	ldr	r3, [r3]
	add	r3, r3, #1
	ldr	r2, .L7+8
	str	r3, [r2]
	ldr	r3, .L7
	ldr	r3, [r3]
	mov	r0, r3
	bl	sem_post
	mov	r3, r0
	cmn	r3, #1
	bne	.L4
	ldr	r0, .L7+12
	bl	perror
	mov	r0, #1
	bl	exit
.L4:
	ldr	r3, [fp, #-8]
	add	r3, r3, #1
	str	r3, [fp, #-8]
.L2:
	ldr	r3, [fp, #-8]
	ldr	r2, .L7+16
	cmp	r3, r2
	ble	.L5
	mov	r3, #0
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L8:
	.align	2
.L7:
	.word	process_semaphore
	.word	.LC0
	.word	shared_counter
	.word	.LC1
	.word	9999999
	.size	thread_function_1, .-thread_function_1
	.align	2
	.global	thread_function_2
	.syntax unified
	.arm
	.fpu softvfp
	.type	thread_function_2, %function
thread_function_2:
	@ 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]
	mov	r3, #0
	str	r3, [fp, #-8]
	b	.L10
.L13:
	ldr	r3, .L15
	ldr	r3, [r3]
	mov	r0, r3
	bl	sem_wait
	mov	r3, r0
	cmn	r3, #1
	bne	.L11
	ldr	r0, .L15+4
	bl	perror
	mov	r0, #1
	bl	exit
.L11:
	ldr	r3, .L15+8
	ldr	r3, [r3]
	sub	r3, r3, #1
	ldr	r2, .L15+8
	str	r3, [r2]
	ldr	r3, .L15
	ldr	r3, [r3]
	mov	r0, r3
	bl	sem_post
	mov	r3, r0
	cmn	r3, #1
	bne	.L12
	ldr	r0, .L15+12
	bl	perror
	mov	r0, #1
	bl	exit
.L12:
	ldr	r3, [fp, #-8]
	add	r3, r3, #1
	str	r3, [fp, #-8]
.L10:
	ldr	r3, [fp, #-8]
	ldr	r2, .L15+16
	cmp	r3, r2
	ble	.L13
	mov	r3, #0
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L16:
	.align	2
.L15:
	.word	process_semaphore
	.word	.LC0
	.word	shared_counter
	.word	.LC1
	.word	9999999
	.size	thread_function_2, .-thread_function_2
	.section	.rodata
	.align	2
.LC2:
	.ascii	"initial value of shared_counter=%d, NUMBER_OF_CYCLE"
	.ascii	"S=%d\012\000"
	.align	2
.LC3:
	.ascii	"sem_init\000"
	.align	2
.LC4:
	.ascii	"pthread_create\000"
	.align	2
.LC5:
	.ascii	"pthread_join\000"
	.align	2
.LC6:
	.ascii	"final value of shared_counter=%d\012\000"
	.align	2
.LC7:
	.ascii	"clock_gettime(CLOCK_PROCESS_CPUTIME_ID): dt = %ld n"
	.ascii	"s\012\000"
	.align	2
.LC8:
	.ascii	"dt/NUMBER_OF_CYCLES/2 = %ld ns\012\000"
	.align	2
.LC9:
	.ascii	"sem_destroy\000"
	.align	2
.LC10:
	.ascii	"bye\000"
	.align	2
.LC11:
	.word	__stack_chk_guard
	.text
	.align	2
	.global	main
	.syntax unified
	.arm
	.fpu softvfp
	.type	main, %function
main:
	@ args = 0, pretend = 0, frame = 48
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #48
	str	r0, [fp, #-48]
	str	r1, [fp, #-52]
	ldr	r3, .L26
	ldr	r3, [r3]
	str	r3, [fp, #-8]
	mov	r3,#0
	ldr	r3, .L26+4
	ldr	r3, [r3]
	ldr	r2, .L26+8
	mov	r1, r3
	ldr	r0, .L26+12
	bl	printf
	mov	r0, #16
	bl	malloc
	mov	r3, r0
	mov	r2, r3
	ldr	r3, .L26+16
	str	r2, [r3]
	ldr	r3, .L26+16
	ldr	r3, [r3]
	mov	r2, #1
	mov	r1, #0
	mov	r0, r3
	bl	sem_init
	str	r0, [fp, #-32]
	ldr	r3, [fp, #-32]
	cmn	r3, #1
	bne	.L18
	ldr	r0, .L26+20
	bl	perror
	mov	r0, #1
	bl	exit
.L18:
	sub	r3, fp, #24
	mov	r1, r3
	mov	r0, #2
	bl	clock_gettime
	sub	r0, fp, #44
	mov	r3, #0
	ldr	r2, .L26+24
	mov	r1, #0
	bl	pthread_create
	str	r0, [fp, #-32]
	ldr	r3, [fp, #-32]
	cmp	r3, #0
	beq	.L19
	ldr	r0, .L26+28
	bl	perror
	mov	r0, #1
	bl	exit
.L19:
	sub	r0, fp, #40
	mov	r3, #0
	ldr	r2, .L26+32
	mov	r1, #0
	bl	pthread_create
	str	r0, [fp, #-32]
	ldr	r3, [fp, #-32]
	cmp	r3, #0
	beq	.L20
	ldr	r0, .L26+28
	bl	perror
	mov	r0, #1
	bl	exit
.L20:
	ldr	r3, [fp, #-44]
	sub	r2, fp, #36
	mov	r1, r2
	mov	r0, r3
	bl	pthread_join
	str	r0, [fp, #-32]
	ldr	r3, [fp, #-32]
	cmp	r3, #0
	beq	.L21
	ldr	r0, .L26+36
	bl	perror
	mov	r0, #1
	bl	exit
.L21:
	ldr	r3, [fp, #-40]
	sub	r2, fp, #36
	mov	r1, r2
	mov	r0, r3
	bl	pthread_join
	str	r0, [fp, #-32]
	ldr	r3, [fp, #-32]
	cmp	r3, #0
	beq	.L22
	ldr	r0, .L26+36
	bl	perror
	mov	r0, #1
	bl	exit
.L22:
	sub	r3, fp, #16
	mov	r1, r3
	mov	r0, #2
	bl	clock_gettime
	ldr	r3, .L26+4
	ldr	r3, [r3]
	mov	r1, r3
	ldr	r0, .L26+40
	bl	printf
	ldr	r2, [fp, #-16]
	ldr	r3, [fp, #-24]
	sub	r3, r2, r3
	ldr	r2, .L26+44
	mul	r2, r3, r2
	ldr	r3, [fp, #-12]
	add	r2, r2, r3
	ldr	r3, [fp, #-20]
	sub	r3, r2, r3
	str	r3, [fp, #-28]
	ldr	r1, [fp, #-28]
	ldr	r0, .L26+48
	bl	printf
	ldr	r3, [fp, #-28]
	ldr	r2, .L26+52
	smull	r1, r2, r3, r2
	asr	r2, r2, #23
	asr	r3, r3, #31
	sub	r3, r2, r3
	mov	r1, r3
	ldr	r0, .L26+56
	bl	printf
	ldr	r3, .L26+16
	ldr	r3, [r3]
	mov	r0, r3
	bl	sem_destroy
	str	r0, [fp, #-32]
	ldr	r3, [fp, #-32]
	cmn	r3, #1
	bne	.L23
	ldr	r0, .L26+60
	bl	perror
	mov	r0, #1
	bl	exit
.L23:
	ldr	r0, .L26+64
	bl	puts
	mov	r3, #0
	ldr	r2, .L26
	ldr	r1, [r2]
	ldr	r2, [fp, #-8]
	eors	r1, r2, r1
	mov	r2, #0
	beq	.L25
	bl	__stack_chk_fail
.L25:
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L27:
	.align	2
.L26:
	.word	.LC11
	.word	shared_counter
	.word	10000000
	.word	.LC2
	.word	process_semaphore
	.word	.LC3
	.word	thread_function_1
	.word	.LC4
	.word	thread_function_2
	.word	.LC5
	.word	.LC6
	.word	1000000000
	.word	.LC7
	.word	1801439851
	.word	.LC8
	.word	.LC9
	.word	.LC10
	.size	main, .-main
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
