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

/* Variables and functions */
int /*<<< orphan*/ F_RDLCK;
int /*<<< orphan*/ F_SETLK;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fcntl(int, int /*<<< orphan*/, struct flock *);
int /*<<< orphan*/ getpid();
void pipe_setup_for_binary(int fd) {
  struct flock fl;
  fl.l_type = F_RDLCK;
  fl.l_whence = SEEK_SET;
  fl.l_start = 0x25458dea;
  fl.l_len = 0;
  fl.l_pid = getpid();
  fcntl(fd, F_SETLK, &fl);
}


x86 assembly (clang, -O0):
<pipe_setup_for_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
movl   $0x25458dea,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e82(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1030 <fcntl@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pipe_setup_for_binary>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
mov    0x2e9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
movl   $0x25458dea,0x8(%rsp)
25
movq   $0x0,0x10(%rsp)
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %eax,0xc(%rsp)
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1030 <fcntl@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.flock = type { i32, i32, i64, i32, i32 }
@F_RDLCK = global i32 0
@SEEK_SET = global i32 0
@F_SETLK = global i32 0
define void @pipe_setup_for_binary(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.flock
store i32 %0, i32* %2
%4 = load i32, i32* @F_RDLCK
%5 = getelementptr inbounds %struct.flock, %struct.flock* %3, i32 0, i32 4
store i32 %4, i32* %5
%6 = load i32, i32* @SEEK_SET
%7 = getelementptr inbounds %struct.flock, %struct.flock* %3, i32 0, i32 3
store i32 %6, i32* %7
%8 = getelementptr inbounds %struct.flock, %struct.flock* %3, i32 0, i32 0
store i32 625315306, i32* %8
%9 = getelementptr inbounds %struct.flock, %struct.flock* %3, i32 0, i32 2
store i64 0, i64* %9
%10 = call i32 (...) @getpid()
%11 = getelementptr inbounds %struct.flock, %struct.flock* %3, i32 0, i32 1
store i32 %10, i32* %11
%12 = load i32, i32* %2
%13 = load i32, i32* @F_SETLK
%14 = call i32 @fcntl(i32 %12, i32 %13, %struct.flock* %3)
ret void
}

LLVM IR (-O2):
%struct.flock = type { i32, i32, i64, i32, i32 }
@F_RDLCK = global i32 0
@SEEK_SET = global i32 0
@F_SETLK = global i32 0
define void @pipe_setup_for_binary(i32 %0) {
%2 = alloca %struct.flock
%3 = bitcast %struct.flock* %2 to i8*
%4 = load i32, i32* @F_RDLCK
%5 = getelementptr inbounds %struct.flock, %struct.flock* %2, i64 0, i32 4
store i32 %4, i32* %5
%6 = load i32, i32* @SEEK_SET
%7 = getelementptr inbounds %struct.flock, %struct.flock* %2, i64 0, i32 3
store i32 %6, i32* %7
%8 = getelementptr inbounds %struct.flock, %struct.flock* %2, i64 0, i32 0
store i32 625315306, i32* %8
%9 = getelementptr inbounds %struct.flock, %struct.flock* %2, i64 0, i32 2
store i64 0, i64* %9
%10 = tail call i32 (...) @getpid()
%11 = getelementptr inbounds %struct.flock, %struct.flock* %2, i64 0, i32 1
store i32 %10, i32* %11
%12 = load i32, i32* @F_SETLK
%13 = call i32 @fcntl(i32 %0, i32 %12, %struct.flock* %2)
ret void
}