// File: /workspace/github_c_makefile_star2_O2/cirocosta[P]stress/src/locks-fcntl.c
// Function: create_file
void
create_file(const char* base, const int i)
{
	FILE* fp;
	char* filename;
	struct flock lock = { 0 };

	lock.l_type = F_WRLCK;

	_STRESS_MUST(asprintf(&filename, "%s/file%d", base, i) > 0,
	             "Couldn't create name for file %d",
	             i);
	_STRESS_MUST(
	  (fp = fopen(filename, "a")), "Couldn't create file %s", filename);

	_STRESS_MUST_P(fcntl(fileno(fp), F_SETLKW, &lock) != -1,
	               "fcntl",
	               "Couldn't acquire lock on %s",
	               filename);

	fprintf(fp, "dummy");
	free(filename);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movl %esi, %ebp
movq %rdi, %rdx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, 0x20(%rsp)
movw $0x1, 0x10(%rsp)
leaq 0x9e3(%rip), %rsi       # 0x210d
leaq 0x8(%rsp), %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x1150
testl %eax, %eax
jle 0x17a7
movq 0x8(%rsp), %rdi
leaq 0xa02(%rip), %rsi       # 0x214a
callq 0x1160
testq %rax, %rax
je 0x182c
movq %rax, %rbx
movq %rax, %rdi
callq 0x1140
pushq $0x7
popq %rsi
leaq 0x10(%rsp), %rdx
movl %eax, %edi
xorl %eax, %eax
callq 0x1090
cmpl $-0x1, %eax
je 0x18ca
leaq 0xa15(%rip), %rdi       # 0x2197
pushq $0x5
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x11b0
movq 0x8(%rsp), %rdi
callq 0x1030
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x284a(%rip), %r14      # 0x3ff8
movq (%r14), %rcx
leaq 0x9cf(%rip), %rdi       # 0x2187
pushq $0x9
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x11b0
movq (%r14), %rcx
leaq 0x9bd(%rip), %rdi       # 0x218d
pushq $0x3
popq %rsi
movq %rbx, %rdx
callq 0x11b0
movq (%r14), %rdi
leaq 0x932(%rip), %rsi       # 0x2117
movl %ebp, %edx
xorl %eax, %eax
callq 0x1120
movq (%r14), %rcx
leaq 0x85a(%rip), %rdi       # 0x2052
pushq $0x2
popq %rsi
movq %rbx, %rdx
callq 0x11b0
movq (%r14), %rdi
leaq 0x848(%rip), %rsi       # 0x2055
leaq 0x924(%rip), %rdx       # 0x2138
xorl %eax, %eax
callq 0x1120
movq (%r14), %rdi
leaq 0x84c(%rip), %rsi       # 0x2071
pushq $0x21
jmp 0x18af
movq 0x27c5(%rip), %r14      # 0x3ff8
movq (%r14), %rcx
leaq 0x94a(%rip), %rdi       # 0x2187
pushq $0x9
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x11b0
movq (%r14), %rcx
leaq 0x938(%rip), %rdi       # 0x218d
pushq $0x3
popq %rsi
movq %rbx, %rdx
callq 0x11b0
movq (%r14), %rdi
movq 0x8(%rsp), %rdx
leaq 0x8dd(%rip), %rsi       # 0x214c
xorl %eax, %eax
callq 0x1120
movq (%r14), %rcx
leaq 0x7d2(%rip), %rdi       # 0x2052
pushq $0x2
popq %rsi
movq %rbx, %rdx
callq 0x11b0
movq (%r14), %rdi
leaq 0x7c0(%rip), %rsi       # 0x2055
leaq 0x89c(%rip), %rdx       # 0x2138
xorl %eax, %eax
callq 0x1120
movq (%r14), %rdi
leaq 0x7c4(%rip), %rsi       # 0x2071
pushq $0x23
popq %rdx
xorl %eax, %eax
callq 0x1120
movq (%r14), %rsi
pushq $0xa
popq %rdi
callq 0x1100
movq (%r14), %rcx
jmp 0x19a6
movq 0x2727(%rip), %r12      # 0x3ff8
movq (%r12), %rcx
leaq 0x8ab(%rip), %rdi       # 0x2187
pushq $0x9
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x11b0
movq (%r12), %rcx
leaq 0x898(%rip), %r14       # 0x218d
pushq $0x3
popq %r15
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x11b0
movq (%r12), %rdi
movq 0x8(%rsp), %rdx
leaq 0x84d(%rip), %rsi       # 0x2164
xorl %eax, %eax
callq 0x1120
movq (%r12), %rcx
leaq 0x729(%rip), %rdi       # 0x2052
pushq $0x2
popq %rsi
movq %rbx, %rdx
callq 0x11b0
movq (%r12), %rdi
leaq 0x716(%rip), %rsi       # 0x2055
leaq 0x7f2(%rip), %rdx       # 0x2138
xorl %eax, %eax
callq 0x1120
movq (%r12), %rdi
leaq 0x719(%rip), %rsi       # 0x2071
pushq $0x28
popq %rdx
xorl %eax, %eax
callq 0x1120
movq (%r12), %rsi
pushq $0xa
popq %rdi
callq 0x1100
movq (%r12), %rcx
leaq 0x807(%rip), %rdi       # 0x2180
pushq $0x10
popq %rsi
movq %rbx, %rdx
callq 0x11b0
leaq 0x806(%rip), %rdi       # 0x2191
callq 0x1170
movq (%r12), %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x11b0
movq (%r12), %rcx
leaq 0x6d1(%rip), %rdi       # 0x207e
pushq $0xa
popq %rsi
movq %rbx, %rdx
callq 0x11b0
pushq $0x1
popq %rdi
callq 0x11a0