#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*/ scanf(char *, char *);
void recebeComando(char *comando) {
  printf("Digite o comando:\n");
  int i = 0;
  char c;
  do {
    scanf("%c", &c);
    if ((c == '\n') || (i == 50))
      c = '\0';
    comando[i] = c;
    if ((comando[i - 1] == ' ') && (c == ' '))
      i = i;
    else if (c == '\b')
      i = i;
    else if ((c == ' ') && (i == 0))
      i = i;
    else
      i++;
  } while (c != '\0');
}


x86 assembly (clang, -O0):
<recebeComando>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
lea    0xecd(%rip),%rdi
lea    -0xd(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0xd(%rbp),%eax
cmp    $0xa,%eax
je     1166 <recebeComando+0x46>
cmpl   $0x32,-0xc(%rbp)
jne    116a <recebeComando+0x4a>
movb   $0x0,-0xd(%rbp)
mov    -0xd(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    11aa <recebeComando+0x8a>
movsbl -0xd(%rbp),%eax
cmp    $0x20,%eax
jne    11aa <recebeComando+0x8a>
mov    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11f7 <recebeComando+0xd7>
movsbl -0xd(%rbp),%eax
cmp    $0x8,%eax
jne    11c2 <recebeComando+0xa2>
mov    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11f2 <recebeComando+0xd2>
movsbl -0xd(%rbp),%eax
cmp    $0x20,%eax
jne    11e4 <recebeComando+0xc4>
cmpl   $0x0,-0xc(%rbp)
jne    11e4 <recebeComando+0xc4>
mov    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11ed <recebeComando+0xcd>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11f2 <recebeComando+0xd2>
jmp    11f7 <recebeComando+0xd7>
jmp    11fc <recebeComando+0xdc>
movsbl -0xd(%rbp),%eax
cmp    $0x0,%eax
jne    113f <recebeComando+0x1f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recebeComando>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
lea    0xec0(%rip),%r14
lea    0x7(%rsp),%r15
jmp    1184 <recebeComando+0x64>
nopw   0x0(%rax,%rax,1)
movb   $0x0,0x7(%rsp)
xor    %eax,%eax
lea    0x1(%rbx),%ecx
test   %ebx,%ebx
mov    %ecx,%edx
cmove  %ebx,%edx
cmp    $0x20,%al
cmovne %ecx,%edx
cmp    $0x8,%al
cmove  %ebx,%edx
cmp    $0x20,%al
movslq %ebx,%rcx
mov    %al,(%r12,%rcx,1)
cmovne %edx,%ebx
cmpb   $0x20,-0x1(%r12,%rcx,1)
cmovne %edx,%ebx
test   %al,%al
je     119f <recebeComando+0x7f>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
movzbl 0x7(%rsp),%eax
cmp    $0xa,%al
je     1150 <recebeComando+0x30>
cmp    $0x32,%ebx
jne    1157 <recebeComando+0x37>
jmp    1150 <recebeComando+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Digite o comando:\0A\00"
@.str.1 = [3 x i8] c"%c\00"
define void @recebeComando(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
store i8* %0, i8** %2
%5 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %6
6: ; preds = %56, %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%8 = load i8, i8* %4
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 10
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 50
br i1 %13, label %14, label %15
14: ; preds = %11, %6
store i8 0, i8* %4
br label %15
15: ; preds = %14, %11
%16 = load i8, i8* %4
%17 = load i8*, i8** %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 %16, i8* %20
%21 = load i8*, i8** %2
%22 = load i32, i32* %3
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %21, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 32
br i1 %28, label %29, label %35
29: ; preds = %15
%30 = load i8, i8* %4
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 32
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = load i32, i32* %3
store i32 %34, i32* %3
br label %55
35: ; preds = %29, %15
%36 = load i8, i8* %4
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 8
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = load i32, i32* %3
store i32 %40, i32* %3
br label %54
41: ; preds = %35
%42 = load i8, i8* %4
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 32
br i1 %44, label %45, label %50
45: ; preds = %41
%46 = load i32, i32* %3
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = load i32, i32* %3
store i32 %49, i32* %3
br label %53
50: ; preds = %45, %41
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
store i32 %52, i32* %3
br label %53
53: ; preds = %50, %48
br label %54
54: ; preds = %53, %39
br label %55
55: ; preds = %54, %33
br label %56
56: ; preds = %55
%57 = load i8, i8* %4
%58 = sext i8 %57 to i32
%59 = icmp ne i32 %58, 0
br i1 %59, label %6, label %60
60: ; preds = %56
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%c\00"
@str = [18 x i8] c"Digite o comando:\00"
define void @recebeComando(i8* nocapture %0) {
%2 = alloca i8
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %12, %1
%5 = phi i32 [ 0, %1 ], [ %29, %12 ]
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 10
%9 = icmp eq i32 %5, 50
%10 = select i1 %8, i1 true, i1 %9
br i1 %10, label %11, label %12
11: ; preds = %4
store i8 0, i8* %2
br label %12
12: ; preds = %4, %11
%13 = phi i8 [ %7, %4 ], [ 0, %11 ]
%14 = sext i32 %5 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
store i8 %13, i8* %15
%16 = add nsw i32 %5, -1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 32
%21 = icmp eq i8 %13, 32
%22 = select i1 %20, i1 %21, i1 false
%23 = icmp eq i8 %13, 8
%24 = select i1 %22, i1 true, i1 %23
%25 = icmp eq i32 %5, 0
%26 = select i1 %21, i1 %25, i1 false
%27 = add nsw i32 %5, 1
%28 = select i1 %26, i32 0, i32 %27
%29 = select i1 %24, i32 %5, i32 %28
%30 = icmp eq i8 %13, 0
br i1 %30, label %31, label %4
31: ; preds = %12
ret void
}