#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;
typedef int uint32_t;
struct UdpSocket {
  int dummy;
};
typedef int /*<<< orphan*/ RtpBuf;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int *, int *, int);
int /*<<< orphan*/ memset(int *, int, int);
int /*<<< orphan*/ udp_write(struct UdpSocket *, int *, int);
void send_rtp_packet(struct UdpSocket *sock, uint8_t *Jpeg, int JpegLen,
                     uint32_t m_SequenceNumber, uint32_t m_Timestamp,
                     uint32_t m_offset, uint8_t marker_bit, int w, int h,
                     uint8_t format_code, uint8_t quality_code,
                     uint8_t has_dri_header) {
  uint8_t RtpBuf[2048];
  int RtpPacketSize = JpegLen + 12 + 8;
  memset(RtpBuf, 0x00, sizeof(RtpBuf));
  RtpBuf[0] = 0x80;
  RtpBuf[1] = 0x1a + (marker_bit << 7);
  RtpBuf[2] = m_SequenceNumber >> 8;
  RtpBuf[3] = m_SequenceNumber & 0x0FF;
  RtpBuf[4] = (m_Timestamp & 0xFF000000) >> 24;
  RtpBuf[5] = (m_Timestamp & 0x00FF0000) >> 16;
  RtpBuf[6] = (m_Timestamp & 0x0000FF00) >> 8;
  RtpBuf[7] = (m_Timestamp & 0x000000FF);
  RtpBuf[8] = 0x13;
  RtpBuf[9] = 0xf9;
  RtpBuf[10] = 0x7e;
  RtpBuf[11] = 0x67;
  RtpBuf[12] = 0x00;
  RtpBuf[13] = (m_offset & 0x00FF0000) >> 16;
  RtpBuf[14] = (m_offset & 0x0000FF00) >> 8;
  RtpBuf[15] = (m_offset & 0x000000FF);
  RtpBuf[16] = 0x00;
  RtpBuf[17] = 60;
  RtpBuf[16] = format_code;
  if (has_dri_header)
    RtpBuf[16] |= 0x40;
  RtpBuf[17] = quality_code;
  RtpBuf[18] = w / 8;
  RtpBuf[19] = h / 8;
  memcpy(&RtpBuf[20], Jpeg, JpegLen);
  udp_write(sock, RtpBuf, RtpPacketSize);
}


x86 assembly (clang, -O0):
<send_rtp_packet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
mov    0x38(%rbp),%eax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0xc,%eax
add    $0x8,%eax
mov    %eax,-0x2024(%rbp)
lea    -0x2020(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1040 <memset@plt>
movl   $0x80,-0x2020(%rbp)
mov    0x10(%rbp),%eax
shl    $0x7,%eax
add    $0x1a,%eax
mov    %eax,-0x201c(%rbp)
mov    -0x18(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x2018(%rbp)
mov    -0x18(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x2014(%rbp)
mov    -0x1c(%rbp),%eax
and    $0xff000000,%eax
shr    $0x18,%eax
mov    %eax,-0x2010(%rbp)
mov    -0x1c(%rbp),%eax
and    $0xff0000,%eax
sar    $0x10,%eax
mov    %eax,-0x200c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    %eax,-0x2008(%rbp)
mov    -0x1c(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x2004(%rbp)
movl   $0x13,-0x2000(%rbp)
movl   $0xf9,-0x1ffc(%rbp)
movl   $0x7e,-0x1ff8(%rbp)
movl   $0x67,-0x1ff4(%rbp)
movl   $0x0,-0x1ff0(%rbp)
mov    -0x20(%rbp),%eax
and    $0xff0000,%eax
sar    $0x10,%eax
mov    %eax,-0x1fec(%rbp)
mov    -0x20(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    %eax,-0x1fe8(%rbp)
mov    -0x20(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x1fe4(%rbp)
movl   $0x0,-0x1fe0(%rbp)
movl   $0x3c,-0x1fdc(%rbp)
mov    0x28(%rbp),%eax
mov    %eax,-0x1fe0(%rbp)
cmpl   $0x0,0x38(%rbp)
je     1291 <send_rtp_packet+0x161>
mov    -0x1fe0(%rbp),%eax
or     $0x40,%eax
mov    %eax,-0x1fe0(%rbp)
mov    0x30(%rbp),%eax
mov    %eax,-0x1fdc(%rbp)
mov    0x18(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1fd8(%rbp)
mov    0x20(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1fd4(%rbp)
lea    -0x2020(%rbp),%rdi
add    $0x50,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x8(%rbp),%rdi
lea    -0x2020(%rbp),%rsi
mov    -0x2024(%rbp),%edx
call   1030 <udp_write@plt>
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_rtp_packet>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2018,%rsp
mov    %ecx,%ebp
mov    %edx,%r15d
mov    %r9d,%r13d
mov    %rsi,(%rsp)
mov    %r8d,%ebx
mov    %rdi,0x8(%rsp)
mov    0x2058(%rsp),%r12d
mov    0x2050(%rsp),%r14d
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1040 <memset@plt>
movl   $0x80,0x10(%rsp)
shl    $0x7,%r14d
or     $0x1a,%r14d
mov    %r14d,0x14(%rsp)
mov    %ebp,%eax
sar    $0x8,%eax
mov    %eax,0x18(%rsp)
movzbl %bpl,%eax
mov    %eax,0x1c(%rsp)
mov    %ebx,%eax
shr    $0x18,%eax
mov    %eax,0x20(%rsp)
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%eax
mov    %eax,0x24(%rsp)
movzbl %bh,%eax
mov    %eax,0x28(%rsp)
movzbl %bl,%eax
mov    %eax,0x2c(%rsp)
movaps 0xe3a(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movl   $0x0,0x40(%rsp)
mov    %r13d,%ecx
mov    %r13d,%eax
shr    $0x10,%eax
movzbl %al,%eax
mov    %eax,0x44(%rsp)
movzbl %ch,%eax
mov    %eax,0x48(%rsp)
movzbl %cl,%eax
mov    %eax,0x4c(%rsp)
mov    0x2068(%rsp),%ecx
mov    %ecx,%eax
or     $0x40,%eax
cmpl   $0x0,0x2078(%rsp)
cmove  %ecx,%eax
mov    %eax,0x50(%rsp)
lea    0x14(%r15),%ebp
mov    0x2070(%rsp),%eax
mov    %eax,0x54(%rsp)
lea    0x7(%r12),%eax
test   %r12d,%r12d
cmovns %r12d,%eax
sar    $0x3,%eax
mov    0x2060(%rsp),%edx
lea    0x7(%rdx),%ecx
test   %edx,%edx
cmovns %edx,%ecx
mov    %eax,0x58(%rsp)
sar    $0x3,%ecx
mov    %ecx,0x5c(%rsp)
lea    0x60(%rsp),%rdi
mov    (%rsp),%rsi
mov    %r15d,%edx
call   1050 <memcpy@plt>
mov    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %ebp,%edx
call   1030 <udp_write@plt>
add    $0x2018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.UdpSocket = type { i32 }
define void @send_rtp_packet(%struct.UdpSocket* %0, i32* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11) {
%13 = alloca %struct.UdpSocket*
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca [2048 x i32]
%26 = alloca i32
store %struct.UdpSocket* %0, %struct.UdpSocket** %13
store i32* %1, i32** %14
store i32 %2, i32* %15
store i32 %3, i32* %16
store i32 %4, i32* %17
store i32 %5, i32* %18
store i32 %6, i32* %19
store i32 %7, i32* %20
store i32 %8, i32* %21
store i32 %9, i32* %22
store i32 %10, i32* %23
store i32 %11, i32* %24
%27 = load i32, i32* %15
%28 = add nsw i32 %27, 12
%29 = add nsw i32 %28, 8
store i32 %29, i32* %26
%30 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 0
%31 = call i32 @memset(i32* %30, i32 0, i32 8192)
%32 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 0
store i32 128, i32* %32
%33 = load i32, i32* %19
%34 = shl i32 %33, 7
%35 = add nsw i32 26, %34
%36 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 1
store i32 %35, i32* %36
%37 = load i32, i32* %16
%38 = ashr i32 %37, 8
%39 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 2
store i32 %38, i32* %39
%40 = load i32, i32* %16
%41 = and i32 %40, 255
%42 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 3
store i32 %41, i32* %42
%43 = load i32, i32* %17
%44 = and i32 %43, -16777216
%45 = lshr i32 %44, 24
%46 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 4
store i32 %45, i32* %46
%47 = load i32, i32* %17
%48 = and i32 %47, 16711680
%49 = ashr i32 %48, 16
%50 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 5
store i32 %49, i32* %50
%51 = load i32, i32* %17
%52 = and i32 %51, 65280
%53 = ashr i32 %52, 8
%54 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 6
store i32 %53, i32* %54
%55 = load i32, i32* %17
%56 = and i32 %55, 255
%57 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 7
store i32 %56, i32* %57
%58 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 8
store i32 19, i32* %58
%59 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 9
store i32 249, i32* %59
%60 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 10
store i32 126, i32* %60
%61 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 11
store i32 103, i32* %61
%62 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 12
store i32 0, i32* %62
%63 = load i32, i32* %18
%64 = and i32 %63, 16711680
%65 = ashr i32 %64, 16
%66 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 13
store i32 %65, i32* %66
%67 = load i32, i32* %18
%68 = and i32 %67, 65280
%69 = ashr i32 %68, 8
%70 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 14
store i32 %69, i32* %70
%71 = load i32, i32* %18
%72 = and i32 %71, 255
%73 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 15
store i32 %72, i32* %73
%74 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 16
store i32 0, i32* %74
%75 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 17
store i32 60, i32* %75
%76 = load i32, i32* %22
%77 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 16
store i32 %76, i32* %77
%78 = load i32, i32* %24
%79 = icmp ne i32 %78, 0
br i1 %79, label %80, label %84
80: ; preds = %12
%81 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 16
%82 = load i32, i32* %81
%83 = or i32 %82, 64
store i32 %83, i32* %81
br label %84
84: ; preds = %80, %12
%85 = load i32, i32* %23
%86 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 17
store i32 %85, i32* %86
%87 = load i32, i32* %20
%88 = sdiv i32 %87, 8
%89 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 18
store i32 %88, i32* %89
%90 = load i32, i32* %21
%91 = sdiv i32 %90, 8
%92 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 19
store i32 %91, i32* %92
%93 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 20
%94 = load i32*, i32** %14
%95 = load i32, i32* %15
%96 = call i32 @memcpy(i32* %93, i32* %94, i32 %95)
%97 = load %struct.UdpSocket*, %struct.UdpSocket** %13
%98 = getelementptr inbounds [2048 x i32], [2048 x i32]* %25, i64 0, i64 0
%99 = load i32, i32* %26
%100 = call i32 @udp_write(%struct.UdpSocket* %97, i32* %98, i32 %99)
ret void
}

LLVM IR (-O2):
%struct.UdpSocket = type { i32 }
define void @send_rtp_packet(%struct.UdpSocket* %0, i32* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11) {
%13 = alloca [2048 x i32]
%14 = bitcast [2048 x i32]* %13 to i8*
%15 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 0
%16 = call i32 @memset(i32* %15, i32 0, i32 8192)
store i32 128, i32* %15
%17 = shl i32 %6, 7
%18 = or i32 %17, 26
%19 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 1
store i32 %18, i32* %19
%20 = ashr i32 %3, 8
%21 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 2
store i32 %20, i32* %21
%22 = and i32 %3, 255
%23 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 3
store i32 %22, i32* %23
%24 = lshr i32 %4, 24
%25 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 4
store i32 %24, i32* %25
%26 = lshr i32 %4, 16
%27 = and i32 %26, 255
%28 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 5
store i32 %27, i32* %28
%29 = lshr i32 %4, 8
%30 = and i32 %29, 255
%31 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 6
store i32 %30, i32* %31
%32 = and i32 %4, 255
%33 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 7
store i32 %32, i32* %33
%34 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 8
%35 = bitcast i32* %34 to <4 x i32>*
store <4 x i32> <i32 19, i32 249, i32 126, i32 103>, <4 x i32>* %35
%36 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 12
store i32 0, i32* %36
%37 = lshr i32 %5, 16
%38 = and i32 %37, 255
%39 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 13
store i32 %38, i32* %39
%40 = lshr i32 %5, 8
%41 = and i32 %40, 255
%42 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 14
store i32 %41, i32* %42
%43 = and i32 %5, 255
%44 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 15
store i32 %43, i32* %44
%45 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 16
%46 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 17
%47 = icmp eq i32 %11, 0
%48 = or i32 %9, 64
%49 = select i1 %47, i32 %9, i32 %48
store i32 %49, i32* %45
%50 = add nsw i32 %2, 20
store i32 %10, i32* %46
%51 = sdiv i32 %7, 8
%52 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 18
store i32 %51, i32* %52
%53 = sdiv i32 %8, 8
%54 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 19
store i32 %53, i32* %54
%55 = getelementptr inbounds [2048 x i32], [2048 x i32]* %13, i64 0, i64 20
%56 = call i32 @memcpy(i32* %55, i32* %1, i32 %2)
%57 = call i32 @udp_write(%struct.UdpSocket* %0, i32* %15, i32 %50)
ret void
}