#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_type;
  int l_whence;
  void *l_len;
  void *l_start;
};
typedef void *off_t;

/* Variables and functions */
int fcntl(int, int, struct flock *);
int misc_lockreg(int fd, int cmd, int type, off_t offset, int whence,
                 off_t len) {
  struct flock lock;
  lock.l_type = type;
  lock.l_start = offset;
  lock.l_whence = whence;
  lock.l_len = len;
  return fcntl(fd, cmd, &lock);
}


x86 assembly (clang, -O0):
<misc_lockreg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0x40(%rbp),%rdx
call   1030 <fcntl@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<misc_lockreg>:
sub    $0x18,%rsp
mov    %edx,(%rsp)
mov    %rcx,0x10(%rsp)
mov    %r8d,0x4(%rsp)
mov    %r9,0x8(%rsp)
mov    %rsp,%rdx
call   1030 <fcntl@plt>
add    $0x18,%rsp
ret

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

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