#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*/ add(char *, char *);
int /*<<< orphan*/ delete (char *);
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ next(char *);
int parse_int(char *);
int /*<<< orphan*/ previous(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ set(char *, int);
int /*<<< orphan*/ show(char *, int);
int /*<<< orphan*/ usage();
void subcommand(char command, int argc, char **argv) {
  switch (command) {
  case 'a':
    if (argc == 1)
      add(argv[0], NULL);
    else if (argc == 2)
      add(argv[0], argv[1]);
    else
      usage();
    break;
  case 'd':
    if (argc == 1)
      delete (argv[0]);
    else
      usage();
    break;
  case 'n':
    if (argc == 1)
      next(argv[0]);
    else
      usage();
    break;
  case 'p':
    if (argc == 1)
      previous(argv[0]);
    else
      usage();
    break;
  case 's':
    if (argc == 2) {
      int num;
      errno = 0;
      num = parse_int(argv[0]);
      if (errno != 0)
        err(1, "bad argument to '-s'");
      show(argv[1], num);
    } else {
      usage();
    }
    break;
  case 't':
    if (argc == 2) {
      int entry;
      errno = 0;
      entry = parse_int(argv[0]);
      if (errno != 0)
        err(1, "bad argument to '-t'");
      set(argv[1], entry);
    } else {
      usage();
    }
    break;
  case 'V':
    printf("reading %s\n", "0.1.0");
    break;
  default:
    usage();
  }
}


x86 assembly (clang, -O0):
<subcommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movsbl -0x1(%rbp),%eax
add    $0xffffffaa,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x1e,%eax
ja     138f <subcommand+0x1ef>
mov    -0x20(%rbp),%rax
lea    0xe2a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x1,-0x8(%rbp)
jne    11fe <subcommand+0x5e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <add@plt>
jmp    122d <subcommand+0x8d>
cmpl   $0x2,-0x8(%rbp)
jne    1221 <subcommand+0x81>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <add@plt>
jmp    1228 <subcommand+0x88>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    122d <subcommand+0x8d>
jmp    1396 <subcommand+0x1f6>
cmpl   $0x1,-0x8(%rbp)
jne    124d <subcommand+0xad>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <delete@plt>
jmp    1254 <subcommand+0xb4>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    1396 <subcommand+0x1f6>
cmpl   $0x1,-0x8(%rbp)
jne    1274 <subcommand+0xd4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <next@plt>
jmp    127b <subcommand+0xdb>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    1396 <subcommand+0x1f6>
cmpl   $0x1,-0x8(%rbp)
jne    129b <subcommand+0xfb>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <previous@plt>
jmp    12a2 <subcommand+0x102>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    1396 <subcommand+0x1f6>
cmpl   $0x2,-0x8(%rbp)
jne    1303 <subcommand+0x163>
mov    0x2d28(%rip),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <parse_int@plt>
mov    %eax,-0x14(%rbp)
mov    0x2d0c(%rip),%rax
cmpl   $0x0,(%rax)
je     12ee <subcommand+0x14e>
mov    $0x1,%edi
lea    0xd93(%rip),%rsi
call   1080 <err@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
call   1060 <show@plt>
jmp    130a <subcommand+0x16a>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    1396 <subcommand+0x1f6>
cmpl   $0x2,-0x8(%rbp)
jne    136b <subcommand+0x1cb>
mov    0x2cc0(%rip),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <parse_int@plt>
mov    %eax,-0x18(%rbp)
mov    0x2ca4(%rip),%rax
cmpl   $0x0,(%rax)
je     1356 <subcommand+0x1b6>
mov    $0x1,%edi
lea    0xd40(%rip),%rsi
call   1080 <err@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%esi
call   10c0 <set@plt>
jmp    1372 <subcommand+0x1d2>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    1396 <subcommand+0x1f6>
lea    0xd28(%rip),%rdi
lea    0xd2d(%rip),%rsi
call   1050 <printf@plt>
jmp    1396 <subcommand+0x1f6>
mov    $0x0,%al
call   1090 <usage@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<subcommand>:
push   %rbp
push   %r14
push   %rbx
add    $0xffffffaa,%edi
cmp    $0x1e,%edi
ja     12bf <subcommand+0x11f>
mov    %rdx,%rbx
lea    0xe46(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xedc(%rip),%rdi
lea    0xee1(%rip),%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <printf@plt>
cmp    $0x2,%esi
je     12ca <subcommand+0x12a>
cmp    $0x1,%esi
jne    12bf <subcommand+0x11f>
mov    (%rbx),%rdi
xor    %esi,%esi
jmp    12d1 <subcommand+0x131>
cmp    $0x1,%esi
jne    12bf <subcommand+0x11f>
mov    (%rbx),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    10a0 <delete@plt>
cmp    $0x1,%esi
jne    12bf <subcommand+0x11f>
mov    (%rbx),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <next@plt>
cmp    $0x1,%esi
jne    12bf <subcommand+0x11f>
mov    (%rbx),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <previous@plt>
cmp    $0x2,%esi
jne    12bf <subcommand+0x11f>
mov    0x2d9b(%rip),%r14
movl   $0x0,(%r14)
mov    (%rbx),%rdi
call   10b0 <parse_int@plt>
mov    %eax,%ebp
cmpl   $0x0,(%r14)
je     126d <subcommand+0xcd>
lea    0xe19(%rip),%rsi
mov    $0x1,%edi
call   1080 <err@plt>
mov    0x8(%rbx),%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <show@plt>
cmp    $0x2,%esi
jne    12bf <subcommand+0x11f>
mov    0x2d58(%rip),%r14
movl   $0x0,(%r14)
mov    (%rbx),%rdi
call   10b0 <parse_int@plt>
mov    %eax,%ebp
cmpl   $0x0,(%r14)
je     12b0 <subcommand+0x110>
lea    0xdeb(%rip),%rsi
mov    $0x1,%edi
call   1080 <err@plt>
mov    0x8(%rbx),%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    10c0 <set@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1090 <usage@plt>
mov    (%rbx),%rdi
mov    0x8(%rbx),%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <add@plt>

LLVM IR (-O0):
@errno = global i32 0
@.str = [21 x i8] c"bad argument to '-s'\00"
@.str.1 = [21 x i8] c"bad argument to '-t'\00"
@.str.2 = [12 x i8] c"reading %s\0A\00"
@.str.3 = [6 x i8] c"0.1.0\00"
define void @subcommand(i8 signext %0, i32 %1, i8** %2) {
%4 = alloca i8
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
store i8 %0, i8* %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
%9 = load i8, i8* %4
%10 = sext i8 %9 to i32
switch i32 %10, label %111 [
i32 97, label %11
i32 100, label %34
i32 110, label %45
i32 112, label %56
i32 115, label %67
i32 116, label %88
i32 86, label %109
]
11: ; preds = %3
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i8**, i8*** %6
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @add(i8* %17, i8* null)
br label %33
19: ; preds = %11
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = load i8**, i8*** %6
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = load i8**, i8*** %6
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @add(i8* %25, i8* %28)
br label %32
30: ; preds = %19
%31 = call i32 (...) @usage()
br label %32
32: ; preds = %30, %22
br label %33
33: ; preds = %32, %14
br label %113
34: ; preds = %3
%35 = load i32, i32* %5
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i8**, i8*** %6
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i32 @delete(i8* %40)
br label %44
42: ; preds = %34
%43 = call i32 (...) @usage()
br label %44
44: ; preds = %42, %37
br label %113
45: ; preds = %3
%46 = load i32, i32* %5
%47 = icmp eq i32 %46, 1
br i1 %47, label %48, label %53
48: ; preds = %45
%49 = load i8**, i8*** %6
%50 = getelementptr inbounds i8*, i8** %49, i64 0
%51 = load i8*, i8** %50
%52 = call i32 @next(i8* %51)
br label %55
53: ; preds = %45
%54 = call i32 (...) @usage()
br label %55
55: ; preds = %53, %48
br label %113
56: ; preds = %3
%57 = load i32, i32* %5
%58 = icmp eq i32 %57, 1
br i1 %58, label %59, label %64
59: ; preds = %56
%60 = load i8**, i8*** %6
%61 = getelementptr inbounds i8*, i8** %60, i64 0
%62 = load i8*, i8** %61
%63 = call i32 @previous(i8* %62)
br label %66
64: ; preds = %56
%65 = call i32 (...) @usage()
br label %66
66: ; preds = %64, %59
br label %113
67: ; preds = %3
%68 = load i32, i32* %5
%69 = icmp eq i32 %68, 2
br i1 %69, label %70, label %85
70: ; preds = %67
store i32 0, i32* @errno
%71 = load i8**, i8*** %6
%72 = getelementptr inbounds i8*, i8** %71, i64 0
%73 = load i8*, i8** %72
%74 = call i32 @parse_int(i8* %73)
store i32 %74, i32* %7
%75 = load i32, i32* @errno
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %70
%78 = call i32 @err(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %79
79: ; preds = %77, %70
%80 = load i8**, i8*** %6
%81 = getelementptr inbounds i8*, i8** %80, i64 1
%82 = load i8*, i8** %81
%83 = load i32, i32* %7
%84 = call i32 @show(i8* %82, i32 %83)
br label %87
85: ; preds = %67
%86 = call i32 (...) @usage()
br label %87
87: ; preds = %85, %79
br label %113
88: ; preds = %3
%89 = load i32, i32* %5
%90 = icmp eq i32 %89, 2
br i1 %90, label %91, label %106
91: ; preds = %88
store i32 0, i32* @errno
%92 = load i8**, i8*** %6
%93 = getelementptr inbounds i8*, i8** %92, i64 0
%94 = load i8*, i8** %93
%95 = call i32 @parse_int(i8* %94)
store i32 %95, i32* %8
%96 = load i32, i32* @errno
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %100
98: ; preds = %91
%99 = call i32 @err(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %100
100: ; preds = %98, %91
%101 = load i8**, i8*** %6
%102 = getelementptr inbounds i8*, i8** %101, i64 1
%103 = load i8*, i8** %102
%104 = load i32, i32* %8
%105 = call i32 @set(i8* %103, i32 %104)
br label %108
106: ; preds = %88
%107 = call i32 (...) @usage()
br label %108
108: ; preds = %106, %100
br label %113
109: ; preds = %3
%110 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %113
111: ; preds = %3
%112 = call i32 (...) @usage()
br label %113
113: ; preds = %111, %109, %108, %87, %66, %55, %44, %33
ret void
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [21 x i8] c"bad argument to '-s'\00"
@.str.1 = [21 x i8] c"bad argument to '-t'\00"
@.str.2 = [12 x i8] c"reading %s\0A\00"
@.str.3 = [6 x i8] c"0.1.0\00"
define void @subcommand(i8 signext %0, i32 %1, i8** nocapture %2) {
%4 = sext i8 %0 to i32
switch i32 %4, label %69 [
i32 97, label %5
i32 100, label %16
i32 110, label %23
i32 112, label %30
i32 115, label %37
i32 116, label %52
i32 86, label %67
]
5: ; preds = %3
switch i32 %1, label %14 [
i32 1, label %6
i32 2, label %9
]
6: ; preds = %5
%7 = load i8*, i8** %2
%8 = tail call i32 @add(i8* %7, i8* null)
br label %71
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8*, i8** %2, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @add(i8* %10, i8* %12)
br label %71
14: ; preds = %5
%15 = tail call i32 (...) @usage()
br label %71
16: ; preds = %3
%17 = icmp eq i32 %1, 1
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = load i8*, i8** %2
%20 = tail call i32 @delete(i8* %19)
br label %71
21: ; preds = %16
%22 = tail call i32 (...) @usage()
br label %71
23: ; preds = %3
%24 = icmp eq i32 %1, 1
br i1 %24, label %25, label %28
25: ; preds = %23
%26 = load i8*, i8** %2
%27 = tail call i32 @next(i8* %26)
br label %71
28: ; preds = %23
%29 = tail call i32 (...) @usage()
br label %71
30: ; preds = %3
%31 = icmp eq i32 %1, 1
br i1 %31, label %32, label %35
32: ; preds = %30
%33 = load i8*, i8** %2
%34 = tail call i32 @previous(i8* %33)
br label %71
35: ; preds = %30
%36 = tail call i32 (...) @usage()
br label %71
37: ; preds = %3
%38 = icmp eq i32 %1, 2
br i1 %38, label %39, label %50
39: ; preds = %37
store i32 0, i32* @errno
%40 = load i8*, i8** %2
%41 = tail call i32 @parse_int(i8* %40)
%42 = load i32, i32* @errno
%43 = icmp eq i32 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %39
%45 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %46
46: ; preds = %44, %39
%47 = getelementptr inbounds i8*, i8** %2, i64 1
%48 = load i8*, i8** %47
%49 = tail call i32 @show(i8* %48, i32 %41)
br label %71
50: ; preds = %37
%51 = tail call i32 (...) @usage()
br label %71
52: ; preds = %3
%53 = icmp eq i32 %1, 2
br i1 %53, label %54, label %65
54: ; preds = %52
store i32 0, i32* @errno
%55 = load i8*, i8** %2
%56 = tail call i32 @parse_int(i8* %55)
%57 = load i32, i32* @errno
%58 = icmp eq i32 %57, 0
br i1 %58, label %61, label %59
59: ; preds = %54
%60 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %61
61: ; preds = %59, %54
%62 = getelementptr inbounds i8*, i8** %2, i64 1
%63 = load i8*, i8** %62
%64 = tail call i32 @set(i8* %63, i32 %56)
br label %71
65: ; preds = %52
%66 = tail call i32 (...) @usage()
br label %71
67: ; preds = %3
%68 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %71
69: ; preds = %3
%70 = tail call i32 (...) @usage()
br label %71
71: ; preds = %61, %65, %46, %50, %32, %35, %25, %28, %18, %21, %6, %14, %9, %69, %67
ret void
}