#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 char uint8_t;

/* Variables and functions */
char generate_checksum_byte(char *, int);
int /*<<< orphan*/ usart3_putc(char);
void send_onboard_parameter(uint8_t *payload, int payload_count) {
  uint8_t checksum;
  checksum = generate_checksum_byte(payload, payload_count);
  usart3_putc('@');
  usart3_putc((uint8_t)payload_count);
  int i;
  for (i = 0; i < payload_count; i++)
    usart3_putc(payload[i]);
  usart3_putc(checksum);
}


x86 assembly (clang, -O0):
<send_onboard_parameter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <generate_checksum_byte@plt>
mov    %al,-0xd(%rbp)
mov    $0x40,%edi
call   1040 <usart3_putc@plt>
mov    -0xc(%rbp),%eax
movsbl %al,%edi
call   1040 <usart3_putc@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1185 <send_onboard_parameter+0x65>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <usart3_putc@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115a <send_onboard_parameter+0x3a>
movsbl -0xd(%rbp),%edi
call   1040 <usart3_putc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_onboard_parameter>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r15
call   1030 <generate_checksum_byte@plt>
mov    %eax,%r14d
mov    $0x40,%edi
call   1040 <usart3_putc@plt>
movsbl %bpl,%edi
call   1040 <usart3_putc@plt>
test   %ebp,%ebp
jle    1163 <send_onboard_parameter+0x43>
mov    %ebp,%ebp
xor    %ebx,%ebx
nop
movsbl (%r15,%rbx,1),%edi
call   1040 <usart3_putc@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <send_onboard_parameter+0x30>
movsbl %r14b,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <usart3_putc@plt>

LLVM IR (-O0):
define void @send_onboard_parameter(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = load i32, i32* %4
%9 = call signext i8 @generate_checksum_byte(i8* %7, i32 %8)
store i8 %9, i8* %5
%10 = call i32 @usart3_putc(i8 signext 64)
%11 = load i32, i32* %4
%12 = trunc i32 %11 to i8
%13 = call i32 @usart3_putc(i8 signext %12)
store i32 0, i32* %6
br label %14
14: ; preds = %25, %2
%15 = load i32, i32* %6
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = load i8*, i8** %3
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = call i32 @usart3_putc(i8 signext %23)
br label %25
25: ; preds = %18
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %14
28: ; preds = %14
%29 = load i8, i8* %5
%30 = call i32 @usart3_putc(i8 signext %29)
ret void
}

LLVM IR (-O2):
define void @send_onboard_parameter(i8* %0, i32 %1) {
%3 = tail call signext i8 @generate_checksum_byte(i8* %0, i32 %1)
%4 = tail call i32 @usart3_putc(i8 signext 64)
%5 = trunc i32 %1 to i8
%6 = tail call i32 @usart3_putc(i8 signext %5)
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %15, %10 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = tail call i32 @usart3_putc(i8 signext %13)
%15 = add nuw nsw i64 %11, 1
%16 = icmp eq i64 %15, %9
br i1 %16, label %17, label %10
17: ; preds = %10, %2
%18 = tail call i32 @usart3_putc(i8 signext %3)
ret void
}