#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;
  int /*<<< orphan*/ l_whence;
  int /*<<< orphan*/ l_type;
};

/* Variables and functions */
int /*<<< orphan*/ F_SETLK;
int /*<<< orphan*/ F_WRLCK;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ 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 main(int argc, char *argv[]) {
  int fc;
  struct flock flo;
  if (argc < 1) {
    printf("We needs of a file path :)");
    exit(1);
  }
  if ((fc = 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(fc, F_SETLK, &flo) == -1) {
    perror("Found error");
    exit(1);
  } else
    printf("Loking file from %d to %d with success \n", (int)flo.l_start,
           (int)flo.l_len);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    1188 <main+0x38>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e51(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    11c0 <main+0x70>
lea    0xe6a(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2dfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x96,-0x30(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2def(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
jne    121b <main+0xcb>
lea    0xe1a(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x28(%rbp),%rax
mov    %eax,%esi
mov    -0x30(%rbp),%edx
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
test   %edi,%edi
jle    11cd <main+0x7d>
mov    0x8(%rsi),%rdi
mov    0x2e85(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
cmp    $0xffffffff,%eax
je     11e5 <main+0x95>
mov    0x2e52(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x14(%rsp)
mov    0x2e4d(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x10(%rsp)
movq   $0x0,0x8(%rsp)
movl   $0x96,(%rsp)
mov    0x2e40(%rip),%rcx
mov    (%rcx),%esi
mov    %rsp,%rdx
mov    %eax,%edi
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
je     11ee <main+0x9e>
mov    (%rsp),%edx
mov    0x8(%rsp),%esi
lea    0xe73(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
lea    0xe2c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe2f(%rip),%rdi
jmp    11f5 <main+0xa5>
lea    0xe31(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.flock = type { i32, i64, i32, i32 }
@.str = [27 x i8] c"We needs of a file path :)\00"
@O_RDWR = global i32 0
@.str.1 = [11 x i8] c"Open error\00"
@F_WRLCK = global i32 0
@SEEK_SET = global i32 0
@F_SETLK = global i32 0
@.str.2 = [12 x i8] c"Found error\00"
@.str.3 = [41 x i8] c"Loking file from %d to %d with success \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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = load i32, i32* @O_RDWR
%18 = call i32 @open(i8* %16, i32 %17)
store i32 %18, i32* %6
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %13
%24 = load i32, i32* @F_WRLCK
%25 = getelementptr inbounds %struct.flock, %struct.flock* %7, i32 0, i32 3
store i32 %24, i32* %25
%26 = load i32, i32* @SEEK_SET
%27 = getelementptr inbounds %struct.flock, %struct.flock* %7, i32 0, i32 2
store i32 %26, i32* %27
%28 = getelementptr inbounds %struct.flock, %struct.flock* %7, i32 0, i32 1
store i64 0, i64* %28
%29 = getelementptr inbounds %struct.flock, %struct.flock* %7, i32 0, i32 0
store i32 150, i32* %29
%30 = load i32, i32* %6
%31 = load i32, i32* @F_SETLK
%32 = call i32 @fcntl(i32 %30, i32 %31, %struct.flock* %7)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %37
34: ; preds = %23
%35 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %23
%38 = getelementptr inbounds %struct.flock, %struct.flock* %7, i32 0, i32 1
%39 = load i64, i64* %38
%40 = trunc i64 %39 to i32
%41 = getelementptr inbounds %struct.flock, %struct.flock* %7, i32 0, i32 0
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %40, i32 %42)
br label %44
44: ; preds = %37
ret i32 0
}

LLVM IR (-O2):
%struct.flock = type { i32, i64, i32, i32 }
@.str = [27 x i8] c"We needs of a file path :)\00"
@O_RDWR = global i32 0
@.str.1 = [11 x i8] c"Open error\00"
@F_WRLCK = global i32 0
@SEEK_SET = global i32 0
@F_SETLK = global i32 0
@.str.2 = [12 x i8] c"Found error\00"
@.str.3 = [41 x i8] c"Loking file from %d to %d with success \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.flock
%4 = bitcast %struct.flock* %3 to i8*
%5 = icmp slt i32 %0, 1
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = load i32, i32* @O_RDWR
%13 = tail call i32 @open(i8* %11, i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %9
%19 = load i32, i32* @F_WRLCK
%20 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 3
store i32 %19, i32* %20
%21 = load i32, i32* @SEEK_SET
%22 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 2
store i32 %21, i32* %22
%23 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 1
store i64 0, i64* %23
%24 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 0
store i32 150, i32* %24
%25 = load i32, i32* @F_SETLK
%26 = call i32 @fcntl(i32 %13, i32 %25, %struct.flock* %3)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %31
28: ; preds = %18
%29 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %18
%32 = load i64, i64* %23
%33 = trunc i64 %32 to i32
%34 = load i32, i32* %24
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %33, i32 %34)
ret i32 0
}