// File: /workspace/github_c_makefile_star2_O0/jacereda[P]fsatrace/src/unix/shm.c
// Function: shmInit
int
shmInit(struct shm *shm, const char *key, size_t sz, int root)
{
	int	     err = 0;
	struct priv *p = (struct priv *)shm->storage;
	char *	     shname = shm->name;
	assert(key);
	assert(sizeof(shm->storage) > sizeof(*p));
	snprintf(shname, sizeof(shm->storage), "/fsatrace%ld",
	    hash((unsigned char *)key));
	for (size_t i = 0, l = strlen(shname); i < l; i++)
		if (shname[i] == '/')
			shname[i] = '_';
	if (root)
		shm_unlink(shname); // Just in case, it might have crashed on a
				    // previous execution
	err +=
	    (-1 == (p->fd = shm_open(shname, (root * O_CREAT) | O_RDWR, 0666)))
	    << 0;
	err += (root && (-1 == ftruncate(p->fd, sz))) << 1;
	err += (MAP_FAILED ==
		   (shm->buf = mmap(
			0, sz, PROT_READ | PROT_WRITE, MAP_SHARED, p->fd, 0)))
	    << 2;
	p->sz = sz;
	return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rax
addq $0x1008, %rax           # imm = 0x1008
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1e61
jmp 0x1e80
leaq 0x1482(%rip), %rdi      # 0x32ea
leaq 0x147f(%rip), %rsi      # 0x32ee
movl $0x22, %edx
leaq 0x1482(%rip), %rcx      # 0x32fd
callq 0x1100
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1fe0
movq -0x48(%rbp), %rdi
movq %rax, %rcx
movl $0x20, %esi
leaq 0x148e(%rip), %rdx      # 0x3332
movb $0x0, %al
callq 0x10e0
movq $0x0, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x10b0
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x1ef7
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0x1ee7
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movb $0x5f, (%rax,%rcx)
jmp 0x1ee9
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1ec0
cmpl $0x0, -0x1c(%rbp)
je 0x1f06
movq -0x30(%rbp), %rdi
callq 0x1200
movq -0x30(%rbp), %rdi
movl -0x1c(%rbp), %esi
shll $0x6, %esi
orl $0x2, %esi
movl $0x1b6, %edx            # imm = 0x1B6
callq 0x11e0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
shll $0x0, %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x49(%rbp)
je 0x1f66
movq -0x28(%rbp), %rax
movl (%rax), %edi
movq -0x18(%rbp), %rsi
callq 0x10f0
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
sete %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
shll %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rax
movl (%rax), %r8d
xorl %eax, %eax
movl %eax, %r9d
movl $0x3, %edx
movl $0x1, %ecx
movq %r9, %rdi
callq 0x10c0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq $-0x1, %rax
cmpq %rcx, %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
shll $0x2, %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x20(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)