#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 scalar_t__ u_int16_t;
struct modemchannel {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ kiss_encodepkt(struct modemchannel *, unsigned char *, int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *, int);
void p3dreceive(struct modemchannel *chan, const unsigned char *pkt,
                u_int16_t crc) {
  unsigned char buf[256 + 16];
  unsigned int i;
  if (crc)
    return;
  buf[0] = 'Q' << 1;
  buf[1] = 'S' << 1;
  buf[2] = 'T' << 1;
  buf[3] = ' ' << 1;
  buf[4] = ' ' << 1;
  buf[5] = ' ' << 1;
  buf[6] = (0 << 1) | 0x80;
  buf[7] = 'A' << 1;
  buf[8] = 'O' << 1;
  buf[9] = '4' << 1;
  buf[10] = '0' << 1;
  buf[11] = ' ' << 1;
  buf[12] = ' ' << 1;
  buf[13] = (1 << 1) | 1;
  buf[14] = 0x03;
  buf[15] = 0xf0;
  memcpy(&buf[16], &pkt[0], 256);
  kiss_encodepkt(chan, buf, 256 + 16);
  buf[13] = (2 << 1) | 1;
  memcpy(&buf[16], &pkt[256], 256);
  kiss_encodepkt(chan, buf, 256 + 16);
}


x86 assembly (clang, -O0):
<p3dreceive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1147 <p3dreceive+0x27>
jmp    1221 <p3dreceive+0x101>
movb   $0xa2,-0x130(%rbp)
movb   $0xa6,-0x12f(%rbp)
movb   $0xa8,-0x12e(%rbp)
movb   $0x40,-0x12d(%rbp)
movb   $0x40,-0x12c(%rbp)
movb   $0x40,-0x12b(%rbp)
movb   $0x80,-0x12a(%rbp)
movb   $0x82,-0x129(%rbp)
movb   $0x9e,-0x128(%rbp)
movb   $0x68,-0x127(%rbp)
movb   $0x60,-0x126(%rbp)
movb   $0x40,-0x125(%rbp)
movb   $0x40,-0x124(%rbp)
movb   $0x3,-0x123(%rbp)
movb   $0x3,-0x122(%rbp)
movb   $0xf0,-0x121(%rbp)
lea    -0x130(%rbp),%rdi
add    $0x10,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x100,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rdi
lea    -0x130(%rbp),%rsi
mov    $0x110,%edx
call   1040 <kiss_encodepkt@plt>
movb   $0x5,-0x123(%rbp)
lea    -0x130(%rbp),%rdi
add    $0x10,%rdi
mov    -0x10(%rbp),%rsi
add    $0x100,%rsi
mov    $0x100,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rdi
lea    -0x130(%rbp),%rsi
mov    $0x110,%edx
call   1040 <kiss_encodepkt@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<p3dreceive>:
test   %rdx,%rdx
je     1126 <p3dreceive+0x6>
ret
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movaps 0xebf(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0x100,%edx
call   1030 <memcpy@plt>
mov    %rsp,%r12
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x110,%edx
call   1040 <kiss_encodepkt@plt>
movb   $0x5,0xd(%rsp)
add    $0x100,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1030 <memcpy@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x110,%edx
call   1040 <kiss_encodepkt@plt>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.modemchannel = type { i32 }
define void @p3dreceive(%struct.modemchannel* %0, i8* %1, i64 %2) {
%4 = alloca %struct.modemchannel*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca [272 x i8]
%8 = alloca i32
store %struct.modemchannel* %0, %struct.modemchannel** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%9 = load i64, i64* %6
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %3
br label %44
12: ; preds = %3
%13 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 0
store i8 -94, i8* %13
%14 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 1
store i8 -90, i8* %14
%15 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 2
store i8 -88, i8* %15
%16 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 3
store i8 64, i8* %16
%17 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 4
store i8 64, i8* %17
%18 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 5
store i8 64, i8* %18
%19 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 6
store i8 -128, i8* %19
%20 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 7
store i8 -126, i8* %20
%21 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 8
store i8 -98, i8* %21
%22 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 9
store i8 104, i8* %22
%23 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 10
store i8 96, i8* %23
%24 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 11
store i8 64, i8* %24
%25 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 12
store i8 64, i8* %25
%26 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 13
store i8 3, i8* %26
%27 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 14
store i8 3, i8* %27
%28 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 15
store i8 -16, i8* %28
%29 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 16
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i64 0
%32 = call i32 @memcpy(i8* %29, i8* %31, i32 256)
%33 = load %struct.modemchannel*, %struct.modemchannel** %4
%34 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 0
%35 = call i32 @kiss_encodepkt(%struct.modemchannel* %33, i8* %34, i32 272)
%36 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 13
store i8 5, i8* %36
%37 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 16
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i64 256
%40 = call i32 @memcpy(i8* %37, i8* %39, i32 256)
%41 = load %struct.modemchannel*, %struct.modemchannel** %4
%42 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 0
%43 = call i32 @kiss_encodepkt(%struct.modemchannel* %41, i8* %42, i32 272)
br label %44
44: ; preds = %12, %11
ret void
}

LLVM IR (-O2):
%struct.modemchannel = type { i32 }
define void @p3dreceive(%struct.modemchannel* %0, i8* %1, i64 %2) {
%4 = alloca [272 x i8]
%5 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 0
%6 = icmp eq i64 %2, 0
br i1 %6, label %7, label %29
7: ; preds = %3
store i8 -94, i8* %5
%8 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 1
store i8 -90, i8* %8
%9 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 2
store i8 -88, i8* %9
%10 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 3
store i8 64, i8* %10
%11 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 4
store i8 64, i8* %11
%12 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 5
store i8 64, i8* %12
%13 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 6
store i8 -128, i8* %13
%14 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 7
store i8 -126, i8* %14
%15 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 8
store i8 -98, i8* %15
%16 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 9
store i8 104, i8* %16
%17 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 10
store i8 96, i8* %17
%18 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 11
store i8 64, i8* %18
%19 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 12
store i8 64, i8* %19
%20 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 13
store i8 3, i8* %20
%21 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 14
store i8 3, i8* %21
%22 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 15
store i8 -16, i8* %22
%23 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 16
%24 = call i32 @memcpy(i8* %23, i8* %1, i32 256)
%25 = call i32 @kiss_encodepkt(%struct.modemchannel* %0, i8* %5, i32 272)
store i8 5, i8* %20
%26 = getelementptr inbounds i8, i8* %1, i64 256
%27 = call i32 @memcpy(i8* %23, i8* %26, i32 256)
%28 = call i32 @kiss_encodepkt(%struct.modemchannel* %0, i8* %5, i32 272)
br label %29
29: ; preds = %3, %7
ret void
}