#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 */
typedef int /*<<< orphan*/ line;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strchr(char *, char);
char *strtok(char *, char *);
int parse_line(char *line, unsigned buff[]) {
  char *instr = NULL;
  char *cmd = NULL;
  char *reg = NULL;
  char *arg1, *arg2, *arg3 = NULL;
  char *ls_reg = NULL;
  char *op_regs = NULL;
  char *val = NULL;
  if (strchr("!", *line)) {
    cmd = strtok(line, "!");
    printf("COMMAND : %s", cmd);
  }
  if (line[0] == '\t' || line[0] == ' ') {
    int i = 0;
    while (i < sizeof(line) / sizeof(char *)) {
      instr = strtok(line, " ");
      printf("INSTR : %s\n", instr);
      arg1 = strtok(NULL, " ");
      printf("ARG1 : %s\n", arg1);
      arg2 = strtok(NULL, " ");
      printf("ARG2 : %s\n", arg2);
      arg3 = strtok(NULL, " ");
      printf("ARG3 : %s\n", arg3);
      i++;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x8(%rbp),%rax
lea    0xe7d(%rip),%rdi
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     11b9 <parse_line+0x89>
mov    -0x8(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe4e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
je     11d9 <parse_line+0xa9>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1291 <parse_line+0x161>
movl   $0x0,-0x5c(%rbp)
movslq -0x5c(%rbp),%rax
cmp    $0x1,%rax
jae    128c <parse_line+0x15c>
mov    -0x8(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe04(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdf2(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xdec(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdce(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xdd3(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdaa(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
lea    0xdba(%rip),%rdi
call   1040 <printf@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11e0 <parse_line+0xb0>
jmp    1291 <parse_line+0x161>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_line>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movsbl (%rdi),%esi
lea    0xebf(%rip),%rdi
call   1030 <strchr@plt>
test   %rax,%rax
je     1169 <parse_line+0x39>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strtok@plt>
lea    0xea1(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    (%rbx),%al
cmp    $0x20,%al
je     1173 <parse_line+0x43>
cmp    $0x9,%al
jne    11df <parse_line+0xaf>
lea    0xe95(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strtok@plt>
lea    0xe85(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
lea    0xe78(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
lea    0xe6a(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
lea    0xe5c(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"!\00"
@.str.1 = [13 x i8] c"COMMAND : %s\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [12 x i8] c"INSTR : %s\0A\00"
@.str.4 = [11 x i8] c"ARG1 : %s\0A\00"
@.str.5 = [11 x i8] c"ARG2 : %s\0A\00"
@.str.6 = [11 x i8] c"ARG3 : %s\0A\00"
define i32 @parse_line(i8* %0, i32* nocapture readnone %1) {
%3 = load i8, i8* %0
%4 = tail call i64 @strchr(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8 signext %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %6, %2
%10 = load i8, i8* %0
switch i8 %10, label %20 [
i8 9, label %11
i8 32, label %11
]
11: ; preds = %9, %9
%12 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%14 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %14)
%16 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %16)
%18 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %11, %9
ret i32 0
}