// File: /workspace/github_c_makefile_star2_O0/bluecmd[P]fst-example/example.c
// Function: main
int main() {
  void* fst = fstWriterCreate("example.fst", /* use_compressed_hier */ 1);
  fstWriterSetPackType(fst, FST_WR_PT_LZ4);
  fstWriterSetTimescale(fst, FST_TS_NS);
#ifdef FST_WRITER_PARALLEL
  fstWriterSetParallelMode(fst, true);
#endif

  fstWriterSetComment(fst, "Created by bluecmd/fst-example");
  fstWriterSetDate(fst, "2020-09-10");

  const char *enumNames[] = { "STATE1", "STATE2", "STATE3" };
  const char *enumValues[] = { "001", "010", "100" };
  fstEnumHandle enumMap = fstWriterCreateEnumTable(
      fst, "ExampleEnum", /* elements */ 3, 0, enumNames, enumValues);

  fstHandle varInt, varEnum, varString, varEvent;

  // Create a tree like this:
  //
  //  Example
  //   |
  //   |-Function
  //   |
  //   |-Aliases
  //
  fstWriterSetScope(fst, FST_ST_VCD_PROGRAM, "Example", NULL);
  fstWriterSetScope(fst, FST_ST_VCD_FUNCTION, "Function", NULL);

  varInt    = fstWriterCreateVar(fst, FST_VT_VCD_INTEGER, FST_VD_INPUT, 8, "integer", /* alias */ 0);
  varString = fstWriterCreateVar(fst, FST_VT_GEN_STRING, FST_VD_OUTPUT, 0, "string", /* alias */ 0);
  varEvent  = fstWriterCreateVar(fst, FST_VT_VCD_EVENT, FST_VD_OUTPUT, 1, "event", /* alias */ 0);

  // Activate enum for next variable defined
  fstWriterEmitEnumTableRef(fst, enumMap);
  varEnum   = fstWriterCreateVar(fst, FST_VT_SV_ENUM, FST_VD_INPUT, 3, "enum", /* alias */ 0);

  fstWriterSetUpscope(fst);
  fstWriterSetScope(fst, FST_ST_VCD_PACKAGE, "Aliases", NULL);
  // Alias of the "integer" variable above
  fstWriterCreateVar(fst, FST_VT_VCD_INTEGER, FST_VD_INPUT, 8, "integer", varInt);

  fstWriterEmitTimeChange(fst, 0);
  fstWriterEmitValueChange(fst, varInt, "zzzzxxxx");
  fstWriterEmitTimeChange(fst, 1);
  for (int i = 2; i < 1000;) {
    fstWriterEmitValueChange32(fst, varInt, 8, 100 + i);
    fstWriterEmitValueChange32(fst, varEvent, 1, 1);
    fstWriterEmitVariableLengthValueChange(fst, varString, "str1", 4);
    fstWriterEmitValueChange(fst, varEnum, "001");
    fstWriterEmitTimeChange(fst, i++);
    fstWriterEmitValueChange32(fst, varInt, 8, 100 + i);
    fstWriterEmitVariableLengthValueChange(fst, varString, "str2", 4);
    fstWriterEmitValueChange(fst, varEnum, "010");
    fstWriterEmitTimeChange(fst, i++);
    fstWriterEmitValueChange32(fst, varInt, 8, 100 + i);
    fstWriterEmitVariableLengthValueChange(fst, varString, NULL, 0); // z-equivalent for strings
    fstWriterEmitValueChange(fst, varEnum, "100");
    fstWriterEmitTimeChange(fst, i++);
  }

  fstWriterClose(fst);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl $0x0, -0x4(%rbp)
leaq 0x27b3e(%rip), %rdi     # 0x2a004
movl $0x1, %esi
callq 0x4700
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0x82f0
movq -0x10(%rbp), %rdi
movl $0xfffffff7, %esi       # imm = 0xFFFFFFF7
callq 0x8070
movq -0x10(%rbp), %rdi
leaq 0x27b15(%rip), %rsi     # 0x2a010
callq 0x7f40
movq -0x10(%rbp), %rdi
leaq 0x27b24(%rip), %rsi     # 0x2a02f
callq 0x7a70
movq 0x2c889(%rip), %rax     # 0x2eda0
movq %rax, -0x30(%rbp)
movq 0x2c886(%rip), %rax     # 0x2eda8
movq %rax, -0x28(%rbp)
movq 0x2c883(%rip), %rax     # 0x2edb0
movq %rax, -0x20(%rbp)
movq 0x2c888(%rip), %rax     # 0x2edc0
movq %rax, -0x50(%rbp)
movq 0x2c885(%rip), %rax     # 0x2edc8
movq %rax, -0x48(%rbp)
movq 0x2c882(%rip), %rax     # 0x2edd0
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x30(%rbp), %r8
leaq -0x50(%rbp), %r9
leaq 0x27af6(%rip), %rsi     # 0x2a05b
movl $0x3, %edx
xorl %ecx, %ecx
callq 0x8cd0
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
movl $0xb, %esi
leaq 0x27ae3(%rip), %rdx     # 0x2a067
xorl %eax, %eax
movl %eax, %ecx
callq 0x8990
movq -0x10(%rbp), %rdi
movl $0x2, %esi
leaq 0x27ad2(%rip), %rdx     # 0x2a06f
xorl %eax, %eax
movl %eax, %ecx
callq 0x8990
movq -0x10(%rbp), %rdi
movl $0x1, %edx
movl $0x8, %ecx
leaq 0x29032(%rip), %r8      # 0x2b5ed
xorl %r9d, %r9d
movl %edx, %esi
callq 0x85f0
movl %eax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movl $0x15, %esi
movl $0x2, %edx
xorl %r9d, %r9d
leaq 0x27a98(%rip), %r8      # 0x2a078
movl %r9d, %ecx
callq 0x85f0
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
xorl %r9d, %r9d
movl $0x2, %edx
movl $0x1, %ecx
leaq 0x27a7c(%rip), %r8      # 0x2a07f
movl %r9d, %esi
callq 0x85f0
movl %eax, -0x64(%rbp)
movq -0x10(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x94c0
movq -0x10(%rbp), %rdi
movl $0x1c, %esi
movl $0x1, %edx
movl $0x3, %ecx
leaq 0x27a51(%rip), %r8      # 0x2a085
xorl %r9d, %r9d
callq 0x85f0
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8ac0
movq -0x10(%rbp), %rdi
movl $0xa, %esi
leaq 0x27a32(%rip), %rdx     # 0x2a08a
xorl %eax, %eax
movl %eax, %ecx
callq 0x8990
movq -0x10(%rbp), %rdi
movl -0x58(%rbp), %r9d
movl $0x1, %edx
movl $0x8, %ecx
leaq 0x28f73(%rip), %r8      # 0x2b5ed
movl %edx, %esi
callq 0x85f0
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5ed0
movq -0x10(%rbp), %rdi
movl -0x58(%rbp), %esi
leaq 0x279f6(%rip), %rdx     # 0x2a092
callq 0x6100
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x5ed0
movl $0x2, -0x68(%rbp)
cmpl $0x3e8, -0x68(%rbp)     # imm = 0x3E8
jge 0x27e0
movq -0x10(%rbp), %rdi
movl -0x58(%rbp), %esi
movl -0x68(%rbp), %ecx
addl $0x64, %ecx
movl $0x8, %edx
callq 0x9810
movq -0x10(%rbp), %rdi
movl -0x64(%rbp), %esi
movl $0x1, %ecx
movl %ecx, %edx
callq 0x9810
movq -0x10(%rbp), %rdi
movl -0x60(%rbp), %esi
leaq 0x279a0(%rip), %rdx     # 0x2a09b
movl $0x4, %ecx
callq 0x9dc0
movq -0x10(%rbp), %rdi
movl -0x5c(%rbp), %esi
leaq 0x2793c(%rip), %rdx     # 0x2a04f
callq 0x6100
movq -0x10(%rbp), %rdi
movl -0x68(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x68(%rbp)
movslq %eax, %rsi
callq 0x5ed0
movq -0x10(%rbp), %rdi
movl -0x58(%rbp), %esi
movl -0x68(%rbp), %ecx
addl $0x64, %ecx
movl $0x8, %edx
callq 0x9810
movq -0x10(%rbp), %rdi
movl -0x60(%rbp), %esi
leaq 0x2794c(%rip), %rdx     # 0x2a0a0
movl $0x4, %ecx
callq 0x9dc0
movq -0x10(%rbp), %rdi
movl -0x5c(%rbp), %esi
leaq 0x278e7(%rip), %rdx     # 0x2a053
callq 0x6100
movq -0x10(%rbp), %rdi
movl -0x68(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x68(%rbp)
movslq %eax, %rsi
callq 0x5ed0
movq -0x10(%rbp), %rdi
movl -0x58(%rbp), %esi
movl -0x68(%rbp), %ecx
addl $0x64, %ecx
movl $0x8, %edx
callq 0x9810
movq -0x10(%rbp), %rdi
movl -0x60(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x9dc0
movq -0x10(%rbp), %rdi
movl -0x5c(%rbp), %esi
leaq 0x27898(%rip), %rdx     # 0x2a057
callq 0x6100
movq -0x10(%rbp), %rdi
movl -0x68(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x68(%rbp)
movslq %eax, %rsi
callq 0x5ed0
jmp 0x26b6
movq -0x10(%rbp), %rdi
callq 0x4eb0
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)