#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*/ ___delay_ms(int);
int /*<<< orphan*/ ___receive_char_usci_A1(char *);
int /*<<< orphan*/ ___send_char_usci_A1(int);
int /*<<< orphan*/ ___send_msg_usci_A1(char *, int);
char status_inicial(void) {
  char ini_state;
  char *ini_msg = "PRESSIONE M(MASTER) ou S(SLAVE): ";
  int msg_len = 33;
  ___send_msg_usci_A1(ini_msg, msg_len);
  for (;;) {
    ___receive_char_usci_A1(&ini_state);
    if (ini_state == 'm' || ini_state == 's') {
      ini_state = (ini_state == 'm' ? 'M' : 'S');
      break;
    } else
      continue;
  }
  ___delay_ms(3);
  ___send_char_usci_A1(ini_state);
  ___delay_ms(3);
  ___send_char_usci_A1(10);
  ___delay_ms(3);
  ___send_char_usci_A1(13);
  ___delay_ms(3);
  return ini_state;
}


x86 assembly (clang, -O0):
<status_inicial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x21,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <___send_msg_usci_A1@plt>
lea    -0x1(%rbp),%rdi
call   1060 <___receive_char_usci_A1@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x6d,%eax
je     1189 <status_inicial+0x49>
movsbl -0x1(%rbp),%eax
cmp    $0x73,%eax
jne    11a5 <status_inicial+0x65>
movsbl -0x1(%rbp),%edx
mov    $0x53,%eax
mov    $0x4d,%ecx
cmp    $0x6d,%edx
cmove  %ecx,%eax
mov    %al,-0x1(%rbp)
jmp    11aa <status_inicial+0x6a>
jmp    1166 <status_inicial+0x26>
mov    $0x3,%edi
call   1050 <___delay_ms@plt>
movsbl -0x1(%rbp),%edi
call   1030 <___send_char_usci_A1@plt>
mov    $0x3,%edi
call   1050 <___delay_ms@plt>
mov    $0xa,%edi
call   1030 <___send_char_usci_A1@plt>
mov    $0x3,%edi
call   1050 <___delay_ms@plt>
mov    $0xd,%edi
call   1030 <___send_char_usci_A1@plt>
mov    $0x3,%edi
call   1050 <___delay_ms@plt>
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<status_inicial>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
mov    $0x21,%esi
call   1040 <___send_msg_usci_A1@plt>
lea    0xf(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <___receive_char_usci_A1@plt>
movzbl 0xf(%rsp),%eax
cmp    $0x73,%al
je     1175 <status_inicial+0x35>
cmp    $0x6d,%al
jne    1160 <status_inicial+0x20>
cmp    $0x6d,%al
mov    $0x4d,%eax
mov    $0x53,%ecx
cmove  %eax,%ecx
mov    %cl,0xf(%rsp)
mov    $0x3,%edi
call   1050 <___delay_ms@plt>
movsbl 0xf(%rsp),%edi
call   1030 <___send_char_usci_A1@plt>
mov    $0x3,%edi
call   1050 <___delay_ms@plt>
mov    $0xa,%edi
call   1030 <___send_char_usci_A1@plt>
mov    $0x3,%edi
call   1050 <___delay_ms@plt>
mov    $0xd,%edi
call   1030 <___send_char_usci_A1@plt>
mov    $0x3,%edi
call   1050 <___delay_ms@plt>
mov    0xf(%rsp),%al
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [34 x i8] c"PRESSIONE M(MASTER) ou S(SLAVE): \00"
define signext i8 @status_inicial() {
%1 = alloca i8
%2 = alloca i8*
%3 = alloca i32
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8** %2
store i32 33, i32* %3
%4 = load i8*, i8** %2
%5 = load i32, i32* %3
%6 = call i32 @___send_msg_usci_A1(i8* %4, i32 %5)
br label %7
7: ; preds = %23, %0
%8 = call i32 @___receive_char_usci_A1(i8* %1)
%9 = load i8, i8* %1
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 109
br i1 %11, label %16, label %12
12: ; preds = %7
%13 = load i8, i8* %1
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 115
br i1 %15, label %16, label %23
16: ; preds = %12, %7
%17 = load i8, i8* %1
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 109
%20 = zext i1 %19 to i64
%21 = select i1 %19, i32 77, i32 83
%22 = trunc i32 %21 to i8
store i8 %22, i8* %1
br label %24
23: ; preds = %12
br label %7
24: ; preds = %16
%25 = call i32 @___delay_ms(i32 3)
%26 = load i8, i8* %1
%27 = sext i8 %26 to i32
%28 = call i32 @___send_char_usci_A1(i32 %27)
%29 = call i32 @___delay_ms(i32 3)
%30 = call i32 @___send_char_usci_A1(i32 10)
%31 = call i32 @___delay_ms(i32 3)
%32 = call i32 @___send_char_usci_A1(i32 13)
%33 = call i32 @___delay_ms(i32 3)
%34 = load i8, i8* %1
ret i8 %34
}

LLVM IR (-O2):
@.str = [34 x i8] c"PRESSIONE M(MASTER) ou S(SLAVE): \00"
define signext i8 @status_inicial() {
%1 = alloca i8
%2 = tail call i32 @___send_msg_usci_A1(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 33)
br label %3
3: ; preds = %3, %0
%4 = call i32 @___receive_char_usci_A1(i8* %1)
%5 = load i8, i8* %1
switch i8 %5, label %3 [
i8 115, label %6
i8 109, label %6
]
6: ; preds = %3, %3
%7 = icmp eq i8 %5, 109
%8 = select i1 %7, i8 77, i8 83
store i8 %8, i8* %1
%9 = call i32 @___delay_ms(i32 3)
%10 = load i8, i8* %1
%11 = sext i8 %10 to i32
%12 = call i32 @___send_char_usci_A1(i32 %11)
%13 = call i32 @___delay_ms(i32 3)
%14 = call i32 @___send_char_usci_A1(i32 10)
%15 = call i32 @___delay_ms(i32 3)
%16 = call i32 @___send_char_usci_A1(i32 13)
%17 = call i32 @___delay_ms(i32 3)
%18 = load i8, i8* %1
ret i8 %18
}