#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 {
  short l_type;
  short l_whence;
  scalar_t__ l_pid;
  void *l_len;
  void *l_start;
};
typedef void *off_t;

/* Variables and functions */
int /*<<< orphan*/ F_SETLK;
int fcntl(int, int /*<<< orphan*/, struct flock *);
int lock_file(int fd, short int type, short int whence, off_t start,
              off_t len) {
  struct flock fl;
  fl.l_type = type;
  fl.l_whence = whence;
  fl.l_start = start;
  fl.l_len = len;
  fl.l_pid = 0;
  return fcntl(fd, F_SETLK, &fl);
}


x86 assembly (clang, -O0):
<lock_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dx,%ax
mov    %si,%dx
mov    %edi,-0x4(%rbp)
mov    %dx,-0x6(%rbp)
mov    %ax,-0x8(%rbp)
mov    %rcx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    -0x6(%rbp),%ax
mov    %ax,-0x38(%rbp)
mov    -0x8(%rbp),%ax
mov    %ax,-0x36(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e85(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1030 <fcntl@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lock_file>:
sub    $0x28,%rsp
mov    %si,0x8(%rsp)
mov    %dx,0xa(%rsp)
mov    %rcx,0x20(%rsp)
mov    %r8,0x18(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2eb0(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
call   1030 <fcntl@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.flock = type { i16, i16, i64, i8*, i8* }
@F_SETLK = global i32 0
define i32 @lock_file(i32 %0, i16 signext %1, i16 signext %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i16
%8 = alloca i16
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca %struct.flock
store i32 %0, i32* %6
store i16 %1, i16* %7
store i16 %2, i16* %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = load i16, i16* %7
%13 = getelementptr inbounds %struct.flock, %struct.flock* %11, i32 0, i32 0
store i16 %12, i16* %13
%14 = load i16, i16* %8
%15 = getelementptr inbounds %struct.flock, %struct.flock* %11, i32 0, i32 1
store i16 %14, i16* %15
%16 = load i8*, i8** %9
%17 = getelementptr inbounds %struct.flock, %struct.flock* %11, i32 0, i32 4
store i8* %16, i8** %17
%18 = load i8*, i8** %10
%19 = getelementptr inbounds %struct.flock, %struct.flock* %11, i32 0, i32 3
store i8* %18, i8** %19
%20 = getelementptr inbounds %struct.flock, %struct.flock* %11, i32 0, i32 2
store i64 0, i64* %20
%21 = load i32, i32* %6
%22 = load i32, i32* @F_SETLK
%23 = call i32 @fcntl(i32 %21, i32 %22, %struct.flock* %11)
ret i32 %23
}

LLVM IR (-O2):
%struct.flock = type { i16, i16, i64, i8*, i8* }
@F_SETLK = global i32 0
define i32 @lock_file(i32 %0, i16 signext %1, i16 signext %2, i8* %3, i8* %4) {
%6 = alloca %struct.flock
%7 = bitcast %struct.flock* %6 to i8*
%8 = getelementptr inbounds %struct.flock, %struct.flock* %6, i64 0, i32 0
store i16 %1, i16* %8
%9 = getelementptr inbounds %struct.flock, %struct.flock* %6, i64 0, i32 1
store i16 %2, i16* %9
%10 = getelementptr inbounds %struct.flock, %struct.flock* %6, i64 0, i32 4
store i8* %3, i8** %10
%11 = getelementptr inbounds %struct.flock, %struct.flock* %6, i64 0, i32 3
store i8* %4, i8** %11
%12 = getelementptr inbounds %struct.flock, %struct.flock* %6, i64 0, i32 2
store i64 0, i64* %12
%13 = load i32, i32* @F_SETLK
%14 = call i32 @fcntl(i32 %0, i32 %13, %struct.flock* %6)
ret i32 %14
}