#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 uint8_t;

/* Variables and functions */
int build_query_basis_rtu(int slave, int function, int start_addr, int nb,
                          uint8_t *query) {
  query[0] = slave;
  query[1] = function;
  query[2] = start_addr >> 8;
  query[3] = start_addr & 0x00ff;
  query[4] = nb >> 8;
  query[5] = nb & 0x00ff;
  return 6;
}


x86 assembly (clang, -O0):
<build_query_basis_rtu>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    -0x4(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0xc(%rbp),%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x10(%rbp),%ecx
sar    $0x8,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x10(%rbp),%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    $0x6,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_query_basis_rtu>:
mov    %edi,(%r8)
mov    %esi,0x4(%r8)
movzbl %dl,%eax
sar    $0x8,%edx
mov    %edx,0x8(%r8)
mov    %eax,0xc(%r8)
movzbl %cl,%eax
sar    $0x8,%ecx
mov    %ecx,0x10(%r8)
mov    %eax,0x14(%r8)
mov    $0x6,%eax
ret

LLVM IR (-O0):
define i32 @build_query_basis_rtu(i32 %0, i32 %1, i32 %2, i32 %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32* %4, i32** %10
%11 = load i32, i32* %6
%12 = load i32*, i32** %10
%13 = getelementptr inbounds i32, i32* %12, i64 0
store i32 %11, i32* %13
%14 = load i32, i32* %7
%15 = load i32*, i32** %10
%16 = getelementptr inbounds i32, i32* %15, i64 1
store i32 %14, i32* %16
%17 = load i32, i32* %8
%18 = ashr i32 %17, 8
%19 = load i32*, i32** %10
%20 = getelementptr inbounds i32, i32* %19, i64 2
store i32 %18, i32* %20
%21 = load i32, i32* %8
%22 = and i32 %21, 255
%23 = load i32*, i32** %10
%24 = getelementptr inbounds i32, i32* %23, i64 3
store i32 %22, i32* %24
%25 = load i32, i32* %9
%26 = ashr i32 %25, 8
%27 = load i32*, i32** %10
%28 = getelementptr inbounds i32, i32* %27, i64 4
store i32 %26, i32* %28
%29 = load i32, i32* %9
%30 = and i32 %29, 255
%31 = load i32*, i32** %10
%32 = getelementptr inbounds i32, i32* %31, i64 5
store i32 %30, i32* %32
ret i32 6
}

LLVM IR (-O2):
define i32 @build_query_basis_rtu(i32 %0, i32 %1, i32 %2, i32 %3, i32* nocapture writeonly %4) {
store i32 %0, i32* %4
%6 = getelementptr inbounds i32, i32* %4, i64 1
store i32 %1, i32* %6
%7 = ashr i32 %2, 8
%8 = getelementptr inbounds i32, i32* %4, i64 2
store i32 %7, i32* %8
%9 = and i32 %2, 255
%10 = getelementptr inbounds i32, i32* %4, i64 3
store i32 %9, i32* %10
%11 = ashr i32 %3, 8
%12 = getelementptr inbounds i32, i32* %4, i64 4
store i32 %11, i32* %12
%13 = and i32 %3, 255
%14 = getelementptr inbounds i32, i32* %4, i64 5
store i32 %13, i32* %14
ret i32 6
}