#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(int, int, char **);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ del(int, int, char **);
int /*<<< orphan*/ exit(int);
int openapi();
int /*<<< orphan*/ set(int, int, char **);
int /*<<< orphan*/ show(int, int, char **);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  int sock;
  if (argc < 2) {
    usage();
    exit(-1);
  }
  sock = openapi();
  if (strncmp(argv[1], "add", 3) == 0) {
    add(sock, (argc - 1), argv + 1);
    return (0);
  }
  if (strncmp(argv[1], "remove", 3) == 0) {
    del(sock, (argc - 1), argv + 1);
    return (0);
  }
  if (strncmp(argv[1], "set", 3) == 0) {
    set(sock, (argc - 1), argv + 1);
    return (0);
  }
  if (strncmp(argv[1], "show", 4) == 0) {
    show(sock, (argc - 1), argv + 1);
    return (0);
  }
  usage();
  close(sock);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11c1 <main+0x31>
mov    $0x0,%al
call   1070 <usage@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    $0x0,%al
call   10b0 <openapi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe26(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1210 <main+0x80>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
mov    -0x10(%rbp),%rdx
add    $0x8,%rdx
call   1040 <add@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f5 <main+0x165>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xde5(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1255 <main+0xc5>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
mov    -0x10(%rbp),%rdx
add    $0x8,%rdx
call   1080 <del@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f5 <main+0x165>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xda7(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    129a <main+0x10a>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
mov    -0x10(%rbp),%rdx
add    $0x8,%rdx
call   10a0 <set@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f5 <main+0x165>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd66(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12df <main+0x14f>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
mov    -0x10(%rbp),%rdx
add    $0x8,%rdx
call   1060 <show@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f5 <main+0x165>
mov    $0x0,%al
call   1070 <usage@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jle    1273 <main+0xe3>
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   10b0 <openapi@plt>
mov    %eax,%r14d
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
lea    0xe45(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1226 <main+0x96>
mov    (%rbx),%rdi
lea    0xe30(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1238 <main+0xa8>
mov    (%rbx),%rdi
lea    0xe1e(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     124a <main+0xba>
mov    (%rbx),%rdi
lea    0xe09(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     125c <main+0xcc>
xor    %eax,%eax
call   1070 <usage@plt>
mov    %r14d,%edi
call   1050 <close@plt>
jmp    126c <main+0xdc>
add    $0xffffffff,%ebp
mov    %r14d,%edi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1040 <add@plt>
jmp    126c <main+0xdc>
add    $0xffffffff,%ebp
mov    %r14d,%edi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1080 <del@plt>
jmp    126c <main+0xdc>
add    $0xffffffff,%ebp
mov    %r14d,%edi
mov    %ebp,%esi
mov    %rbx,%rdx
call   10a0 <set@plt>
jmp    126c <main+0xdc>
add    $0xffffffff,%ebp
mov    %r14d,%edi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1060 <show@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %eax,%eax
call   1070 <usage@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"add\00"
@.str.1 = [7 x i8] c"remove\00"
@.str.2 = [4 x i8] c"set\00"
@.str.3 = [5 x i8] c"show\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 (...) @usage()
%11 = call i32 @exit(i32 -1)
unreachable
12: ; preds = %2
%13 = call i32 (...) @openapi()
store i32 %13, i32* %6
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @strncmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %12
%20 = load i32, i32* %6
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 1
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = call i32 @add(i32 %20, i32 %22, i8** %24)
store i32 0, i32* %3
br label %69
26: ; preds = %12
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i64 @strncmp(i8* %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 3)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %26
%33 = load i32, i32* %6
%34 = load i32, i32* %4
%35 = sub nsw i32 %34, 1
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = call i32 @del(i32 %33, i32 %35, i8** %37)
store i32 0, i32* %3
br label %69
39: ; preds = %26
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i64 @strncmp(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %52
45: ; preds = %39
%46 = load i32, i32* %6
%47 = load i32, i32* %4
%48 = sub nsw i32 %47, 1
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = call i32 @set(i32 %46, i32 %48, i8** %50)
store i32 0, i32* %3
br label %69
52: ; preds = %39
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = call i64 @strncmp(i8* %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %65
58: ; preds = %52
%59 = load i32, i32* %6
%60 = load i32, i32* %4
%61 = sub nsw i32 %60, 1
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 1
%64 = call i32 @show(i32 %59, i32 %61, i8** %63)
store i32 0, i32* %3
br label %69
65: ; preds = %52
%66 = call i32 (...) @usage()
%67 = load i32, i32* %6
%68 = call i32 @close(i32 %67)
store i32 0, i32* %3
br label %69
69: ; preds = %65, %58, %45, %32, %19
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
@.str = [4 x i8] c"add\00"
@.str.1 = [7 x i8] c"remove\00"
@.str.2 = [4 x i8] c"set\00"
@.str.3 = [5 x i8] c"show\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 (...) @usage()
%6 = tail call i32 @exit(i32 -1)
unreachable
7: ; preds = %2
%8 = tail call i32 (...) @openapi()
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = add nsw i32 %0, -1
%15 = tail call i32 @add(i32 %8, i32 %14, i8** %9)
br label %40
16: ; preds = %7
%17 = load i8*, i8** %9
%18 = tail call i64 @strncmp(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 3)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = add nsw i32 %0, -1
%22 = tail call i32 @del(i32 %8, i32 %21, i8** %9)
br label %40
23: ; preds = %16
%24 = load i8*, i8** %9
%25 = tail call i64 @strncmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = add nsw i32 %0, -1
%29 = tail call i32 @set(i32 %8, i32 %28, i8** %9)
br label %40
30: ; preds = %23
%31 = load i8*, i8** %9
%32 = tail call i64 @strncmp(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = add nsw i32 %0, -1
%36 = tail call i32 @show(i32 %8, i32 %35, i8** %9)
br label %40
37: ; preds = %30
%38 = tail call i32 (...) @usage()
%39 = tail call i32 @close(i32 %8)
br label %40
40: ; preds = %37, %34, %27, %20, %13
ret i32 0
}