#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 int /*<<< orphan*/ uint8_t;
typedef scalar_t__ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(scalar_t__ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ send_do(scalar_t__, int);
int /*<<< orphan*/ swap16(scalar_t__ *);
int rt_modbus_force_single_output(uint8_t *buf, int sz) {
  uint16_t address;
  uint16_t value;
  memcpy(&address, buf + 2, 2);
  swap16(&address);
  memcpy(&value, buf + 4, 2);
  swap16(&value);
  send_do(address, value != 0);
  return 8;
}


x86 assembly (clang, -O0):
<rt_modbus_force_single_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rsi
add    $0x8,%rsi
lea    -0x18(%rbp),%rdi
mov    $0x2,%edx
call   1030 <memcpy@plt>
lea    -0x18(%rbp),%rdi
call   1040 <swap16@plt>
mov    -0x8(%rbp),%rsi
add    $0x10,%rsi
lea    -0x20(%rbp),%rdi
mov    $0x2,%edx
call   1030 <memcpy@plt>
lea    -0x20(%rbp),%rdi
call   1040 <swap16@plt>
mov    -0x18(%rbp),%rdi
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%esi
call   1050 <send_do@plt>
mov    $0x8,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rt_modbus_force_single_output>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0x8(%rdi),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x2,%edx
call   1030 <memcpy@plt>
mov    %r14,%rdi
call   1040 <swap16@plt>
add    $0x10,%rbx
lea    0x8(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <memcpy@plt>
mov    %r14,%rdi
call   1040 <swap16@plt>
mov    0x10(%rsp),%rdi
xor    %esi,%esi
cmpq   $0x0,0x8(%rsp)
setne  %sil
call   1050 <send_do@plt>
mov    $0x8,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @rt_modbus_force_single_output(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32*, i32** %3
%8 = getelementptr inbounds i32, i32* %7, i64 2
%9 = call i32 @memcpy(i64* %5, i32* %8, i32 2)
%10 = call i32 @swap16(i64* %5)
%11 = load i32*, i32** %3
%12 = getelementptr inbounds i32, i32* %11, i64 4
%13 = call i32 @memcpy(i64* %6, i32* %12, i32 2)
%14 = call i32 @swap16(i64* %6)
%15 = load i64, i64* %5
%16 = load i64, i64* %6
%17 = icmp ne i64 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @send_do(i64 %15, i32 %18)
ret i32 8
}

LLVM IR (-O2):
define i32 @rt_modbus_force_single_output(i32* %0, i32 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = bitcast i64* %3 to i8*
%6 = bitcast i64* %4 to i8*
%7 = getelementptr inbounds i32, i32* %0, i64 2
%8 = call i32 @memcpy(i64* %3, i32* %7, i32 2)
%9 = call i32 @swap16(i64* %3)
%10 = getelementptr inbounds i32, i32* %0, i64 4
%11 = call i32 @memcpy(i64* %4, i32* %10, i32 2)
%12 = call i32 @swap16(i64* %4)
%13 = load i64, i64* %3
%14 = load i64, i64* %4
%15 = icmp ne i64 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @send_do(i64 %13, i32 %16)
ret i32 8
}