#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 /*<<< orphan*/ data2;
typedef int /*<<< orphan*/ data1;

/* Variables and functions */
int make_send_data_command(char *, int, int, char *, int);
int make_uart_9600_command(char *);
int /*<<< orphan*/ print_data(char *, int);
int /*<<< orphan*/ sm_parse_packet_stream(int);
void test_simplemesh() {
  char packet_buf[127];
  char data1[] = "test";
  int data1_size = sizeof(data1) - 1;
  int size = make_send_data_command(packet_buf, 14, 04, data1, data1_size);
  print_data(packet_buf, size);
  size = make_uart_9600_command(packet_buf);
  print_data(packet_buf, size);
  uint8_t data2[] = {171, 10, 34, 0, 0, 0, 255, 199, 84, 69, 83, 84, 96, 173};
  int data2_size = sizeof(data2);
  for (int i = 0; i < data2_size; ++i)
    sm_parse_packet_stream(data2[i]);
}


x86 assembly (clang, -O0):
<test_simplemesh>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    0xe9f(%rip),%eax
mov    %eax,-0x85(%rbp)
mov    0xe97(%rip),%al
mov    %al,-0x81(%rbp)
movl   $0x4,-0x8c(%rbp)
lea    -0x80(%rbp),%rdi
lea    -0x85(%rbp),%rcx
mov    -0x8c(%rbp),%r8d
mov    $0xe,%esi
mov    $0x4,%edx
call   1040 <make_send_data_command@plt>
mov    %eax,-0x90(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x90(%rbp),%esi
call   1030 <print_data@plt>
lea    -0x80(%rbp),%rdi
call   1070 <make_uart_9600_command@plt>
mov    %eax,-0x90(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x90(%rbp),%esi
call   1030 <print_data@plt>
lea    -0xd0(%rbp),%rdi
lea    0xe31(%rip),%rsi
mov    $0x38,%edx
call   1050 <memcpy@plt>
movl   $0x38,-0xd4(%rbp)
movl   $0x0,-0xd8(%rbp)
mov    -0xd8(%rbp),%eax
cmp    -0xd4(%rbp),%eax
jge    1236 <test_simplemesh+0xe6>
movslq -0xd8(%rbp),%rax
mov    -0xd0(%rbp,%rax,4),%edi
call   1060 <sm_parse_packet_stream@plt>
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    11fd <test_simplemesh+0xad>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_simplemesh>:
push   %r14
push   %rbx
sub    $0x98,%rsp
movb   $0x0,0xc(%rsp)
movl   $0x74736574,0x8(%rsp)
74
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    $0xe,%esi
mov    $0x4,%edx
mov    $0x4,%r8d
call   1040 <make_send_data_command@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <print_data@plt>
mov    %rbx,%rdi
call   1060 <make_uart_9600_command@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <print_data@plt>
xor    %ebx,%ebx
lea    0xe72(%rip),%r14
xchg   %ax,%ax
mov    (%rbx,%r14,1),%edi
call   1050 <sm_parse_packet_stream@plt>
add    $0x4,%rbx
cmp    $0xe0,%rbx
jne    11a0 <test_simplemesh+0x60>
add    $0x98,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.test_simplemesh.data1 = [5 x i8] c"test\00"
@__const.test_simplemesh.data2 = [14 x i32] [i32 171, i32 10, i32 34, i32 0, i32 0, i32 0, i32 255, i32 199, i32 84, i32 69, i32 83, i32 84, i32 96, i32 173]
define void @test_simplemesh() {
%1 = alloca [127 x i8]
%2 = alloca [5 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca [14 x i32]
%6 = alloca i32
%7 = alloca i32
%8 = bitcast [5 x i8]* %2 to i8*
store i32 4, i32* %3
%9 = getelementptr inbounds [127 x i8], [127 x i8]* %1, i64 0, i64 0
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%11 = load i32, i32* %3
%12 = call i32 @make_send_data_command(i8* %9, i32 14, i32 4, i8* %10, i32 %11)
store i32 %12, i32* %4
%13 = getelementptr inbounds [127 x i8], [127 x i8]* %1, i64 0, i64 0
%14 = load i32, i32* %4
%15 = call i32 @print_data(i8* %13, i32 %14)
%16 = getelementptr inbounds [127 x i8], [127 x i8]* %1, i64 0, i64 0
%17 = call i32 @make_uart_9600_command(i8* %16)
store i32 %17, i32* %4
%18 = getelementptr inbounds [127 x i8], [127 x i8]* %1, i64 0, i64 0
%19 = load i32, i32* %4
%20 = call i32 @print_data(i8* %18, i32 %19)
%21 = bitcast [14 x i32]* %5 to i8*
store i32 56, i32* %6
store i32 0, i32* %7
br label %22
22: ; preds = %32, %0
%23 = load i32, i32* %7
%24 = load i32, i32* %6
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %35
26: ; preds = %22
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [14 x i32], [14 x i32]* %5, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = call i32 @sm_parse_packet_stream(i32 %30)
br label %32
32: ; preds = %26
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %22
35: ; preds = %22
ret void
}

LLVM IR (-O2):
@__const.test_simplemesh.data1 = [5 x i8] c"test\00"
@__const.test_simplemesh.data2 = [14 x i32] [i32 171, i32 10, i32 34, i32 0, i32 0, i32 0, i32 255, i32 199, i32 84, i32 69, i32 83, i32 84, i32 96, i32 173]
define void @test_simplemesh() {
%1 = alloca [127 x i8]
%2 = alloca [5 x i8]
%3 = getelementptr inbounds [127 x i8], [127 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%5 = call i32 @make_send_data_command(i8* %3, i32 14, i32 4, i8* %4, i32 4)
%6 = call i32 @print_data(i8* %3, i32 %5)
%7 = call i32 @make_uart_9600_command(i8* %3)
%8 = call i32 @print_data(i8* %3, i32 %7)
br label %10
9: ; preds = %10
ret void
10: ; preds = %0, %10
%11 = phi i64 [ 0, %0 ], [ %15, %10 ]
%12 = getelementptr inbounds [14 x i32], [14 x i32]* @__const.test_simplemesh.data2, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = call i32 @sm_parse_packet_stream(i32 %13)
%15 = add nuw nsw i64 %11, 1
%16 = icmp eq i64 %15, 56
br i1 %16, label %9, label %10
}