#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*/ fprintf(int /*<<< orphan*/, char *, char const *);
int sscanf(char const *, char *, unsigned int *, char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ *strstr(char const *, char *);
int parse_line(const char *line, unsigned int *address, char *instruction_name,
               char *instruction_args) {
  if (strstr(line, "illegal") != NULL || strstr(line, "<UNDEFINED>") != NULL) {
    fprintf(stderr, "NON-ASSEMBLY LINE: %s\n", line);
    return -1;
  }
  int parts = sscanf(line, "%*[ ]%x:\t%*[^\t]\t%[^\t]\t%[^\t\n;]", address,
                     instruction_name, instruction_args);
  if (parts != 3) {
    parts =
        sscanf(line, "%*[ ]%x:\t%*[^\t]\t%[^\t\n]", address, instruction_name);
    if (parts == 2 && (strcmp(instruction_name, "nop") == 0 ||
                       strcmp(instruction_name, "wfe") == 0 ||
                       strcmp(instruction_name, "wfi") == 0 ||
                       strcmp(instruction_name, "sev") == 0)) {
      strcpy(instruction_args, "");
      return 0;
    } else {
      fprintf(stderr, "NON-ASSEMBLY LINE: %s\n", line);
      return -1;
    }
  } else {
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
jne    119c <parse_line+0x4c>
mov    -0x10(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     11c1 <parse_line+0x71>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe64(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c8 <parse_line+0x178>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1060 <sscanf@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
je     12bc <parse_line+0x16c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe4a(%rip),%rsi
mov    $0x0,%al
call   1060 <sscanf@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x2,-0x2c(%rbp)
jne    1297 <parse_line+0x147>
mov    -0x20(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     127b <parse_line+0x12b>
mov    -0x20(%rbp),%rdi
lea    0xe2c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     127b <parse_line+0x12b>
mov    -0x20(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     127b <parse_line+0x12b>
mov    -0x20(%rbp),%rdi
lea    0xe00(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1297 <parse_line+0x147>
mov    -0x28(%rbp),%rdi
lea    0xda4(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    12c8 <parse_line+0x178>
mov    0x2d42(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd69(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c8 <parse_line+0x178>
jmp    12c1 <parse_line+0x171>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_line>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0xe95(%rip),%rsi
call   1070 <strstr@plt>
test   %rax,%rax
jne    1189 <parse_line+0x39>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     11b1 <parse_line+0x61>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe73(%rip),%rsi
xor    %ebp,%ebp
mov    %rbx,%rdi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1060 <sscanf@plt>
cmp    $0x3,%eax
je     11a6 <parse_line+0x56>
lea    0xe70(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1060 <sscanf@plt>
cmp    $0x2,%eax
jne    1189 <parse_line+0x39>
lea    0xe6b(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1242 <parse_line+0xf2>
lea    0xe5b(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1242 <parse_line+0xf2>
lea    0xe4b(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1242 <parse_line+0xf2>
lea    0xe3b(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1189 <parse_line+0x39>
lea    0xde1(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
xor    %ebp,%ebp
jmp    11a6 <parse_line+0x56>

LLVM IR (-O0):
@.str = [8 x i8] c"illegal\00"
@.str.1 = [12 x i8] c"<UNDEFINED>\00"
@stderr = global i32 0
@.str.2 = [23 x i8] c"NON-ASSEMBLY LINE: %s\0A\00"
@.str.3 = [30 x i8] c"%*[ ]%x:\09%*[^\09]\09%[^\09]\09%[^\09\0A;]\00"
@.str.4 = [23 x i8] c"%*[ ]%x:\09%*[^\09]\09%[^\09\0A]\00"
@.str.5 = [4 x i8] c"nop\00"
@.str.6 = [4 x i8] c"wfe\00"
@.str.7 = [4 x i8] c"wfi\00"
@.str.8 = [4 x i8] c"sev\00"
@.str.9 = [1 x i8] zeroinitializer
define i32 @parse_line(i8* %0, i32* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %6
store i32* %1, i32** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
%11 = load i8*, i8** %6
%12 = call i32* @strstr(i8* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i32* %12, null
br i1 %13, label %18, label %14
14: ; preds = %4
%15 = load i8*, i8** %6
%16 = call i32* @strstr(i8* %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %22
18: ; preds = %14, %4
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %6
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %20)
store i32 -1, i32* %5
br label %62
22: ; preds = %14
%23 = load i8*, i8** %6
%24 = load i32*, i32** %7
%25 = load i8*, i8** %8
%26 = load i8*, i8** %9
%27 = call i32 (i8*, i8*, i32*, i8*, ...) @sscanf(i8* %23, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32* %24, i8* %25, i8* %26)
store i32 %27, i32* %10
%28 = load i32, i32* %10
%29 = icmp ne i32 %28, 3
br i1 %29, label %30, label %60
30: ; preds = %22
%31 = load i8*, i8** %6
%32 = load i32*, i32** %7
%33 = load i8*, i8** %8
%34 = call i32 (i8*, i8*, i32*, i8*, ...) @sscanf(i8* %31, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32* %32, i8* %33)
store i32 %34, i32* %10
%35 = load i32, i32* %10
%36 = icmp eq i32 %35, 2
br i1 %36, label %37, label %56
37: ; preds = %30
%38 = load i8*, i8** %8
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %53, label %41
41: ; preds = %37
%42 = load i8*, i8** %8
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %53, label %45
45: ; preds = %41
%46 = load i8*, i8** %8
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %53, label %49
49: ; preds = %45
%50 = load i8*, i8** %8
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %49, %45, %41, %37
%54 = load i8*, i8** %9
%55 = call i32 @strcpy(i8* %54, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %5
br label %62
56: ; preds = %49, %30
%57 = load i32, i32* @stderr
%58 = load i8*, i8** %6
%59 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %58)
store i32 -1, i32* %5
br label %62
60: ; preds = %22
br label %61
61: ; preds = %60
store i32 0, i32* %5
br label %62
62: ; preds = %61, %56, %53, %18
%63 = load i32, i32* %5
ret i32 %63
}

LLVM IR (-O2):
@.str = [8 x i8] c"illegal\00"
@.str.1 = [12 x i8] c"<UNDEFINED>\00"
@stderr = global i32 0
@.str.2 = [23 x i8] c"NON-ASSEMBLY LINE: %s\0A\00"
@.str.3 = [30 x i8] c"%*[ ]%x:\09%*[^\09]\09%[^\09]\09%[^\09\0A;]\00"
@.str.4 = [23 x i8] c"%*[ ]%x:\09%*[^\09]\09%[^\09\0A]\00"
@.str.5 = [4 x i8] c"nop\00"
@.str.6 = [4 x i8] c"wfe\00"
@.str.7 = [4 x i8] c"wfi\00"
@.str.8 = [4 x i8] c"sev\00"
@.str.9 = [1 x i8] zeroinitializer
define i32 @parse_line(i8* %0, i32* %1, i8* %2, i8* %3) {
%5 = tail call i32* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = tail call i32* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %13, label %10
10: ; preds = %7, %4
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %36
13: ; preds = %7
%14 = tail call i32 (i8*, i8*, i32*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32* %1, i8* %2, i8* %3)
%15 = icmp eq i32 %14, 3
br i1 %15, label %36, label %16
16: ; preds = %13
%17 = tail call i32 (i8*, i8*, i32*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32* %1, i8* %2)
%18 = icmp eq i32 %17, 2
br i1 %18, label %19, label %33
19: ; preds = %16
%20 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %31, label %22
22: ; preds = %19
%23 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %22
%26 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28, %25, %22, %19
%32 = tail call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.9, i64 0, i64 0))
br label %36
33: ; preds = %28, %16
%34 = load i32, i32* @stderr
%35 = tail call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %36
36: ; preds = %31, %33, %13, %10
%37 = phi i32 [ -1, %10 ], [ 0, %31 ], [ -1, %33 ], [ 0, %13 ]
ret i32 %37
}