#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*/ bye();
int /*<<< orphan*/ handle_create(int, int);
int /*<<< orphan*/ handle_destroy(int);
int /*<<< orphan*/ handle_get(int, int, int);
int /*<<< orphan*/ handle_list();
int /*<<< orphan*/ handle_print(int);
int /*<<< orphan*/ handle_set(int, int, int, float);
int /*<<< orphan*/ printf(char *, char const *);
int sscanf(char const *, char *, int *, ...);
int /*<<< orphan*/ strncmp(char const *, char *, int);
int /*<<< orphan*/ usage();
void handle_command(const char *cmdbuf) {
  int id;
  int r, c;
  float v;
  if (2 == sscanf(cmdbuf, "create %d %d", &r, &c)) {
    handle_create(r, c);
  } else if (1 == sscanf(cmdbuf, "destroy %d", &id)) {
    handle_destroy(id);
  } else if (!strncmp(cmdbuf, "list", 4)) {
    handle_list();
  } else if (2 == sscanf(cmdbuf, "print %d", &id)) {
    handle_print(id);
  } else if (3 == sscanf(cmdbuf, "get %d %d %d", &id, &r, &c)) {
    handle_get(id, r, c);
  } else if (4 == sscanf(cmdbuf, "set %d %d %d %f", &id, &r, &c, &v)) {
    handle_set(id, r, c, v);
  } else if (!strncmp(cmdbuf, "help", 4)) {
    usage();
  } else if (!strncmp(cmdbuf, "quit", 4)) {
    bye();
  } else {
    printf("ERROR: "
           "'%s' is not a valid command."
           "\n",
           cmdbuf);
  }
}


x86 assembly (clang, -O0):
<handle_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe39(%rip),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
mov    $0x0,%al
call   1070 <sscanf@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
jne    11f5 <handle_command+0x45>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1060 <handle_create@plt>
jmp    1393 <handle_command+0x1e3>
mov    -0x8(%rbp),%rdi
lea    0xe0d(%rip),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1070 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    1227 <handle_command+0x77>
mov    -0xc(%rbp),%edi
call   10b0 <handle_destroy@plt>
jmp    138e <handle_command+0x1de>
mov    -0x8(%rbp),%rdi
lea    0xde6(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1251 <handle_command+0xa1>
mov    $0x0,%al
call   10d0 <handle_list@plt>
jmp    1389 <handle_command+0x1d9>
mov    -0x8(%rbp),%rdi
lea    0xdc1(%rip),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1070 <sscanf@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
jne    1283 <handle_command+0xd3>
mov    -0xc(%rbp),%edi
call   10a0 <handle_print@plt>
jmp    1384 <handle_command+0x1d4>
mov    -0x8(%rbp),%rdi
lea    0xd98(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
mov    $0x0,%al
call   1070 <sscanf@plt>
mov    %eax,%ecx
mov    $0x3,%eax
cmp    %ecx,%eax
jne    12c3 <handle_command+0x113>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   10c0 <handle_get@plt>
jmp    137f <handle_command+0x1cf>
mov    -0x8(%rbp),%rdi
lea    0xd65(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
lea    -0x18(%rbp),%r9
mov    $0x0,%al
call   1070 <sscanf@plt>
mov    %eax,%ecx
mov    $0x4,%eax
cmp    %ecx,%eax
jne    130c <handle_command+0x15c>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
movss  -0x18(%rbp),%xmm0
call   1050 <handle_set@plt>
jmp    137a <handle_command+0x1ca>
mov    -0x8(%rbp),%rdi
lea    0xd2c(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1336 <handle_command+0x186>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    1375 <handle_command+0x1c5>
mov    -0x8(%rbp),%rdi
lea    0xd07(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1360 <handle_command+0x1b0>
mov    $0x0,%al
call   1080 <bye@plt>
jmp    1370 <handle_command+0x1c0>
mov    -0x8(%rbp),%rsi
lea    0xce2(%rip),%rdi
call   1040 <printf@plt>
jmp    1375 <handle_command+0x1c5>
jmp    137a <handle_command+0x1ca>
jmp    137f <handle_command+0x1cf>
jmp    1384 <handle_command+0x1d4>
jmp    1389 <handle_command+0x1d9>
jmp    138e <handle_command+0x1de>
jmp    1393 <handle_command+0x1e3>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_command>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xe41(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
xor    %eax,%eax
call   1070 <sscanf@plt>
cmp    $0x2,%eax
jne    11e7 <handle_command+0x37>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
call   1060 <handle_create@plt>
jmp    1320 <handle_command+0x170>
lea    0xe1f(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <sscanf@plt>
cmp    $0x1,%eax
jne    120d <handle_command+0x5d>
mov    (%rsp),%edi
call   10b0 <handle_destroy@plt>
jmp    1320 <handle_command+0x170>
lea    0xe04(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     124b <handle_command+0x9b>
lea    0xdf1(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <sscanf@plt>
cmp    $0x2,%eax
jne    1257 <handle_command+0xa7>
mov    (%rsp),%edi
call   10a0 <handle_print@plt>
jmp    1320 <handle_command+0x170>
xor    %eax,%eax
call   10d0 <handle_list@plt>
jmp    1320 <handle_command+0x170>
lea    0xdc8(%rip),%rsi
mov    %rsp,%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <sscanf@plt>
cmp    $0x3,%eax
jne    128f <handle_command+0xdf>
mov    (%rsp),%edi
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
call   10c0 <handle_get@plt>
jmp    1320 <handle_command+0x170>
lea    0xd9d(%rip),%rsi
mov    %rsp,%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
lea    0xc(%rsp),%r9
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <sscanf@plt>
cmp    $0x4,%eax
jne    12cf <handle_command+0x11f>
mov    (%rsp),%edi
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
movss  0xc(%rsp),%xmm0
call   1050 <handle_set@plt>
jmp    1320 <handle_command+0x170>
lea    0xd6d(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1310 <handle_command+0x160>
lea    0xd5a(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1319 <handle_command+0x169>
lea    0xd47(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
jmp    1320 <handle_command+0x170>
xor    %eax,%eax
call   1090 <usage@plt>
jmp    1320 <handle_command+0x170>
xor    %eax,%eax
call   1080 <bye@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"create %d %d\00"
@.str.1 = [11 x i8] c"destroy %d\00"
@.str.2 = [5 x i8] c"list\00"
@.str.3 = [9 x i8] c"print %d\00"
@.str.4 = [13 x i8] c"get %d %d %d\00"
@.str.5 = [16 x i8] c"set %d %d %d %f\00"
@.str.6 = [5 x i8] c"help\00"
@.str.7 = [5 x i8] c"quit\00"
@.str.8 = [37 x i8] c"ERROR: '%s' is not a valid command.\0A\00"
define void @handle_command(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5)
%9 = icmp eq i32 2, %8
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = call i32 @handle_create(i32 %11, i32 %12)
br label %75
14: ; preds = %1
%15 = load i8*, i8** %2
%16 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%17 = icmp eq i32 1, %16
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i32, i32* %3
%20 = call i32 @handle_destroy(i32 %19)
br label %74
21: ; preds = %14
%22 = load i8*, i8** %2
%23 = call i32 @strncmp(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%24 = icmp ne i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = call i32 (...) @handle_list()
br label %73
27: ; preds = %21
%28 = load i8*, i8** %2
%29 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%30 = icmp eq i32 2, %29
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i32, i32* %3
%33 = call i32 @handle_print(i32 %32)
br label %72
34: ; preds = %27
%35 = load i8*, i8** %2
%36 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %35, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%37 = icmp eq i32 3, %36
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = load i32, i32* %3
%40 = load i32, i32* %4
%41 = load i32, i32* %5
%42 = call i32 @handle_get(i32 %39, i32 %40, i32 %41)
br label %71
43: ; preds = %34
%44 = load i8*, i8** %2
%45 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %44, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32* %3, i32* %4, i32* %5, float* %6)
%46 = icmp eq i32 4, %45
br i1 %46, label %47, label %53
47: ; preds = %43
%48 = load i32, i32* %3
%49 = load i32, i32* %4
%50 = load i32, i32* %5
%51 = load float, float* %6
%52 = call i32 @handle_set(i32 %48, i32 %49, i32 %50, float %51)
br label %70
53: ; preds = %43
%54 = load i8*, i8** %2
%55 = call i32 @strncmp(i8* %54, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%56 = icmp ne i32 %55, 0
br i1 %56, label %59, label %57
57: ; preds = %53
%58 = call i32 (...) @usage()
br label %69
59: ; preds = %53
%60 = load i8*, i8** %2
%61 = call i32 @strncmp(i8* %60, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 4)
%62 = icmp ne i32 %61, 0
br i1 %62, label %65, label %63
63: ; preds = %59
%64 = call i32 (...) @bye()
br label %68
65: ; preds = %59
%66 = load i8*, i8** %2
%67 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %66)
br label %68
68: ; preds = %65, %63
br label %69
69: ; preds = %68, %57
br label %70
70: ; preds = %69, %47
br label %71
71: ; preds = %70, %38
br label %72
72: ; preds = %71, %31
br label %73
73: ; preds = %72, %25
br label %74
74: ; preds = %73, %18
br label %75
75: ; preds = %74, %10
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"create %d %d\00"
@.str.1 = [11 x i8] c"destroy %d\00"
@.str.2 = [5 x i8] c"list\00"
@.str.3 = [9 x i8] c"print %d\00"
@.str.4 = [13 x i8] c"get %d %d %d\00"
@.str.5 = [16 x i8] c"set %d %d %d %f\00"
@.str.6 = [5 x i8] c"help\00"
@.str.7 = [5 x i8] c"quit\00"
@.str.8 = [37 x i8] c"ERROR: '%s' is not a valid command.\0A\00"
define void @handle_command(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast float* %5 to i8*
%10 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = call i32 @handle_create(i32 %13, i32 %14)
br label %62
16: ; preds = %1
%17 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %2
%21 = call i32 @handle_destroy(i32 %20)
br label %62
22: ; preds = %16
%23 = call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 (...) @handle_list()
br label %62
27: ; preds = %22
%28 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%29 = icmp eq i32 %28, 2
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* %2
%32 = call i32 @handle_print(i32 %31)
br label %62
33: ; preds = %27
%34 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%35 = icmp eq i32 %34, 3
br i1 %35, label %36, label %41
36: ; preds = %33
%37 = load i32, i32* %2
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = call i32 @handle_get(i32 %37, i32 %38, i32 %39)
br label %62
41: ; preds = %33
%42 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32* %2, i32* %3, i32* %4, float* %5)
%43 = icmp eq i32 %42, 4
br i1 %43, label %44, label %50
44: ; preds = %41
%45 = load i32, i32* %2
%46 = load i32, i32* %3
%47 = load i32, i32* %4
%48 = load float, float* %5
%49 = call i32 @handle_set(i32 %45, i32 %46, i32 %47, float %48)
br label %62
50: ; preds = %41
%51 = call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = call i32 (...) @usage()
br label %62
55: ; preds = %50
%56 = call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 4)
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = call i32 (...) @bye()
br label %62
60: ; preds = %55
%61 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %0)
br label %62
62: ; preds = %19, %30, %44, %58, %60, %53, %36, %25, %12
ret void
}