#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 */

/* Variables and functions */
long extract4byteuint(unsigned char *, short *);
int /*<<< orphan*/ extract_receive_buffer_header(short *, unsigned char *,
                                                 unsigned char *,
                                                 unsigned char *);
int /*<<< orphan*/ init_receive_buffer(short *);
int /*<<< orphan*/ init_send_buffer(short *);
int /*<<< orphan*/ special_request(unsigned char *, unsigned char *);
int /*<<< orphan*/ stuff4byteuint(long, unsigned char *, short *);
int /*<<< orphan*/ stuff_send_buffer_header(short, int /*<<< orphan*/, int,
                                            unsigned char *);
long arm_mv(long l_mode, long l_v, long g_mode, long g_v) {
  long result;
  short b_index, b_length;
  unsigned char serial_number;
  unsigned char packet_type;
  unsigned char user_send_buffer[256];
  unsigned char user_receive_buffer[256];
  init_send_buffer(&b_index);
  stuff4byteuint(l_mode, user_send_buffer, &b_index);
  stuff4byteuint(l_v, user_send_buffer, &b_index);
  stuff4byteuint(g_mode, user_send_buffer, &b_index);
  stuff4byteuint(g_v, user_send_buffer, &b_index);
  stuff_send_buffer_header(b_index, 0, 42, user_send_buffer);
  special_request(user_send_buffer, user_receive_buffer);
  init_receive_buffer(&b_index);
  extract_receive_buffer_header(&b_length, &serial_number, &packet_type,
                                user_receive_buffer);
  result = extract4byteuint(user_receive_buffer, &b_index);
  return result;
}


x86 assembly (clang, -O0):
<arm_mv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x2a(%rbp),%rdi
call   1060 <init_send_buffer@plt>
mov    -0x8(%rbp),%rdi
lea    -0x130(%rbp),%rsi
lea    -0x2a(%rbp),%rdx
call   1070 <stuff4byteuint@plt>
mov    -0x10(%rbp),%rdi
lea    -0x130(%rbp),%rsi
lea    -0x2a(%rbp),%rdx
call   1070 <stuff4byteuint@plt>
mov    -0x18(%rbp),%rdi
lea    -0x130(%rbp),%rsi
lea    -0x2a(%rbp),%rdx
call   1070 <stuff4byteuint@plt>
mov    -0x20(%rbp),%rdi
lea    -0x130(%rbp),%rsi
lea    -0x2a(%rbp),%rdx
call   1070 <stuff4byteuint@plt>
mov    -0x2a(%rbp),%ax
lea    -0x130(%rbp),%rcx
xor    %esi,%esi
mov    $0x2a,%edx
movswl %ax,%edi
call   1080 <stuff_send_buffer_header@plt>
lea    -0x130(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1030 <special_request@plt>
lea    -0x2a(%rbp),%rdi
call   1040 <init_receive_buffer@plt>
lea    -0x230(%rbp),%rcx
lea    -0x2c(%rbp),%rdi
lea    -0x2d(%rbp),%rsi
lea    -0x2e(%rbp),%rdx
call   1050 <extract_receive_buffer_header@plt>
lea    -0x230(%rbp),%rdi
lea    -0x2a(%rbp),%rsi
call   1090 <extract4byteuint@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arm_mv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbp
lea    0xa(%rsp),%r14
mov    %r14,%rdi
call   1060 <init_send_buffer@plt>
lea    0x110(%rsp),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <stuff4byteuint@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <stuff4byteuint@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <stuff4byteuint@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <stuff4byteuint@plt>
movswl 0xa(%rsp),%edi
xor    %esi,%esi
mov    $0x2a,%edx
mov    %rbx,%rcx
call   1080 <stuff_send_buffer_header@plt>
lea    0x10(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <special_request@plt>
mov    %r14,%rdi
call   1040 <init_receive_buffer@plt>
lea    0xe(%rsp),%rdi
lea    0xd(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %rbp,%rcx
call   1050 <extract_receive_buffer_header@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1090 <extract4byteuint@plt>
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @arm_mv(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i16
%11 = alloca i16
%12 = alloca i8
%13 = alloca i8
%14 = alloca [256 x i8]
%15 = alloca [256 x i8]
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%16 = call i32 @init_send_buffer(i16* %10)
%17 = load i64, i64* %5
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%19 = call i32 @stuff4byteuint(i64 %17, i8* %18, i16* %10)
%20 = load i64, i64* %6
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%22 = call i32 @stuff4byteuint(i64 %20, i8* %21, i16* %10)
%23 = load i64, i64* %7
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%25 = call i32 @stuff4byteuint(i64 %23, i8* %24, i16* %10)
%26 = load i64, i64* %8
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%28 = call i32 @stuff4byteuint(i64 %26, i8* %27, i16* %10)
%29 = load i16, i16* %10
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%31 = call i32 @stuff_send_buffer_header(i16 signext %29, i32 0, i32 42, i8* %30)
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%34 = call i32 @special_request(i8* %32, i8* %33)
%35 = call i32 @init_receive_buffer(i16* %10)
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%37 = call i32 @extract_receive_buffer_header(i16* %11, i8* %12, i8* %13, i8* %36)
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%39 = call i64 @extract4byteuint(i8* %38, i16* %10)
store i64 %39, i64* %9
%40 = load i64, i64* %9
ret i64 %40
}

LLVM IR (-O2):
define i64 @arm_mv(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i16
%6 = alloca i16
%7 = alloca i8
%8 = alloca i8
%9 = alloca [256 x i8]
%10 = alloca [256 x i8]
%11 = bitcast i16* %5 to i8*
%12 = bitcast i16* %6 to i8*
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%15 = call i32 @init_send_buffer(i16* %5)
%16 = call i32 @stuff4byteuint(i64 %0, i8* %13, i16* %5)
%17 = call i32 @stuff4byteuint(i64 %1, i8* %13, i16* %5)
%18 = call i32 @stuff4byteuint(i64 %2, i8* %13, i16* %5)
%19 = call i32 @stuff4byteuint(i64 %3, i8* %13, i16* %5)
%20 = load i16, i16* %5
%21 = call i32 @stuff_send_buffer_header(i16 signext %20, i32 0, i32 42, i8* %13)
%22 = call i32 @special_request(i8* %13, i8* %14)
%23 = call i32 @init_receive_buffer(i16* %5)
%24 = call i32 @extract_receive_buffer_header(i16* %6, i8* %7, i8* %8, i8* %14)
%25 = call i64 @extract4byteuint(i8* %14, i16* %5)
ret i64 %25
}