#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 int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ Do_JM_Cmd(int, int *, int *);
int __cpu_to_le32(int);
int /*<<< orphan*/ hexdump(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ memset(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
void TestCmd(int theFD, uint8_t *theCmd, uint32_t theLen) {
  uint8_t tempBuf1[(512)];
  uint32_t *tempBuf1_32 = (uint32_t *)tempBuf1;
  uint8_t tempBuf2[(512)];
  static uint32_t cmdNum = 1;
  memset(tempBuf1, 0, (512));
  memcpy(tempBuf1 + 0x08, theCmd, theLen);
  tempBuf1_32[0] = __cpu_to_le32((0x197b0322));
  tempBuf1_32[1] = __cpu_to_le32(cmdNum++);
  theLen += 0x08;
  printf("Sending command:\n");
  hexdump(tempBuf1, (theLen + 0x0f) & 0x1f0);
  Do_JM_Cmd(theFD, (uint32_t *)tempBuf1, (uint32_t *)tempBuf2);
  printf("Response:\n");
  hexdump(tempBuf2, (512));
}


x86 assembly (clang, -O0):
<TestCmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x820(%rbp),%rax
mov    %rax,-0x828(%rbp)
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1040 <memset@plt>
lea    -0x820(%rbp),%rdi
add    $0x20,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <memcpy@plt>
mov    $0x197b0322,%edi
call   1050 <__cpu_to_le32@plt>
mov    %eax,%ecx
mov    -0x828(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2e88(%rip),%edi
mov    %edi,%eax
add    $0x1,%eax
mov    %eax,0x2e7d(%rip)
call   1050 <__cpu_to_le32@plt>
mov    %eax,%ecx
mov    -0x828(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x14(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x14(%rbp)
lea    0xe0c(%rip),%rdi
call   1030 <printf@plt>
lea    -0x820(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0xf,%esi
and    $0x1f0,%esi
call   1070 <hexdump@plt>
mov    -0x4(%rbp),%edi
lea    -0x820(%rbp),%rsi
lea    -0x1030(%rbp),%rdx
call   1080 <Do_JM_Cmd@plt>
lea    0xde4(%rip),%rdi
call   1030 <printf@plt>
lea    -0x1030(%rbp),%rdi
mov    $0x200,%esi
call   1070 <hexdump@plt>
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TestCmd>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1008,%rsp
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %edi,%r14d
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1040 <memset@plt>
lea    0x20(%rsp),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1060 <memcpy@plt>
mov    $0x197b0322,%edi
call   1050 <__cpu_to_le32@plt>
mov    %eax,(%rsp)
mov    0x2ea7(%rip),%edi
lea    0x1(%rdi),%eax
mov    %eax,0x2e9e(%rip)
call   1050 <__cpu_to_le32@plt>
mov    %eax,0x4(%rsp)
lea    0xe3e(%rip),%rdi
call   1030 <puts@plt>
add    $0x17,%ebp
and    $0x1f0,%ebp
mov    %r15,%rdi
mov    %ebp,%esi
call   1070 <hexdump@plt>
lea    0x800(%rsp),%rbx
mov    %r14d,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1080 <Do_JM_Cmd@plt>
lea    0xe1a(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x200,%esi
call   1070 <hexdump@plt>
add    $0x1008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@TestCmd.cmdNum = internal global i32 1
@.str = [18 x i8] c"Sending command:\0A\00"
@.str.1 = [11 x i8] c"Response:\0A\00"
define void @TestCmd(i32 %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca [512 x i32]
%8 = alloca i32*
%9 = alloca [512 x i32]
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%10 = getelementptr inbounds [512 x i32], [512 x i32]* %7, i64 0, i64 0
store i32* %10, i32** %8
%11 = getelementptr inbounds [512 x i32], [512 x i32]* %7, i64 0, i64 0
%12 = call i32 @memset(i32* %11, i32 0, i32 512)
%13 = getelementptr inbounds [512 x i32], [512 x i32]* %7, i64 0, i64 0
%14 = getelementptr inbounds i32, i32* %13, i64 8
%15 = load i32*, i32** %5
%16 = load i32, i32* %6
%17 = call i32 @memcpy(i32* %14, i32* %15, i32 %16)
%18 = call i32 @__cpu_to_le32(i32 427492130)
%19 = load i32*, i32** %8
%20 = getelementptr inbounds i32, i32* %19, i64 0
store i32 %18, i32* %20
%21 = load i32, i32* @TestCmd.cmdNum
%22 = add nsw i32 %21, 1
store i32 %22, i32* @TestCmd.cmdNum
%23 = call i32 @__cpu_to_le32(i32 %21)
%24 = load i32*, i32** %8
%25 = getelementptr inbounds i32, i32* %24, i64 1
store i32 %23, i32* %25
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 8
store i32 %27, i32* %6
%28 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%29 = getelementptr inbounds [512 x i32], [512 x i32]* %7, i64 0, i64 0
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 15
%32 = and i32 %31, 496
%33 = call i32 @hexdump(i32* %29, i32 %32)
%34 = load i32, i32* %4
%35 = getelementptr inbounds [512 x i32], [512 x i32]* %7, i64 0, i64 0
%36 = getelementptr inbounds [512 x i32], [512 x i32]* %9, i64 0, i64 0
%37 = call i32 @Do_JM_Cmd(i32 %34, i32* %35, i32* %36)
%38 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%39 = getelementptr inbounds [512 x i32], [512 x i32]* %9, i64 0, i64 0
%40 = call i32 @hexdump(i32* %39, i32 512)
ret void
}

LLVM IR (-O2):
@TestCmd.cmdNum = internal unnamed_addr global i32 1
@str = [17 x i8] c"Sending command:\00"
@str.2 = [10 x i8] c"Response:\00"
define void @TestCmd(i32 %0, i32* %1, i32 %2) {
%4 = alloca [512 x i32]
%5 = alloca [512 x i32]
%6 = bitcast [512 x i32]* %4 to i8*
%7 = getelementptr inbounds [512 x i32], [512 x i32]* %4, i64 0, i64 0
%8 = bitcast [512 x i32]* %5 to i8*
%9 = call i32 @memset(i32* %7, i32 0, i32 512)
%10 = getelementptr inbounds [512 x i32], [512 x i32]* %4, i64 0, i64 8
%11 = call i32 @memcpy(i32* %10, i32* %1, i32 %2)
%12 = call i32 @__cpu_to_le32(i32 427492130)
store i32 %12, i32* %7
%13 = load i32, i32* @TestCmd.cmdNum
%14 = add nsw i32 %13, 1
store i32 %14, i32* @TestCmd.cmdNum
%15 = call i32 @__cpu_to_le32(i32 %13)
%16 = getelementptr inbounds [512 x i32], [512 x i32]* %4, i64 0, i64 1
store i32 %15, i32* %16
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%18 = add nsw i32 %2, 23
%19 = and i32 %18, 496
%20 = call i32 @hexdump(i32* %7, i32 %19)
%21 = getelementptr inbounds [512 x i32], [512 x i32]* %5, i64 0, i64 0
%22 = call i32 @Do_JM_Cmd(i32 %0, i32* %7, i32* %21)
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.2, i64 0, i64 0))
%24 = call i32 @hexdump(i32* %21, i32 512)
ret void
}