#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int O_CREAT;
int O_EXCL;
int open(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
void lockfileCheck() {
  while (open("lockfile", O_CREAT | O_EXCL, 0) == -1) {
    printf("Serwer zajety, prosze czekac\n");
    sleep(3);
  }
}


x86 assembly (clang, -O0):
<lockfileCheck>:
push   %rbp
mov    %rsp,%rbp
jmp    1139 <lockfileCheck+0x9>
mov    0x2eb8(%rip),%rax
mov    (%rax),%esi
mov    0x2e8f(%rip),%rax
or     (%rax),%esi
lea    0xeae(%rip),%rdi
xor    %edx,%edx
call   1040 <open@plt>
cmp    $0xffffffff,%eax
jne    117d <lockfileCheck+0x4d>
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
mov    $0x3,%edi
call   1050 <sleep@plt>
jmp    1139 <lockfileCheck+0x9>
pop    %rbp
ret

x86 assembly (clang, -O2):
<lockfileCheck>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2eb9(%rip),%r15
mov    0x2e92(%rip),%r12
mov    (%r12),%esi
or     (%r15),%esi
lea    0xeac(%rip),%rdi
xor    %edx,%edx
call   1040 <open@plt>
cmp    $0xffffffff,%eax
jne    1198 <lockfileCheck+0x68>
lea    0xea2(%rip),%r14
lea    0xe92(%rip),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1050 <sleep@plt>
mov    (%r12),%esi
or     (%r15),%esi
mov    %rbx,%rdi
xor    %edx,%edx
call   1040 <open@plt>
cmp    $0xffffffff,%eax
je     1170 <lockfileCheck+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"lockfile\00"
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@.str.1 = [30 x i8] c"Serwer zajety, prosze czekac\0A\00"
define void @lockfileCheck() {
br label %1
1: ; preds = %7, %0
%2 = load i32, i32* @O_CREAT
%3 = load i32, i32* @O_EXCL
%4 = or i32 %2, %3
%5 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %4, i32 0)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @sleep(i32 3)
br label %1
10: ; preds = %1
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"lockfile\00"
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@str = [29 x i8] c"Serwer zajety, prosze czekac\00"
define void @lockfileCheck() {
%1 = load i32, i32* @O_CREAT
%2 = load i32, i32* @O_EXCL
%3 = or i32 %2, %1
%4 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %3, i32 0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %14
6: ; preds = %0, %6
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @sleep(i32 3)
%9 = load i32, i32* @O_CREAT
%10 = load i32, i32* @O_EXCL
%11 = or i32 %10, %9
%12 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %11, i32 0)
%13 = icmp eq i32 %12, -1
br i1 %13, label %6, label %14
14: ; preds = %6, %0
ret void
}