#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*/ clean_stdin();
int /*<<< orphan*/ parse_command(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int start_state() {
  int flag = 1;
  char command[500];
  while (flag) {
    clean_stdin();
    scanf("%[^\n]s", command);
    printf("\nCommand: %s", command);
    if (!parse_command(command)) {
      printf("\nInvalid Syntax");
    }
  }
}


x86 assembly (clang, -O0):
<start_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%rsp
movl   $0x1,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11b3 <start_state+0x73>
mov    $0x0,%al
call   1040 <clean_stdin@plt>
lea    -0x200(%rbp),%rsi
lea    0xe8f(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x200(%rbp),%rsi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x200(%rbp),%rdi
call   1060 <parse_command@plt>
cmp    $0x0,%eax
jne    11ae <start_state+0x6e>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1152 <start_state+0x12>
mov    -0x4(%rbp),%eax
add    $0x200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_state>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1f8,%rsp
lea    0xeab(%rip),%r14
mov    %rsp,%rbx
lea    0xea8(%rip),%r15
lea    0xeae(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <clean_stdin@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1060 <parse_command@plt>
test   %eax,%eax
jne    1170 <start_state+0x30>
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1170 <start_state+0x30>

LLVM IR (-O0):
@.str = [7 x i8] c"%[^\0A]s\00"
@.str.1 = [13 x i8] c"\0ACommand: %s\00"
@.str.2 = [16 x i8] c"\0AInvalid Syntax\00"
define i32 @start_state() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [500 x i8]
store i32 1, i32* %2
br label %4
4: ; preds = %18, %0
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %19
7: ; preds = %4
%8 = call i32 (...) @clean_stdin()
%9 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%14 = call i32 @parse_command(i8* %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %7
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %7
br label %4
19: ; preds = %4
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str = [7 x i8] c"%[^\0A]s\00"
@.str.1 = [13 x i8] c"\0ACommand: %s\00"
@.str.2 = [16 x i8] c"\0AInvalid Syntax\00"
define i32 @start_state() {
%1 = alloca [500 x i8]
%2 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %11, %0
%4 = call i32 (...) @clean_stdin()
%5 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %2)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%7 = call i32 @parse_command(i8* %2)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %9, %3
br label %3
}