#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 */
struct flock {
  int l_len;
  scalar_t__ l_start;
  void *l_whence;
  int /*<<< orphan*/ l_type;
};

/* Variables and functions */
int /*<<< orphan*/ F_GETOWN;
int /*<<< orphan*/ F_SETLK;
int /*<<< orphan*/ F_UNLCK;
int /*<<< orphan*/ F_WRLCK;
int /*<<< orphan*/ O_RDWR;
void *SEEK_SET;
int /*<<< orphan*/ exit(int);
int fcntl(int, int /*<<< orphan*/, struct flock *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int fd;
  struct flock flo;
  if (argc < 1) {
    printf("Is needs a path/file :)");
    exit(1);
  }
  if ((fd = open(argv[1], O_RDWR)) == -1) {
    perror("Open error");
    exit(1);
  }
  flo.l_type = F_WRLCK;
  flo.l_whence = SEEK_SET;
  flo.l_start = 0;
  flo.l_len = 150;
  if (fcntl(fd, F_SETLK, &flo) == -1) {
    perror("File locking error");
    exit(1);
  } else
    printf("File locked \n");
  int own = 0;
  if ((own = fcntl(fd, F_GETOWN, &flo)) != -1) {
    if (own > 0)
      printf("The PID own is %d\n", own);
    else
      printf("The GID own id %d\n", own);
  }
  char _ulk[1];
  printf("You want unloking file start/len byte? S or Any ");
  scanf("%s", _ulk);
  if (strcmp("s", _ulk) != 0) {
    flo.l_type = F_UNLCK;
    flo.l_whence = SEEK_SET;
    flo.l_start = 0;
    flo.l_len = 150;
    if (fcntl(fd, F_SETLK, &flo) == -1) {
      perror("Unloking error");
      exit(1);
    } else
      printf("File bytes unloking with success\n");
  } else
    printf("File still is locked\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    11a8 <main+0x38>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e31(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    11e0 <main+0x70>
lea    0xe47(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2dd1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2dcd(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x96,-0x38(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2dcd(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
jne    123d <main+0xcd>
lea    0xdf5(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2d7c(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1030 <fcntl@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0xffffffff,%eax
je     12a9 <main+0x139>
cmpl   $0x0,-0x3c(%rbp)
jle    1293 <main+0x123>
mov    -0x3c(%rbp),%esi
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12a4 <main+0x134>
mov    -0x3c(%rbp),%esi
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12a9 <main+0x139>
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x3d(%rbp),%rsi
lea    0xdd9(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x3d(%rbp),%rsi
lea    0xdca(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1351 <main+0x1e1>
mov    0x2ce8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2ccc(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x96,-0x38(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2ccc(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
jne    133e <main+0x1ce>
lea    0xd6f(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    135f <main+0x1ef>
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
test   %edi,%edi
jle    12d0 <main+0x150>
mov    0x8(%rsi),%rdi
mov    0x2e4b(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
cmp    $0xffffffff,%eax
je     12e8 <main+0x168>
mov    %eax,%ebp
mov    0x2e02(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
mov    0x2dfd(%rip),%r14
mov    (%r14),%rax
mov    %rax,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movl   $0x96,0x8(%rsp)
mov    0x2dfd(%rip),%r15
mov    (%r15),%esi
lea    0x8(%rsp),%rdx
mov    %ebp,%edi
call   1040 <fcntl@plt>
cmp    $0xffffffff,%eax
je     12f1 <main+0x171>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebp,%edi
call   1040 <fcntl@plt>
cmp    $0xffffffff,%eax
je     123e <main+0xbe>
test   %eax,%eax
lea    0xe0c(%rip),%rcx
lea    0xe18(%rip),%rdi
cmovg  %rcx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe17(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe3a(%rip),%rdi
lea    0x7(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <scanf@plt>
lea    0xe27(%rip),%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12b7 <main+0x137>
mov    0x2d55(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
mov    (%r14),%rax
mov    %rax,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movl   $0x96,0x8(%rsp)
mov    (%r15),%esi
lea    0x8(%rsp),%rdx
mov    %ebp,%edi
call   1040 <fcntl@plt>
cmp    $0xffffffff,%eax
je     12fa <main+0x17a>
lea    0xe0c(%rip),%rdi
jmp    12be <main+0x13e>
lea    0xdee(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd29(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0xd29(%rip),%rdi
jmp    1301 <main+0x181>
lea    0xd2b(%rip),%rdi
jmp    1301 <main+0x181>
lea    0xd8f(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.flock = type { i32, i64, i8*, i32 }
@.str = [24 x i8] c"Is needs a path/file :)\00"
@O_RDWR = global i32 0
@.str.1 = [11 x i8] c"Open error\00"
@F_WRLCK = global i32 0
@SEEK_SET = global i8* null
@F_SETLK = global i32 0
@.str.2 = [19 x i8] c"File locking error\00"
@.str.3 = [14 x i8] c"File locked \0A\00"
@F_GETOWN = global i32 0
@.str.4 = [19 x i8] c"The PID own is %d\0A\00"
@.str.5 = [19 x i8] c"The GID own id %d\0A\00"
@.str.6 = [49 x i8] c"You want unloking file start/len byte? S or Any \00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [2 x i8] c"s\00"
@F_UNLCK = global i32 0
@.str.9 = [15 x i8] c"Unloking error\00"
@.str.10 = [34 x i8] c"File bytes unloking with success\0A\00"
@.str.11 = [22 x i8] c"File still is locked\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.flock
%8 = alloca i32
%9 = alloca [1 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 1
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = load i32, i32* @O_RDWR
%20 = call i32 @open(i8* %18, i32 %19)
store i32 %20, i32* %6
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %15
%26 = load i32, i32* @F_WRLCK
%27 = getelementptr inbounds %struct.flock, %struct.flock* %7, i32 0, i32 3
store i32 %26, i32* %27
%28 = load i8*, i8** @SEEK_SET
%29 = getelementptr inbounds %struct.flock, %struct.flock* %7, i32 0, i32 2
store i8* %28, i8** %29
%30 = getelementptr inbounds %struct.flock, %struct.flock* %7, i32 0, i32 1
store i64 0, i64* %30
%31 = getelementptr inbounds %struct.flock, %struct.flock* %7, i32 0, i32 0
store i32 150, i32* %31
%32 = load i32, i32* %6
%33 = load i32, i32* @F_SETLK
%34 = call i32 @fcntl(i32 %32, i32 %33, %struct.flock* %7)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %39
36: ; preds = %25
%37 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %25
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39
store i32 0, i32* %8
%42 = load i32, i32* %6
%43 = load i32, i32* @F_GETOWN
%44 = call i32 @fcntl(i32 %42, i32 %43, %struct.flock* %7)
store i32 %44, i32* %8
%45 = icmp ne i32 %44, -1
br i1 %45, label %46, label %56
46: ; preds = %41
%47 = load i32, i32* %8
%48 = icmp sgt i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %46
%50 = load i32, i32* %8
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %50)
br label %55
52: ; preds = %46
%53 = load i32, i32* %8
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %52, %49
br label %56
56: ; preds = %55, %41
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
%58 = getelementptr inbounds [1 x i8], [1 x i8]* %9, i64 0, i64 0
%59 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %58)
%60 = getelementptr inbounds [1 x i8], [1 x i8]* %9, i64 0, i64 0
%61 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* %60)
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %80
63: ; preds = %56
%64 = load i32, i32* @F_UNLCK
%65 = getelementptr inbounds %struct.flock, %struct.flock* %7, i32 0, i32 3
store i32 %64, i32* %65
%66 = load i8*, i8** @SEEK_SET
%67 = getelementptr inbounds %struct.flock, %struct.flock* %7, i32 0, i32 2
store i8* %66, i8** %67
%68 = getelementptr inbounds %struct.flock, %struct.flock* %7, i32 0, i32 1
store i64 0, i64* %68
%69 = getelementptr inbounds %struct.flock, %struct.flock* %7, i32 0, i32 0
store i32 150, i32* %69
%70 = load i32, i32* %6
%71 = load i32, i32* @F_SETLK
%72 = call i32 @fcntl(i32 %70, i32 %71, %struct.flock* %7)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %77
74: ; preds = %63
%75 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%76 = call i32 @exit(i32 1)
unreachable
77: ; preds = %63
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0))
br label %79
79: ; preds = %77
br label %82
80: ; preds = %56
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
br label %82
82: ; preds = %80, %79
ret i32 0
}

LLVM IR (-O2):
%struct.flock = type { i32, i64, i8*, i32 }
@.str = [24 x i8] c"Is needs a path/file :)\00"
@O_RDWR = global i32 0
@.str.1 = [11 x i8] c"Open error\00"
@F_WRLCK = global i32 0
@SEEK_SET = global i8* null
@F_SETLK = global i32 0
@.str.2 = [19 x i8] c"File locking error\00"
@F_GETOWN = global i32 0
@.str.4 = [19 x i8] c"The PID own is %d\0A\00"
@.str.5 = [19 x i8] c"The GID own id %d\0A\00"
@.str.6 = [49 x i8] c"You want unloking file start/len byte? S or Any \00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [2 x i8] c"s\00"
@F_UNLCK = global i32 0
@.str.9 = [15 x i8] c"Unloking error\00"
@str = [13 x i8] c"File locked \00"
@str.12 = [21 x i8] c"File still is locked\00"
@str.13 = [33 x i8] c"File bytes unloking with success\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.flock
%4 = alloca [1 x i8]
%5 = bitcast %struct.flock* %3 to i8*
%6 = icmp slt i32 %0, 1
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = load i32, i32* @O_RDWR
%14 = tail call i32 @open(i8* %12, i32 %13)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %10
%20 = load i32, i32* @F_WRLCK
%21 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 3
store i32 %20, i32* %21
%22 = load i8*, i8** @SEEK_SET
%23 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 2
store i8* %22, i8** %23
%24 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 1
store i64 0, i64* %24
%25 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 0
store i32 150, i32* %25
%26 = load i32, i32* @F_SETLK
%27 = call i32 @fcntl(i32 %14, i32 %26, %struct.flock* %3)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %32
29: ; preds = %19
%30 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %19
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%34 = load i32, i32* @F_GETOWN
%35 = call i32 @fcntl(i32 %14, i32 %34, %struct.flock* %3)
%36 = icmp eq i32 %35, -1
br i1 %36, label %41, label %37
37: ; preds = %32
%38 = icmp sgt i32 %35, 0
%39 = select i1 %38, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %39, i32 %35)
br label %41
41: ; preds = %37, %32
%42 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
%44 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %42)
%45 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* %42)
%46 = icmp eq i64 %45, 0
br i1 %46, label %56, label %47
47: ; preds = %41
%48 = load i32, i32* @F_UNLCK
store i32 %48, i32* %21
%49 = load i8*, i8** @SEEK_SET
store i8* %49, i8** %23
store i64 0, i64* %24
store i32 150, i32* %25
%50 = load i32, i32* @F_SETLK
%51 = call i32 @fcntl(i32 %14, i32 %50, %struct.flock* %3)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %56
53: ; preds = %47
%54 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %41, %47
%57 = phi i8* [ getelementptr inbounds ([33 x i8], [33 x i8]* @str.13, i64 0, i64 0), %47 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.12, i64 0, i64 0), %41 ]
%58 = call i32 @puts(i8* dereferenceable(1) %57)
ret i32 0
}