#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 EINVAL;
int /*<<< orphan*/ atoi(char *);
char *getenv(char *);
int lednames_serialize();
int lednames_store(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strcmp(char const *, char *);
int main(int argc, char *argv[]) {
  const char *action = argv[1];
  if (action) {
    if (0 == strcmp(action, "serialize")) {
      return lednames_serialize();
    } else if (0 == strcmp(action, "store")) {
      return lednames_store(atoi(argv[2]), atoi(getenv("CONTENT_LENGTH")));
    }
  }
  return -EINVAL;
}


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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1208 <main+0xb8>
mov    -0x18(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11aa <main+0x5a>
mov    $0x0,%al
call   1070 <lednames_serialize@plt>
mov    %eax,-0x4(%rbp)
jmp    1216 <main+0xc6>
mov    -0x18(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11fe <main+0xae>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
lea    0xe31(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%esi
call   1050 <lednames_store@plt>
mov    %eax,-0x4(%rbp)
jmp    1216 <main+0xc6>
jmp    1203 <main+0xb3>
jmp    1208 <main+0xb8>
xor    %eax,%eax
mov    0x2dcf(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rbx
test   %rbx,%rbx
je     1188 <main+0x38>
mov    %rsi,%r14
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     119b <main+0x4b>
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11a9 <main+0x59>
mov    0x2e51(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <lednames_serialize@plt>
mov    0x10(%r14),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
lea    0xe55(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %ebx,%edi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <lednames_store@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"serialize\00"
@.str.1 = [6 x i8] c"store\00"
@.str.2 = [15 x i8] c"CONTENT_LENGTH\00"
@EINVAL = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %32
12: ; preds = %2
%13 = load i8*, i8** %6
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 0, %14
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 (...) @lednames_serialize()
store i32 %17, i32* %3
br label %35
18: ; preds = %12
%19 = load i8*, i8** %6
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 0, %20
br i1 %21, label %22, label %30
22: ; preds = %18
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
%27 = call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @atoi(i8* %27)
%29 = call i32 @lednames_store(i32 %26, i32 %28)
store i32 %29, i32* %3
br label %35
30: ; preds = %18
br label %31
31: ; preds = %30
br label %32
32: ; preds = %31, %2
%33 = load i32, i32* @EINVAL
%34 = sub nsw i32 0, %33
store i32 %34, i32* %3
br label %35
35: ; preds = %32, %22, %16
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [10 x i8] c"serialize\00"
@.str.1 = [6 x i8] c"store\00"
@.str.2 = [15 x i8] c"CONTENT_LENGTH\00"
@EINVAL = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %21, label %6
6: ; preds = %2
%7 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 (...) @lednames_serialize()
br label %24
11: ; preds = %6
%12 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = tail call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i32 @atoi(i8* %18)
%20 = tail call i32 @lednames_store(i32 %17, i32 %19)
br label %24
21: ; preds = %11, %2
%22 = load i32, i32* @EINVAL
%23 = sub nsw i32 0, %22
br label %24
24: ; preds = %21, %14, %9
%25 = phi i32 [ %10, %9 ], [ %20, %14 ], [ %23, %21 ]
ret i32 %25
}