#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*/ printf(char *, ...);
int /*<<< orphan*/ test_s3p_build_no_escape();
int /*<<< orphan*/ test_s3p_build_read_integration();
int /*<<< orphan*/ test_s3p_build_with_escape();
int /*<<< orphan*/ test_s3p_build_with_small_buf();
int /*<<< orphan*/ test_s3p_read_bad_checksum();
int /*<<< orphan*/ test_s3p_read_empty_packet();
int /*<<< orphan*/ test_s3p_read_no_escape();
int /*<<< orphan*/ test_s3p_read_oversize_packet();
int /*<<< orphan*/ test_s3p_read_truncated_packet();
int /*<<< orphan*/ test_s3p_read_with_escape();
int /*<<< orphan*/ test_s3p_read_with_mixed_packet();
int /*<<< orphan*/ test_s3p_read_without_start_byte();
int main(void) {
  printf("Super Simple Streaming Protocol Test Program\n");
  test_s3p_build_no_escape();
  test_s3p_build_with_escape();
  test_s3p_build_with_small_buf();
  test_s3p_read_no_escape();
  test_s3p_read_with_escape();
  test_s3p_read_without_start_byte();
  test_s3p_read_with_mixed_packet();
  test_s3p_read_bad_checksum();
  test_s3p_read_truncated_packet();
  test_s3p_read_empty_packet();
  test_s3p_read_oversize_packet();
  test_s3p_build_read_integration();
  printf("%s%s%s", "\x1B[32m", "ALL PASS\n", "\x1B[0m");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1060 <test_s3p_build_no_escape@plt>
mov    $0x0,%al
call   1030 <test_s3p_build_with_escape@plt>
mov    $0x0,%al
call   1080 <test_s3p_build_with_small_buf@plt>
mov    $0x0,%al
call   10e0 <test_s3p_read_no_escape@plt>
mov    $0x0,%al
call   10f0 <test_s3p_read_with_escape@plt>
mov    $0x0,%al
call   1040 <test_s3p_read_without_start_byte@plt>
mov    $0x0,%al
call   10c0 <test_s3p_read_with_mixed_packet@plt>
mov    $0x0,%al
call   10d0 <test_s3p_read_bad_checksum@plt>
mov    $0x0,%al
call   1050 <test_s3p_read_truncated_packet@plt>
mov    $0x0,%al
call   10a0 <test_s3p_read_empty_packet@plt>
mov    $0x0,%al
call   10b0 <test_s3p_read_oversize_packet@plt>
mov    $0x0,%al
call   1090 <test_s3p_build_read_integration@plt>
lea    0xde6(%rip),%rdi
lea    0xde6(%rip),%rsi
lea    0xde5(%rip),%rdx
lea    0xde8(%rip),%rcx
mov    $0x0,%al
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xe34(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
call   1070 <test_s3p_build_no_escape@plt>
xor    %eax,%eax
call   1030 <test_s3p_build_with_escape@plt>
xor    %eax,%eax
call   1090 <test_s3p_build_with_small_buf@plt>
xor    %eax,%eax
call   10f0 <test_s3p_read_no_escape@plt>
xor    %eax,%eax
call   1100 <test_s3p_read_with_escape@plt>
xor    %eax,%eax
call   1040 <test_s3p_read_without_start_byte@plt>
xor    %eax,%eax
call   10d0 <test_s3p_read_with_mixed_packet@plt>
xor    %eax,%eax
call   10e0 <test_s3p_read_bad_checksum@plt>
xor    %eax,%eax
call   1050 <test_s3p_read_truncated_packet@plt>
xor    %eax,%eax
call   10b0 <test_s3p_read_empty_packet@plt>
xor    %eax,%eax
call   10c0 <test_s3p_read_oversize_packet@plt>
xor    %eax,%eax
call   10a0 <test_s3p_build_read_integration@plt>
lea    0xdb8(%rip),%rdi
lea    0xdb8(%rip),%rsi
lea    0xdb7(%rip),%rdx
lea    0xdba(%rip),%rcx
xor    %eax,%eax
call   1080 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Super Simple Streaming Protocol Test Program\0A\00"
@.str.1 = [7 x i8] c"%s%s%s\00"
@.str.2 = [6 x i8] c"\1B[32m\00"
@.str.3 = [10 x i8] c"ALL PASS\0A\00"
@.str.4 = [5 x i8] c"\1B[0m\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (...) @test_s3p_build_no_escape()
%4 = call i32 (...) @test_s3p_build_with_escape()
%5 = call i32 (...) @test_s3p_build_with_small_buf()
%6 = call i32 (...) @test_s3p_read_no_escape()
%7 = call i32 (...) @test_s3p_read_with_escape()
%8 = call i32 (...) @test_s3p_read_without_start_byte()
%9 = call i32 (...) @test_s3p_read_with_mixed_packet()
%10 = call i32 (...) @test_s3p_read_bad_checksum()
%11 = call i32 (...) @test_s3p_read_truncated_packet()
%12 = call i32 (...) @test_s3p_read_empty_packet()
%13 = call i32 (...) @test_s3p_read_oversize_packet()
%14 = call i32 (...) @test_s3p_build_read_integration()
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%s%s%s\00"
@.str.2 = [6 x i8] c"\1B[32m\00"
@.str.3 = [10 x i8] c"ALL PASS\0A\00"
@.str.4 = [5 x i8] c"\1B[0m\00"
@str = [45 x i8] c"Super Simple Streaming Protocol Test Program\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @test_s3p_build_no_escape()
%3 = tail call i32 (...) @test_s3p_build_with_escape()
%4 = tail call i32 (...) @test_s3p_build_with_small_buf()
%5 = tail call i32 (...) @test_s3p_read_no_escape()
%6 = tail call i32 (...) @test_s3p_read_with_escape()
%7 = tail call i32 (...) @test_s3p_read_without_start_byte()
%8 = tail call i32 (...) @test_s3p_read_with_mixed_packet()
%9 = tail call i32 (...) @test_s3p_read_bad_checksum()
%10 = tail call i32 (...) @test_s3p_read_truncated_packet()
%11 = tail call i32 (...) @test_s3p_read_empty_packet()
%12 = tail call i32 (...) @test_s3p_read_oversize_packet()
%13 = tail call i32 (...) @test_s3p_build_read_integration()
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}