#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*/ serial_byte_rx();
int /*<<< orphan*/ serial_init(int);
int /*<<< orphan*/ serial_rx(char *, int);
int /*<<< orphan*/ serial_shut();
int /*<<< orphan*/ serial_tx(char *);
int c_entry(void) {
  char str[32];
  serial_init(115200);
  serial_byte_rx();
  serial_tx("Welcome to SysPlay\r\n");
  for (;;) {
    serial_tx("Cmd> ");
    serial_rx(str, 32);
    serial_tx("You entered: ");
    serial_tx(str);
    serial_tx("\r\n");
  }
  serial_shut();
  return 0;
}


x86 assembly (clang, -O0):
<c_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x1c200,%edi
call   1060 <serial_init@plt>
mov    $0x0,%al
call   1050 <serial_byte_rx@plt>
lea    0xea0(%rip),%rdi
call   1040 <serial_tx@plt>
lea    0xea9(%rip),%rdi
call   1040 <serial_tx@plt>
lea    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1030 <serial_rx@plt>
lea    0xe95(%rip),%rdi
call   1040 <serial_tx@plt>
lea    -0x20(%rbp),%rdi
call   1040 <serial_tx@plt>
lea    0xe77(%rip),%rdi
call   1040 <serial_tx@plt>
jmp    1165 <c_entry+0x25>

x86 assembly (clang, -O2):
<c_entry>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0x1c200,%edi
call   1060 <serial_init@plt>
xor    %eax,%eax
call   1050 <serial_byte_rx@plt>
lea    0xe9d(%rip),%rdi
call   1040 <serial_tx@plt>
lea    0xea6(%rip),%r14
mov    %rsp,%rbx
lea    0xea2(%rip),%r15
lea    0xe92(%rip),%r12
mov    %r14,%rdi
call   1040 <serial_tx@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1030 <serial_rx@plt>
mov    %r15,%rdi
call   1040 <serial_tx@plt>
mov    %rbx,%rdi
call   1040 <serial_tx@plt>
mov    %r12,%rdi
call   1040 <serial_tx@plt>
jmp    1180 <c_entry+0x40>

LLVM IR (-O0):
@.str = [21 x i8] c"Welcome to SysPlay\0D\0A\00"
@.str.1 = [6 x i8] c"Cmd> \00"
@.str.2 = [14 x i8] c"You entered: \00"
@.str.3 = [3 x i8] c"\0D\0A\00"
define i32 @c_entry() {
%1 = alloca [32 x i8]
%2 = call i32 @serial_init(i32 115200)
%3 = call i32 (...) @serial_byte_rx()
%4 = call i32 @serial_tx(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %5, %0
%6 = call i32 @serial_tx(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%8 = call i32 @serial_rx(i8* %7, i32 32)
%9 = call i32 @serial_tx(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%11 = call i32 @serial_tx(i8* %10)
%12 = call i32 @serial_tx(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %5
}

LLVM IR (-O2):
@.str = [21 x i8] c"Welcome to SysPlay\0D\0A\00"
@.str.1 = [6 x i8] c"Cmd> \00"
@.str.2 = [14 x i8] c"You entered: \00"
@.str.3 = [3 x i8] c"\0D\0A\00"
define i32 @c_entry() {
%1 = alloca [32 x i8]
%2 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @serial_init(i32 115200)
%4 = tail call i32 (...) @serial_byte_rx()
%5 = tail call i32 @serial_tx(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %6, %0
%7 = call i32 @serial_tx(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @serial_rx(i8* %2, i32 32)
%9 = call i32 @serial_tx(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @serial_tx(i8* %2)
%11 = call i32 @serial_tx(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %6
}