#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 */
typedef void *uint64_t;
typedef int /*<<< orphan*/ uint32_t;
struct rtcuse_cdev {
  int dummy;
};
struct iovec {
  int iov_len;
  struct fuse_out_header *iov_base;
};
struct fuse_out_header {
  int len;
  scalar_t__ error;
  void *unique;
  int /*<<< orphan*/ open_flags;
  void *fh;
  int /*<<< orphan*/ member_0;
};
struct fuse_open_out {
  int len;
  scalar_t__ error;
  void *unique;
  int /*<<< orphan*/ open_flags;
  void *fh;
  int /*<<< orphan*/ member_0;
};
typedef int /*<<< orphan*/ out;
typedef int /*<<< orphan*/ hdr;

/* Variables and functions */
int rtcuse_writev_block(struct rtcuse_cdev *, struct iovec *, int);
int rtcuse_reply_open(struct rtcuse_cdev *dev, uint64_t unique, uint64_t fh,
                      uint32_t flags) {
  struct fuse_open_out out = {0};
  struct fuse_out_header hdr;
  struct iovec iov[2];
  out.fh = fh;
  out.open_flags = flags;
  hdr.unique = unique;
  hdr.len = sizeof(hdr) + sizeof(out);
  hdr.error = 0;
  iov[0].iov_base = &hdr;
  iov[0].iov_len = sizeof(hdr);
  iov[1].iov_base = &out;
  iov[1].iov_len = sizeof(out);
  return rtcuse_writev_block(dev, iov, 2);
}


x86 assembly (clang, -O0):
<rtcuse_reply_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
movl   $0x60,-0x80(%rbp)
movq   $0x0,-0x78(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0x98(%rbp)
movl   $0x30,-0xa0(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x88(%rbp)
movl   $0x30,-0x90(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x2,%edx
call   1040 <rtcuse_writev_block@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtcuse_reply_open>:
sub    $0x88,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
mov    %rdx,0x40(%rsp)
mov    %ecx,0x38(%rsp)
mov    %rsi,0x68(%rsp)
movl   $0x60,0x58(%rsp)
movq   $0x0,0x60(%rsp)
lea    0x58(%rsp),%rax
mov    %rax,0x8(%rsp)
movl   $0x30,(%rsp)
lea    0x20(%rsp),%rax
mov    %rax,0x18(%rsp)
movl   $0x30,0x10(%rsp)
mov    %rsp,%rsi
mov    $0x2,%edx
call   1030 <rtcuse_writev_block@plt>
add    $0x88,%rsp
ret

LLVM IR (-O0):
%struct.rtcuse_cdev = type { i32 }
%struct.fuse_open_out = type { i32, i64, i8*, i32, i8*, i32 }
%struct.fuse_out_header = type { i32, i64, i8*, i32, i8*, i32 }
%struct.iovec = type { i32, %struct.fuse_out_header* }
define i32 @rtcuse_reply_open(%struct.rtcuse_cdev* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca %struct.rtcuse_cdev*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca %struct.fuse_open_out
%10 = alloca %struct.fuse_out_header
%11 = alloca [2 x %struct.iovec]
store %struct.rtcuse_cdev* %0, %struct.rtcuse_cdev** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%12 = bitcast %struct.fuse_open_out* %9 to i8*
%13 = load i8*, i8** %7
%14 = getelementptr inbounds %struct.fuse_open_out, %struct.fuse_open_out* %9, i32 0, i32 4
store i8* %13, i8** %14
%15 = load i32, i32* %8
%16 = getelementptr inbounds %struct.fuse_open_out, %struct.fuse_open_out* %9, i32 0, i32 3
store i32 %15, i32* %16
%17 = load i8*, i8** %6
%18 = getelementptr inbounds %struct.fuse_out_header, %struct.fuse_out_header* %10, i32 0, i32 2
store i8* %17, i8** %18
%19 = getelementptr inbounds %struct.fuse_out_header, %struct.fuse_out_header* %10, i32 0, i32 0
store i32 96, i32* %19
%20 = getelementptr inbounds %struct.fuse_out_header, %struct.fuse_out_header* %10, i32 0, i32 1
store i64 0, i64* %20
%21 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %11, i64 0, i64 0
%22 = getelementptr inbounds %struct.iovec, %struct.iovec* %21, i32 0, i32 1
store %struct.fuse_out_header* %10, %struct.fuse_out_header** %22
%23 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %11, i64 0, i64 0
%24 = getelementptr inbounds %struct.iovec, %struct.iovec* %23, i32 0, i32 0
store i32 48, i32* %24
%25 = bitcast %struct.fuse_open_out* %9 to %struct.fuse_out_header*
%26 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %11, i64 0, i64 1
%27 = getelementptr inbounds %struct.iovec, %struct.iovec* %26, i32 0, i32 1
store %struct.fuse_out_header* %25, %struct.fuse_out_header** %27
%28 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %11, i64 0, i64 1
%29 = getelementptr inbounds %struct.iovec, %struct.iovec* %28, i32 0, i32 0
store i32 48, i32* %29
%30 = load %struct.rtcuse_cdev*, %struct.rtcuse_cdev** %5
%31 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %11, i64 0, i64 0
%32 = call i32 @rtcuse_writev_block(%struct.rtcuse_cdev* %30, %struct.iovec* %31, i32 2)
ret i32 %32
}

LLVM IR (-O2):
%struct.rtcuse_cdev = type { i32 }
%struct.fuse_open_out = type { i32, i64, i8*, i32, i8*, i32 }
%struct.fuse_out_header = type { i32, i64, i8*, i32, i8*, i32 }
%struct.iovec = type { i32, %struct.fuse_out_header* }
define i32 @rtcuse_reply_open(%struct.rtcuse_cdev* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca %struct.fuse_open_out
%6 = alloca %struct.fuse_out_header
%7 = alloca [2 x %struct.iovec]
%8 = bitcast %struct.fuse_open_out* %5 to i8*
%9 = bitcast %struct.fuse_out_header* %6 to i8*
%10 = bitcast [2 x %struct.iovec]* %7 to i8*
%11 = getelementptr inbounds %struct.fuse_open_out, %struct.fuse_open_out* %5, i64 0, i32 4
store i8* %2, i8** %11
%12 = getelementptr inbounds %struct.fuse_open_out, %struct.fuse_open_out* %5, i64 0, i32 3
store i32 %3, i32* %12
%13 = getelementptr inbounds %struct.fuse_out_header, %struct.fuse_out_header* %6, i64 0, i32 2
store i8* %1, i8** %13
%14 = getelementptr inbounds %struct.fuse_out_header, %struct.fuse_out_header* %6, i64 0, i32 0
store i32 96, i32* %14
%15 = getelementptr inbounds %struct.fuse_out_header, %struct.fuse_out_header* %6, i64 0, i32 1
store i64 0, i64* %15
%16 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %7, i64 0, i64 0
%17 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %7, i64 0, i64 0, i32 1
store %struct.fuse_out_header* %6, %struct.fuse_out_header** %17
%18 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %7, i64 0, i64 0, i32 0
store i32 48, i32* %18
%19 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %7, i64 0, i64 1, i32 1
%20 = bitcast %struct.fuse_out_header** %19 to %struct.fuse_open_out**
store %struct.fuse_open_out* %5, %struct.fuse_open_out** %20
%21 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %7, i64 0, i64 1, i32 0
store i32 48, i32* %21
%22 = call i32 @rtcuse_writev_block(%struct.rtcuse_cdev* %0, %struct.iovec* %16, i32 2)
ret i32 %22
}