#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 *, unsigned short *);
int /*<<< orphan*/ extract_receive_buffer_header(unsigned short *,
                                                 unsigned char *,
                                                 unsigned char *,
                                                 unsigned char *);
int /*<<< orphan*/ init_receive_buffer(unsigned short *);
int /*<<< orphan*/ init_send_buffer(unsigned short *);
int /*<<< orphan*/ special_request(unsigned char *, unsigned char *);
int /*<<< orphan*/ stuff2byteuint(short, unsigned char *, unsigned short *);
int /*<<< orphan*/ stuff_send_buffer_header(unsigned short, int /*<<< orphan*/,
                                            int, unsigned char *);
long arm_zr(short override) {
  long result;
  unsigned 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);
  stuff2byteuint(override, user_send_buffer, &b_index);
  stuff_send_buffer_header(b_index, 0, 40, 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_zr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
lea    -0x12(%rbp),%rdi
call   1070 <init_send_buffer@plt>
mov    -0x2(%rbp),%ax
lea    -0x120(%rbp),%rsi
lea    -0x12(%rbp),%rdx
movswl %ax,%edi
call   1060 <stuff2byteuint@plt>
mov    -0x12(%rbp),%ax
lea    -0x120(%rbp),%rcx
xor    %esi,%esi
mov    $0x28,%edx
movzwl %ax,%edi
call   1080 <stuff_send_buffer_header@plt>
lea    -0x120(%rbp),%rdi
lea    -0x220(%rbp),%rsi
call   1030 <special_request@plt>
lea    -0x12(%rbp),%rdi
call   1040 <init_receive_buffer@plt>
lea    -0x220(%rbp),%rcx
lea    -0x14(%rbp),%rdi
lea    -0x15(%rbp),%rsi
lea    -0x16(%rbp),%rdx
call   1050 <extract_receive_buffer_header@plt>
lea    -0x220(%rbp),%rdi
lea    -0x12(%rbp),%rsi
call   1090 <extract4byteuint@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arm_zr>:
push   %rbp
push   %r14
push   %rbx
sub    $0x210,%rsp
mov    %edi,%ebp
lea    0xa(%rsp),%r14
mov    %r14,%rdi
call   1070 <init_send_buffer@plt>
lea    0x110(%rsp),%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <stuff2byteuint@plt>
movzwl 0xa(%rsp),%edi
xor    %esi,%esi
mov    $0x28,%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    $0x210,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i64 @arm_zr(i16 signext %0) {
%2 = alloca i16
%3 = alloca i16
%4 = alloca i8
%5 = alloca i8
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = bitcast i16* %2 to i8*
%9 = bitcast i16* %3 to i8*
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%12 = call i32 @init_send_buffer(i16* %2)
%13 = call i32 @stuff2byteuint(i16 signext %0, i8* %10, i16* %2)
%14 = load i16, i16* %2
%15 = call i32 @stuff_send_buffer_header(i16 zeroext %14, i32 0, i32 40, i8* %10)
%16 = call i32 @special_request(i8* %10, i8* %11)
%17 = call i32 @init_receive_buffer(i16* %2)
%18 = call i32 @extract_receive_buffer_header(i16* %3, i8* %4, i8* %5, i8* %11)
%19 = call i64 @extract4byteuint(i8* %11, i16* %2)
ret i64 %19
}