#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*/ _display_cpu_state();
int /*<<< orphan*/ cpu_do_step();
int /*<<< orphan*/ cpu_reset();
int /*<<< orphan*/ strcmp(char *, char *);
int _monitor_cmd_cpu_control(char *argv[], int argc) {
  if (argc < 1) {
    return -2;
  }
  char *control_cmd = argv[0];
  if (!strcmp(control_cmd, "disp")) {
    _display_cpu_state();
  } else if (!strcmp(control_cmd, "step")) {
    cpu_do_step();
    _display_cpu_state();
  } else if (!strcmp(control_cmd, "reset")) {
    cpu_reset();
  }
  return 0;
}


x86 assembly (clang, -O0):
<_monitor_cmd_cpu_control>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jge    1165 <_monitor_cmd_cpu_control+0x25>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11f2 <_monitor_cmd_cpu_control+0xb2>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1195 <_monitor_cmd_cpu_control+0x55>
mov    $0x0,%al
call   1030 <_display_cpu_state@plt>
jmp    11eb <_monitor_cmd_cpu_control+0xab>
mov    -0x20(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11c1 <_monitor_cmd_cpu_control+0x81>
mov    $0x0,%al
call   1060 <cpu_do_step@plt>
mov    $0x0,%al
call   1030 <_display_cpu_state@plt>
jmp    11e6 <_monitor_cmd_cpu_control+0xa6>
mov    -0x20(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11e1 <_monitor_cmd_cpu_control+0xa1>
mov    $0x0,%al
call   1050 <cpu_reset@plt>
jmp    11e6 <_monitor_cmd_cpu_control+0xa6>
jmp    11eb <_monitor_cmd_cpu_control+0xab>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_monitor_cmd_cpu_control>:
push   %rbx
test   %esi,%esi
jle    118e <_monitor_cmd_cpu_control+0x4e>
mov    (%rdi),%rbx
lea    0xeb1(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1195 <_monitor_cmd_cpu_control+0x55>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1199 <_monitor_cmd_cpu_control+0x59>
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    11a9 <_monitor_cmd_cpu_control+0x69>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <cpu_reset@plt>
jmp    11a9 <_monitor_cmd_cpu_control+0x69>
mov    $0xfffffffe,%ebx
jmp    11a9 <_monitor_cmd_cpu_control+0x69>
xor    %ebx,%ebx
jmp    11a2 <_monitor_cmd_cpu_control+0x62>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <cpu_do_step@plt>
xor    %eax,%eax
call   1030 <_display_cpu_state@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"disp\00"
@.str.1 = [5 x i8] c"step\00"
@.str.2 = [6 x i8] c"reset\00"
define i32 @_monitor_cmd_cpu_control(i8** %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
store i8** %0, i8*** %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 1
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 -2, i32* %3
br label %35
10: ; preds = %2
%11 = load i8**, i8*** %4
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %10
%18 = call i32 (...) @_display_cpu_state()
br label %34
19: ; preds = %10
%20 = load i8*, i8** %6
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %19
%24 = call i32 (...) @cpu_do_step()
%25 = call i32 (...) @_display_cpu_state()
br label %33
26: ; preds = %19
%27 = load i8*, i8** %6
%28 = call i32 @strcmp(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp ne i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %26
%31 = call i32 (...) @cpu_reset()
br label %32
32: ; preds = %30, %26
br label %33
33: ; preds = %32, %23
br label %34
34: ; preds = %33, %17
store i32 0, i32* %3
br label %35
35: ; preds = %34, %9
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [5 x i8] c"disp\00"
@.str.1 = [5 x i8] c"step\00"
@.str.2 = [6 x i8] c"reset\00"
define i32 @_monitor_cmd_cpu_control(i8** nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 1
br i1 %3, label %21, label %4
4: ; preds = %2
%5 = load i8*, i8** %0
%6 = tail call i32 @strcmp(i8* dereferenceable(1) %5, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 (...) @_display_cpu_state()
br label %21
10: ; preds = %4
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %5, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = tail call i32 (...) @cpu_do_step()
%15 = tail call i32 (...) @_display_cpu_state()
br label %21
16: ; preds = %10
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %5, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 (...) @cpu_reset()
br label %21
21: ; preds = %8, %16, %19, %13, %2
%22 = phi i32 [ -2, %2 ], [ 0, %13 ], [ 0, %19 ], [ 0, %16 ], [ 0, %8 ]
ret i32 %22
}