// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/classes/threads/backends/posix/semaphoreposix.cpp
// Function: smooth::Threads::SemaphorePOSIX::SemaphorePOSIX(int, void*)
S::Threads::SemaphorePOSIX::SemaphorePOSIX(Int iValue, Void *iSemaphore) : SemaphoreBackend(iValue)
{
	type = SEMAPHORE_POSIX;

	if (iSemaphore != NIL)
	{
		SemaphorePOSIX	*oSemaphore = (SemaphorePOSIX *) iSemaphore;

		mutex	    = oSemaphore->mutex;
		condition   = oSemaphore->condition;

		count	    = oSemaphore->count;
		max	    = oSemaphore->max;

		mySemaphore = False;
	}
	else
	{
		mutex	    = new pthread_mutex_t;
		condition   = new pthread_cond_t;

		count	    = iValue;
		max	    = iValue;

		mySemaphore = True;

		if (pthread_mutex_init(mutex, NIL) != 0)
		{
			delete mutex;
			delete condition;

			mutex	  = NIL;
			condition = NIL;
		}
		else if (pthread_cond_init(condition, NIL) != 0)
		{
			pthread_mutex_destroy(mutex);

			delete mutex;
			delete condition;

			mutex	  = NIL;
			condition = NIL;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x38(%rbp)
movl -0xc(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x10daa0
movq -0x38(%rbp), %rax
leaq 0xd62b6(%rip), %rcx     # 0x206f58
addq $0x10, %rcx
movq %rcx, (%rax)
movw $0x1, 0x8(%rax)
cmpq $0x0, -0x18(%rbp)
je 0x130cf7
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rcx
movl 0x20(%rcx), %ecx
movl %ecx, 0x20(%rax)
movq -0x20(%rbp), %rcx
movl 0x24(%rcx), %ecx
movl %ecx, 0x24(%rax)
movb $0x0, 0x28(%rax)
jmp 0x130e3f
movl $0x28, %edi
callq 0x59820
movq %rax, -0x40(%rbp)
jmp 0x130d07
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl $0x30, %edi
callq 0x59820
movq %rax, -0x48(%rbp)
jmp 0x130d23
movq -0x38(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, 0x18(%rax)
movl -0xc(%rbp), %ecx
movl %ecx, 0x20(%rax)
movl -0xc(%rbp), %ecx
movl %ecx, 0x24(%rax)
movb $0x1, 0x28(%rax)
movq 0x10(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5a680
cmpl $0x0, %eax
je 0x130dc4
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x130d71
movq -0x50(%rbp), %rdi
movl $0x28, %esi
callq 0x595b0
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
je 0x130d91
movq -0x58(%rbp), %rdi
movl $0x30, %esi
callq 0x595b0
movq -0x38(%rbp), %rax
movq $0x0, 0x10(%rax)
movq $0x0, 0x18(%rax)
jmp 0x130e3d
movq -0x38(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x10dad0
jmp 0x130e45
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5a8b0
cmpl $0x0, %eax
je 0x130e3b
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x595d0
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x130e07
movq -0x60(%rbp), %rdi
movl $0x28, %esi
callq 0x595b0
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, %rax
je 0x130e27
movq -0x68(%rbp), %rdi
movl $0x30, %esi
callq 0x595b0
movq -0x38(%rbp), %rax
movq $0x0, 0x10(%rax)
movq $0x0, 0x18(%rax)
jmp 0x130e3d
jmp 0x130e3f
addq $0x70, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x5b6b0
nop