#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 */
struct CONSOLE {
  int dummy;
};

/* Variables and functions */
scalar_t__ cmd_app(struct CONSOLE *, int *, char *);
int /*<<< orphan*/ cmd_cls(struct CONSOLE *);
int /*<<< orphan*/ cmd_dir(struct CONSOLE *);
int /*<<< orphan*/ cmd_exit(struct CONSOLE *, int *);
int /*<<< orphan*/ cmd_mem(struct CONSOLE *, int);
int /*<<< orphan*/ cmd_start(struct CONSOLE *, char *, int);
int /*<<< orphan*/ cmd_type(struct CONSOLE *, int *, char *);
int /*<<< orphan*/ cons_putstr0(struct CONSOLE *, char *);
scalar_t__ strcmp(char *, char *);
scalar_t__ strncmp(char *, char *, int);
void cons_runcmd(char *cmdline, struct CONSOLE *cons, int *fat, int memtotal) {
  if (strcmp(cmdline, "mem") == 0) {
    cmd_mem(cons, memtotal);
  } else if (strcmp(cmdline, "cls") == 0) {
    cmd_cls(cons);
  } else if (strcmp(cmdline, "dir") == 0) {
    cmd_dir(cons);
  } else if (strncmp(cmdline, "type ", 5) == 0) {
    cmd_type(cons, fat, cmdline);
  } else if (strcmp(cmdline, "exit") == 0) {
    cmd_exit(cons, fat);
  } else if (strncmp(cmdline, "start ", 6) == 0) {
    cmd_start(cons, cmdline, memtotal);
  } else if (cmdline[0] != 0) {
    if (cmd_app(cons, fat, cmdline) == 0) {
      cons_putstr0(cons, "Bad command.\n\n");
    }
  }
  return;
}


x86 assembly (clang, -O0):
<cons_runcmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    11e2 <cons_runcmd+0x42>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <cmd_mem@plt>
jmp    1325 <cons_runcmd+0x185>
mov    -0x8(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    120a <cons_runcmd+0x6a>
mov    -0x10(%rbp),%rdi
call   10a0 <cmd_cls@plt>
jmp    1320 <cons_runcmd+0x180>
mov    -0x8(%rbp),%rdi
lea    0xdf3(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1232 <cons_runcmd+0x92>
mov    -0x10(%rbp),%rdi
call   1040 <cmd_dir@plt>
jmp    131b <cons_runcmd+0x17b>
mov    -0x8(%rbp),%rdi
lea    0xdcf(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1267 <cons_runcmd+0xc7>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   10b0 <cmd_type@plt>
jmp    1316 <cons_runcmd+0x176>
mov    -0x8(%rbp),%rdi
lea    0xda0(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1293 <cons_runcmd+0xf3>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <cmd_exit@plt>
jmp    1311 <cons_runcmd+0x171>
mov    -0x8(%rbp),%rdi
lea    0xd79(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12c7 <cons_runcmd+0x127>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1070 <cmd_start@plt>
jmp    130c <cons_runcmd+0x16c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1307 <cons_runcmd+0x167>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1080 <cmd_app@plt>
cmp    $0x0,%rax
jne    1302 <cons_runcmd+0x162>
mov    -0x10(%rbp),%rdi
lea    0xd21(%rip),%rsi
call   10c0 <cons_putstr0@plt>
jmp    1307 <cons_runcmd+0x167>
jmp    130c <cons_runcmd+0x16c>
jmp    1311 <cons_runcmd+0x171>
jmp    1316 <cons_runcmd+0x176>
jmp    131b <cons_runcmd+0x17b>
jmp    1320 <cons_runcmd+0x180>
jmp    1325 <cons_runcmd+0x185>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cons_runcmd>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe47(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1270 <cons_runcmd+0xd0>
lea    0xe36(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1284 <cons_runcmd+0xe4>
lea    0xe22(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1296 <cons_runcmd+0xf6>
lea    0xe0e(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12a8 <cons_runcmd+0x108>
lea    0xdf7(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcmp@plt>
test   %rax,%rax
je     12c0 <cons_runcmd+0x120>
lea    0xde4(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12d5 <cons_runcmd+0x135>
cmpb   $0x0,(%rbx)
je     1265 <cons_runcmd+0xc5>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1080 <cmd_app@plt>
test   %rax,%rax
je     12ec <cons_runcmd+0x14c>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <cmd_mem@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <cmd_cls@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <cmd_dir@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    10b0 <cmd_type@plt>
mov    %r14,%rdi
mov    %r15,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <cmd_exit@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <cmd_start@plt>
lea    0xd2b(%rip),%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    10c0 <cons_putstr0@plt>

LLVM IR (-O0):
%struct.CONSOLE = type { i32 }
@.str = [4 x i8] c"mem\00"
@.str.1 = [4 x i8] c"cls\00"
@.str.2 = [4 x i8] c"dir\00"
@.str.3 = [6 x i8] c"type \00"
@.str.4 = [5 x i8] c"exit\00"
@.str.5 = [7 x i8] c"start \00"
@.str.6 = [15 x i8] c"Bad command.\0A\0A\00"
define void @cons_runcmd(i8* %0, %struct.CONSOLE* %1, i32* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca %struct.CONSOLE*
%7 = alloca i32*
%8 = alloca i32
store i8* %0, i8** %5
store %struct.CONSOLE* %1, %struct.CONSOLE** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%9 = load i8*, i8** %5
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %4
%13 = load %struct.CONSOLE*, %struct.CONSOLE** %6
%14 = load i32, i32* %8
%15 = call i32 @cmd_mem(%struct.CONSOLE* %13, i32 %14)
br label %78
16: ; preds = %4
%17 = load i8*, i8** %5
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load %struct.CONSOLE*, %struct.CONSOLE** %6
%22 = call i32 @cmd_cls(%struct.CONSOLE* %21)
br label %77
23: ; preds = %16
%24 = load i8*, i8** %5
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load %struct.CONSOLE*, %struct.CONSOLE** %6
%29 = call i32 @cmd_dir(%struct.CONSOLE* %28)
br label %76
30: ; preds = %23
%31 = load i8*, i8** %5
%32 = call i64 @strncmp(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 5)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %30
%35 = load %struct.CONSOLE*, %struct.CONSOLE** %6
%36 = load i32*, i32** %7
%37 = load i8*, i8** %5
%38 = call i32 @cmd_type(%struct.CONSOLE* %35, i32* %36, i8* %37)
br label %75
39: ; preds = %30
%40 = load i8*, i8** %5
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = load %struct.CONSOLE*, %struct.CONSOLE** %6
%45 = load i32*, i32** %7
%46 = call i32 @cmd_exit(%struct.CONSOLE* %44, i32* %45)
br label %74
47: ; preds = %39
%48 = load i8*, i8** %5
%49 = call i64 @strncmp(i8* %48, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 6)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %56
51: ; preds = %47
%52 = load %struct.CONSOLE*, %struct.CONSOLE** %6
%53 = load i8*, i8** %5
%54 = load i32, i32* %8
%55 = call i32 @cmd_start(%struct.CONSOLE* %52, i8* %53, i32 %54)
br label %73
56: ; preds = %47
%57 = load i8*, i8** %5
%58 = getelementptr inbounds i8, i8* %57, i64 0
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %72
62: ; preds = %56
%63 = load %struct.CONSOLE*, %struct.CONSOLE** %6
%64 = load i32*, i32** %7
%65 = load i8*, i8** %5
%66 = call i64 @cmd_app(%struct.CONSOLE* %63, i32* %64, i8* %65)
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %62
%69 = load %struct.CONSOLE*, %struct.CONSOLE** %6
%70 = call i32 @cons_putstr0(%struct.CONSOLE* %69, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %71
71: ; preds = %68, %62
br label %72
72: ; preds = %71, %56
br label %73
73: ; preds = %72, %51
br label %74
74: ; preds = %73, %43
br label %75
75: ; preds = %74, %34
br label %76
76: ; preds = %75, %27
br label %77
77: ; preds = %76, %20
br label %78
78: ; preds = %77, %12
ret void
}

LLVM IR (-O2):
%struct.CONSOLE = type { i32 }
@.str = [4 x i8] c"mem\00"
@.str.1 = [4 x i8] c"cls\00"
@.str.2 = [4 x i8] c"dir\00"
@.str.3 = [6 x i8] c"type \00"
@.str.4 = [5 x i8] c"exit\00"
@.str.5 = [7 x i8] c"start \00"
@.str.6 = [15 x i8] c"Bad command.\0A\0A\00"
define void @cons_runcmd(i8* %0, %struct.CONSOLE* %1, i32* %2, i32 %3) {
%5 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @cmd_mem(%struct.CONSOLE* %1, i32 %3)
br label %42
9: ; preds = %4
%10 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @cmd_cls(%struct.CONSOLE* %1)
br label %42
14: ; preds = %9
%15 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = tail call i32 @cmd_dir(%struct.CONSOLE* %1)
br label %42
19: ; preds = %14
%20 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 5)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 @cmd_type(%struct.CONSOLE* %1, i32* %2, i8* %0)
br label %42
24: ; preds = %19
%25 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = tail call i32 @cmd_exit(%struct.CONSOLE* %1, i32* %2)
br label %42
29: ; preds = %24
%30 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 6)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = tail call i32 @cmd_start(%struct.CONSOLE* %1, i8* %0, i32 %3)
br label %42
34: ; preds = %29
%35 = load i8, i8* %0
%36 = icmp eq i8 %35, 0
br i1 %36, label %42, label %37
37: ; preds = %34
%38 = tail call i64 @cmd_app(%struct.CONSOLE* %1, i32* %2, i8* %0)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = tail call i32 @cons_putstr0(%struct.CONSOLE* %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %42
42: ; preds = %12, %22, %32, %37, %40, %34, %27, %17, %7
ret void
}