#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*/ rcs_tx_destroy(void *);
void *rcs_tx_init(int /*<<< orphan*/);
int /*<<< orphan*/ rcs_tx_send_bstring(void *, char *);
int /*<<< orphan*/ rcs_tx_send_bytes(void *, char *, int);
int /*<<< orphan*/ sleep(int);
int main(int argc, char **argv) {
  void *tx = rcs_tx_init(0);
  char string[] = "0000"
                  "1000"
                  "0001"
                  "0000"
                  "0010"
                  "0000"
                  "0100"
                  "0000";
  char bytes[] = {0x01, 0x02, 0x03, 0x04};
  if (tx == NULL)
    return 0;
  int i = 0;
  while (i < 5) {
    sleep(5);
    printf("send frame\n");
    rcs_tx_send_bstring(tx, string);
    sleep(2);
    rcs_tx_send_bytes(tx, bytes, 4);
    i++;
  }
  rcs_tx_destroy(tx);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %edi,%edi
call   1080 <rcs_tx_init@plt>
mov    %rax,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe64(%rip),%rsi
mov    $0x21,%edx
call   1070 <memcpy@plt>
mov    0xe75(%rip),%eax
mov    %eax,-0x44(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c6 <main+0x56>
movl   $0x0,-0x4(%rbp)
jmp    1234 <main+0xc4>
movl   $0x0,-0x48(%rbp)
cmpl   $0x5,-0x48(%rbp)
jge    1224 <main+0xb4>
mov    $0x5,%edi
call   1090 <sleep@plt>
lea    0xe3d(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <rcs_tx_send_bstring@plt>
mov    $0x2,%edi
call   1090 <sleep@plt>
mov    -0x18(%rbp),%rdi
lea    -0x44(%rbp),%rsi
mov    $0x4,%edx
call   1030 <rcs_tx_send_bytes@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11cd <main+0x5d>
mov    -0x18(%rbp),%rdi
call   1040 <rcs_tx_destroy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
xor    %edi,%edi
call   1070 <rcs_tx_init@plt>
movaps 0xe97(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe7b(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movb   $0x0,0x30(%rsp)
movl   $0x4030201,0xc(%rsp)
04
test   %rax,%rax
je     12cf <main+0x16f>
mov    %rax,%rbx
mov    $0x5,%edi
call   1080 <sleep@plt>
lea    0xe6d(%rip),%r14
mov    %r14,%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <rcs_tx_send_bstring@plt>
mov    $0x2,%edi
call   1080 <sleep@plt>
lea    0xc(%rsp),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
call   1030 <rcs_tx_send_bytes@plt>
mov    $0x5,%edi
call   1080 <sleep@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <rcs_tx_send_bstring@plt>
mov    $0x2,%edi
call   1080 <sleep@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
call   1030 <rcs_tx_send_bytes@plt>
mov    $0x5,%edi
call   1080 <sleep@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <rcs_tx_send_bstring@plt>
mov    $0x2,%edi
call   1080 <sleep@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
call   1030 <rcs_tx_send_bytes@plt>
mov    $0x5,%edi
call   1080 <sleep@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <rcs_tx_send_bstring@plt>
mov    $0x2,%edi
call   1080 <sleep@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
call   1030 <rcs_tx_send_bytes@plt>
mov    $0x5,%edi
call   1080 <sleep@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <rcs_tx_send_bstring@plt>
mov    $0x2,%edi
call   1080 <sleep@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
call   1030 <rcs_tx_send_bytes@plt>
mov    %rbx,%rdi
call   1050 <rcs_tx_destroy@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.string = [33 x i8] c"00001000000100000010000001000000\00"
@__const.main.bytes = [4 x i8] c"\01\02\03\04"
@.str = [12 x i8] c"send frame\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [33 x i8]
%8 = alloca [4 x i8]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i8* @rcs_tx_init(i32 0)
store i8* %10, i8** %6
%11 = bitcast [33 x i8]* %7 to i8*
%12 = bitcast [4 x i8]* %8 to i8*
%13 = load i8*, i8** %6
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 0, i32* %3
br label %35
16: ; preds = %2
store i32 0, i32* %9
br label %17
17: ; preds = %20, %16
%18 = load i32, i32* %9
%19 = icmp slt i32 %18, 5
br i1 %19, label %20, label %32
20: ; preds = %17
%21 = call i32 @sleep(i32 5)
%22 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%23 = load i8*, i8** %6
%24 = getelementptr inbounds [33 x i8], [33 x i8]* %7, i64 0, i64 0
%25 = call i32 @rcs_tx_send_bstring(i8* %23, i8* %24)
%26 = call i32 @sleep(i32 2)
%27 = load i8*, i8** %6
%28 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%29 = call i32 @rcs_tx_send_bytes(i8* %27, i8* %28, i32 4)
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 1
store i32 %31, i32* %9
br label %17
32: ; preds = %17
%33 = load i8*, i8** %6
%34 = call i32 @rcs_tx_destroy(i8* %33)
store i32 0, i32* %3
br label %35
35: ; preds = %32, %15
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@__const.main.string = [33 x i8] c"00001000000100000010000001000000\00"
@str = [11 x i8] c"send frame\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [33 x i8]
%4 = alloca i32
%5 = tail call i8* @rcs_tx_init(i32 0)
%6 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
store i32 67305985, i32* %4
%8 = icmp eq i8* %5, null
br i1 %8, label %36, label %9
9: ; preds = %2
%10 = call i32 @sleep(i32 5)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%12 = call i32 @rcs_tx_send_bstring(i8* %5, i8* %6)
%13 = call i32 @sleep(i32 2)
%14 = call i32 @rcs_tx_send_bytes(i8* %5, i8* %7, i32 4)
%15 = call i32 @sleep(i32 5)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%17 = call i32 @rcs_tx_send_bstring(i8* %5, i8* %6)
%18 = call i32 @sleep(i32 2)
%19 = call i32 @rcs_tx_send_bytes(i8* %5, i8* %7, i32 4)
%20 = call i32 @sleep(i32 5)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%22 = call i32 @rcs_tx_send_bstring(i8* %5, i8* %6)
%23 = call i32 @sleep(i32 2)
%24 = call i32 @rcs_tx_send_bytes(i8* %5, i8* %7, i32 4)
%25 = call i32 @sleep(i32 5)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%27 = call i32 @rcs_tx_send_bstring(i8* %5, i8* %6)
%28 = call i32 @sleep(i32 2)
%29 = call i32 @rcs_tx_send_bytes(i8* %5, i8* %7, i32 4)
%30 = call i32 @sleep(i32 5)
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%32 = call i32 @rcs_tx_send_bstring(i8* %5, i8* %6)
%33 = call i32 @sleep(i32 2)
%34 = call i32 @rcs_tx_send_bytes(i8* %5, i8* %7, i32 4)
%35 = call i32 @rcs_tx_destroy(i8* %5)
br label %36
36: ; preds = %2, %9
ret i32 0
}