#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_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 (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    0xe4e(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    11d2 <cons_runcmd+0x42>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <cmd_mem@plt>
jmp    12dc <cons_runcmd+0x14c>
mov    -0x8(%rbp),%rdi
lea    0xe27(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    11fa <cons_runcmd+0x6a>
mov    -0x10(%rbp),%rdi
call   1090 <cmd_cls@plt>
jmp    12d7 <cons_runcmd+0x147>
mov    -0x8(%rbp),%rdi
lea    0xe03(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1222 <cons_runcmd+0x92>
mov    -0x10(%rbp),%rdi
call   1040 <cmd_dir@plt>
jmp    12d2 <cons_runcmd+0x142>
mov    -0x8(%rbp),%rdi
lea    0xddf(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1257 <cons_runcmd+0xc7>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   10a0 <cmd_type@plt>
jmp    12cd <cons_runcmd+0x13d>
mov    -0x8(%rbp),%rdi
lea    0xdb0(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1283 <cons_runcmd+0xf3>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <cmd_exit@plt>
jmp    12c8 <cons_runcmd+0x138>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12c3 <cons_runcmd+0x133>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1070 <cmd_app@plt>
cmp    $0x0,%rax
jne    12be <cons_runcmd+0x12e>
mov    -0x10(%rbp),%rdi
lea    0xd5e(%rip),%rsi
call   10b0 <cons_putstr0@plt>
jmp    12c3 <cons_runcmd+0x133>
jmp    12c8 <cons_runcmd+0x138>
jmp    12cd <cons_runcmd+0x13d>
jmp    12d2 <cons_runcmd+0x142>
jmp    12d7 <cons_runcmd+0x147>
jmp    12dc <cons_runcmd+0x14c>
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,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xe57(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     122b <cons_runcmd+0x9b>
lea    0xe4a(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     123f <cons_runcmd+0xaf>
lea    0xe3a(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1251 <cons_runcmd+0xc1>
lea    0xe2a(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1263 <cons_runcmd+0xd3>
lea    0xe17(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     127b <cons_runcmd+0xeb>
cmpb   $0x0,(%rbx)
je     1220 <cons_runcmd+0x90>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1070 <cmd_app@plt>
test   %rax,%rax
je     1290 <cons_runcmd+0x100>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <cmd_mem@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <cmd_cls@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <cmd_dir@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <cmd_type@plt>
mov    %r15,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <cmd_exit@plt>
lea    0xd80(%rip),%rsi
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    10b0 <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 = [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 %68
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 %67
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 %66
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 %65
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 %64
47: ; preds = %39
%48 = load i8*, i8** %5
%49 = getelementptr inbounds i8, i8* %48, i64 0
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %63
53: ; preds = %47
%54 = load %struct.CONSOLE*, %struct.CONSOLE** %6
%55 = load i32*, i32** %7
%56 = load i8*, i8** %5
%57 = call i64 @cmd_app(%struct.CONSOLE* %54, i32* %55, i8* %56)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %53
%60 = load %struct.CONSOLE*, %struct.CONSOLE** %6
%61 = call i32 @cons_putstr0(%struct.CONSOLE* %60, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %62
62: ; preds = %59, %53
br label %63
63: ; preds = %62, %47
br label %64
64: ; preds = %63, %43
br label %65
65: ; preds = %64, %34
br label %66
66: ; preds = %65, %27
br label %67
67: ; preds = %66, %20
br label %68
68: ; preds = %67, %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 = [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 %37
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 %37
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 %37
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 %37
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 %37
29: ; preds = %24
%30 = load i8, i8* %0
%31 = icmp eq i8 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %29
%33 = tail call i64 @cmd_app(%struct.CONSOLE* %1, i32* %2, i8* %0)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = tail call i32 @cons_putstr0(%struct.CONSOLE* %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %37
37: ; preds = %12, %22, %29, %35, %32, %27, %17, %7
ret void
}