#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 */
int /*<<< orphan*/ signed_int_to_two_bytes(int, unsigned char *);
int /*<<< orphan*/ unsigned_int_to_two_bytes(int, unsigned char *);
void stuff_two_signed_int(int length, int ptype, int num1, int num2,
                          unsigned char *byte_ptr) {
  byte_ptr++;
  unsigned_int_to_two_bytes(length, byte_ptr);
  byte_ptr++;
  byte_ptr++;
  *byte_ptr = ptype;
  byte_ptr++;
  signed_int_to_two_bytes(num1, byte_ptr);
  byte_ptr++;
  byte_ptr++;
  signed_int_to_two_bytes(num2, byte_ptr);
}


x86 assembly (clang, -O0):
<stuff_two_signed_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <unsigned_int_to_two_bytes@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <signed_int_to_two_bytes@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <signed_int_to_two_bytes@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stuff_two_signed_int>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8,%rbx
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebp
lea    0x1(%r8),%rsi
call   1040 <unsigned_int_to_two_bytes@plt>
mov    %bpl,0x3(%rbx)
lea    0x4(%rbx),%rsi
mov    %r15d,%edi
call   1030 <signed_int_to_two_bytes@plt>
add    $0x6,%rbx
mov    %r14d,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <signed_int_to_two_bytes@plt>

LLVM IR (-O0):
define void @stuff_two_signed_int(i32 %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %10
%13 = load i32, i32* %6
%14 = load i8*, i8** %10
%15 = call i32 @unsigned_int_to_two_bytes(i32 %13, i8* %14)
%16 = load i8*, i8** %10
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %10
%18 = load i8*, i8** %10
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %10
%20 = load i32, i32* %7
%21 = trunc i32 %20 to i8
%22 = load i8*, i8** %10
store i8 %21, i8* %22
%23 = load i8*, i8** %10
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %10
%25 = load i32, i32* %8
%26 = load i8*, i8** %10
%27 = call i32 @signed_int_to_two_bytes(i32 %25, i8* %26)
%28 = load i8*, i8** %10
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %10
%30 = load i8*, i8** %10
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %10
%32 = load i32, i32* %9
%33 = load i8*, i8** %10
%34 = call i32 @signed_int_to_two_bytes(i32 %32, i8* %33)
ret void
}

LLVM IR (-O2):
define void @stuff_two_signed_int(i32 %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = getelementptr inbounds i8, i8* %4, i64 1
%7 = tail call i32 @unsigned_int_to_two_bytes(i32 %0, i8* %6)
%8 = getelementptr inbounds i8, i8* %4, i64 3
%9 = trunc i32 %1 to i8
store i8 %9, i8* %8
%10 = getelementptr inbounds i8, i8* %4, i64 4
%11 = tail call i32 @signed_int_to_two_bytes(i32 %2, i8* %10)
%12 = getelementptr inbounds i8, i8* %4, i64 6
%13 = tail call i32 @signed_int_to_two_bytes(i32 %3, i8* %12)
ret void
}