#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_mem(struct CONSOLE *, 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 (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    0xe5e(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11c2 <cons_runcmd+0x42>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <cmd_mem@plt>
jmp    129b <cons_runcmd+0x11b>
mov    -0x8(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11ea <cons_runcmd+0x6a>
mov    -0x10(%rbp),%rdi
call   1080 <cmd_cls@plt>
jmp    1296 <cons_runcmd+0x116>
mov    -0x8(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1212 <cons_runcmd+0x92>
mov    -0x10(%rbp),%rdi
call   1040 <cmd_dir@plt>
jmp    1291 <cons_runcmd+0x111>
mov    -0x8(%rbp),%rdi
lea    0xdef(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1247 <cons_runcmd+0xc7>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1090 <cmd_type@plt>
jmp    128c <cons_runcmd+0x10c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1287 <cons_runcmd+0x107>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1060 <cmd_app@plt>
cmp    $0x0,%rax
jne    1282 <cons_runcmd+0x102>
mov    -0x10(%rbp),%rdi
lea    0xd95(%rip),%rsi
call   10a0 <cons_putstr0@plt>
jmp    1287 <cons_runcmd+0x107>
jmp    128c <cons_runcmd+0x10c>
jmp    1291 <cons_runcmd+0x111>
jmp    1296 <cons_runcmd+0x116>
jmp    129b <cons_runcmd+0x11b>
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    0xe67(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1207 <cons_runcmd+0x87>
lea    0xe5a(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     121b <cons_runcmd+0x9b>
lea    0xe4a(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     122d <cons_runcmd+0xad>
lea    0xe3a(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     123f <cons_runcmd+0xbf>
cmpb   $0x0,(%rbx)
je     11fc <cons_runcmd+0x7c>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1060 <cmd_app@plt>
test   %rax,%rax
je     1257 <cons_runcmd+0xd7>
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    1080 <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    1090 <cmd_type@plt>
lea    0xdb4(%rip),%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <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 = [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 %59
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 %58
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 %57
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 %56
39: ; preds = %30
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 0
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %55
45: ; preds = %39
%46 = load %struct.CONSOLE*, %struct.CONSOLE** %6
%47 = load i32*, i32** %7
%48 = load i8*, i8** %5
%49 = call i64 @cmd_app(%struct.CONSOLE* %46, i32* %47, i8* %48)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %45
%52 = load %struct.CONSOLE*, %struct.CONSOLE** %6
%53 = call i32 @cons_putstr0(%struct.CONSOLE* %52, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %54
54: ; preds = %51, %45
br label %55
55: ; preds = %54, %39
br label %56
56: ; preds = %55, %34
br label %57
57: ; preds = %56, %27
br label %58
58: ; preds = %57, %20
br label %59
59: ; preds = %58, %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 = [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 %32
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 %32
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 %32
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 %32
24: ; preds = %19
%25 = load i8, i8* %0
%26 = icmp eq i8 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %24
%28 = tail call i64 @cmd_app(%struct.CONSOLE* %1, i32* %2, i8* %0)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = tail call i32 @cons_putstr0(%struct.CONSOLE* %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %12, %22, %27, %30, %24, %17, %7
ret void
}