#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;
  int l_start;
  int l_len;
};

/* Variables and functions */
int fcntl(int, int, struct flock *);
int fcntl_lock(int fd, int cmd, int type, int whence, int start, int len) {
  struct flock lock[1];
  lock->l_type = type;
  lock->l_whence = whence;
  lock->l_start = start;
  lock->l_len = len;
  return fcntl(fd, cmd, lock);
}


x86 assembly (clang, -O0):
<fcntl_lock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0x30(%rbp),%rdx
call   1030 <fcntl@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fcntl_lock>:
sub    $0x18,%rsp
mov    %edx,(%rsp)
mov    %ecx,0x4(%rsp)
mov    %r8d,0x8(%rsp)
mov    %r9d,0xc(%rsp)
mov    %rsp,%rdx
call   1030 <fcntl@plt>
add    $0x18,%rsp
ret

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

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