#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_note(char *, char *, char *);
int /*<<< orphan*/ add_notes_from_stdin(int /*<<< orphan*/);
int /*<<< orphan*/ atoi(char *);
int delete_all(int /*<<< orphan*/);
int delete_note(char *, int /*<<< orphan*/);
int /*<<< orphan*/ export_html(char *, char *);
int /*<<< orphan*/ fail(char *);
int /*<<< orphan*/ free(char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ is_valid_date_format(char *, int /*<<< orphan*/);
scalar_t__ malloc(int);
int /*<<< orphan*/ optarg;
scalar_t__ opterr;
char optopt;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ replace_note(char *, int /*<<< orphan*/, char *);
int search_notes(char *, char *);
int search_regexp(char *, char *);
int show_categories();
int /*<<< orphan*/ show_latest(char *, int /*<<< orphan*/);
int /*<<< orphan*/ show_memo_file_path();
int /*<<< orphan*/ show_notes(int /*<<< orphan*/);
int /*<<< orphan*/ show_notes_tree(int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int strlen(char *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int c;
  int has_valid_options = 0;
  opterr = 0;
  if (argc == 1) {
    usage();
    return -1;
  }
  int ret = 0;
  int result;
  while ((c = getopt(argc, argv, "a:d:D:e:f:F:hi:l:Lo:pr:s:V")) != -1) {
    has_valid_options = 1;
    switch (c) {
    case 'a':
      if (argc < 4) {
        char *err = (char *)malloc((19 + strlen("content")) * sizeof(char));
        sprintf(err, "Error: -%s missing an argument %s\n", "a", "content");
        fail(err);
        free(err);
        usage();
        return 1;
      };
      if (argc > 4) {
        if (is_valid_date_format(argv[4], 0) == 0)
          add_note(argv[2], argv[3], argv[4]);
        else
          ret = 1;
      } else
        add_note(argv[2], argv[3], NULL);
      break;
    case 'd':
      if (argc < 4) {
        char *err = (char *)malloc((19 + strlen("ID")) * sizeof(char));
        sprintf(err, "Error: -%s missing an argument %s\n", "d", "ID");
        fail(err);
        free(err);
        usage();
        return 1;
      };
      if ((result = delete_note(argv[2], atoi(argv[3]))) != 0)
        ret = 2;
      break;
    case 'D':
      if ((result = delete_all(optarg)) != 0)
        ret = 2;
      break;
    case 'e':
      if (argc < 4) {
        char *err = (char *)malloc((19 + strlen("path")) * sizeof(char));
        sprintf(err, "Error: -%s missing an argument %s\n", "e", "path");
        fail(err);
        free(err);
        usage();
        return 1;
      };
      export_html(argv[2], argv[3]);
      break;
    case 'f':
      if (argc < 4) {
        char *err =
            (char *)malloc((19 + strlen("search string")) * sizeof(char));
        sprintf(err, "Error: -%s missing an argument %s\n", "f",
                "search string");
        fail(err);
        free(err);
        usage();
        return 1;
      };
      if ((result = search_notes(argv[2], argv[3])) == 0)
        ret = 2;
      break;
    case 'F':
      if (argc < 4) {
        char *err = (char *)malloc((19 + strlen("regex")) * sizeof(char));
        sprintf(err, "Error: -%s missing an argument %s\n", "F", "regex");
        fail(err);
        free(err);
        usage();
        return 1;
      };
      if ((result = search_regexp(argv[2], argv[3])) == 0)
        ret = 2;
      break;
    case 'h':
      usage();
      break;
    case 'i':
      add_notes_from_stdin(optarg);
      break;
    case 'o':
      show_notes_tree(optarg);
      break;
    case 'l':
      if (argc < 4) {
        char *err = (char *)malloc((19 + strlen("number")) * sizeof(char));
        sprintf(err, "Error: -%s missing an argument %s\n", "l", "number");
        fail(err);
        free(err);
        usage();
        return 1;
      };
      show_latest(argv[2], atoi(argv[3]));
      break;
    case 'L':
      if ((result = show_categories()) <= 0)
        ret = 2;
      break;
    case 'p':
      show_memo_file_path();
      break;
    case 'r':
      if (argc < 5) {
        char *err =
            (char *)malloc((19 + strlen("id, content or date")) * sizeof(char));
        sprintf(err, "Error: -%s missing an argument %s\n", "r",
                "id, content or date");
        fail(err);
        free(err);
        usage();
        return 1;
      };
      replace_note(argv[2], atoi(argv[3]), argv[4]);
      break;
    case 's':
      show_notes(optarg);
      break;
    case 'V':
      printf("Stamp version %.1f\n", 1.4);
      break;
    case '?': {
      char *copts = "adDefFilors";
      int coptfound = 0;
      for (int i = 0; i < strlen(copts); i++) {
        if (copts[i] == optopt) {
          coptfound = 1;
          printf("Error: -%c missing an argument category\n", optopt);
          usage();
          ret = 1;
          break;
        }
      }
      if (coptfound == 0) {
        printf("invalid option '%c', see stamp -h for help\n", optopt);
        ret = 1;
      }
      break;
    }
    }
  }
  if (argc > 1 && !has_valid_options)
    printf("invalid input, see stamp -h for help\n");
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    0x2d39(%rip),%rax
movq   $0x0,(%rax)
cmpl   $0x1,-0x8(%rbp)
jne    12bb <main+0x4b>
mov    $0x0,%al
call   1130 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1934 <main+0x6c4>
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe0c(%rip),%rdx
call   1140 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     190c <main+0x69c>
movl   $0x1,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x70(%rbp)
sub    $0x34,%eax
ja     1907 <main+0x697>
mov    -0x70(%rbp),%rax
lea    0xd00(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x4,-0x8(%rbp)
jge    137e <main+0x10e>
lea    0xdd5(%rip),%rdi
call   10a0 <strlen@plt>
add    $0x13,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1120 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xdb9(%rip),%rsi
lea    0xdd5(%rip),%rdx
lea    0xda3(%rip),%rcx
call   1160 <sprintf@plt>
mov    -0x28(%rbp),%rdi
call   1070 <fail@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
mov    $0x0,%al
call   1130 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1934 <main+0x6c4>
cmpl   $0x4,-0x8(%rbp)
jle    13ce <main+0x15e>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
xor    %esi,%esi
call   1170 <is_valid_date_format@plt>
cmp    $0x0,%eax
jne    13c2 <main+0x152>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
call   10e0 <add_note@plt>
jmp    13c9 <main+0x159>
movl   $0x1,-0x1c(%rbp)
jmp    13e7 <main+0x177>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   10e0 <add_note@plt>
jmp    1907 <main+0x697>
cmpl   $0x4,-0x8(%rbp)
jge    1459 <main+0x1e9>
lea    0xd27(%rip),%rdi
call   10a0 <strlen@plt>
add    $0x13,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1120 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xcde(%rip),%rsi
lea    0xcff(%rip),%rdx
lea    0xcf5(%rip),%rcx
call   1160 <sprintf@plt>
mov    -0x30(%rbp),%rdi
call   1070 <fail@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    $0x0,%al
call   1130 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1934 <main+0x6c4>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1150 <atoi@plt>
mov    -0x78(%rbp),%rdi
mov    %eax,%esi
call   10f0 <delete_note@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
je     1490 <main+0x220>
movl   $0x2,-0x1c(%rbp)
jmp    1907 <main+0x697>
mov    0x2b5c(%rip),%rax
mov    (%rax),%edi
call   1050 <delete_all@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
je     14b6 <main+0x246>
movl   $0x2,-0x1c(%rbp)
jmp    1907 <main+0x697>
cmpl   $0x4,-0x8(%rbp)
jge    1528 <main+0x2b8>
lea    0xc5d(%rip),%rdi
call   10a0 <strlen@plt>
add    $0x13,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1120 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xc0f(%rip),%rsi
lea    0xc6a(%rip),%rdx
lea    0xc2b(%rip),%rcx
call   1160 <sprintf@plt>
mov    -0x38(%rbp),%rdi
call   1070 <fail@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    $0x0,%al
call   1130 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1934 <main+0x6c4>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   10c0 <export_html@plt>
jmp    1907 <main+0x697>
cmpl   $0x4,-0x8(%rbp)
jge    15af <main+0x33f>
lea    0xbdb(%rip),%rdi
call   10a0 <strlen@plt>
add    $0x13,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1120 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xb88(%rip),%rsi
lea    0xbbe(%rip),%rdx
lea    0xba9(%rip),%rcx
call   1160 <sprintf@plt>
mov    -0x40(%rbp),%rdi
call   1070 <fail@plt>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    $0x0,%al
call   1130 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1934 <main+0x6c4>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1100 <search_notes@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jne    15d7 <main+0x367>
movl   $0x2,-0x1c(%rbp)
jmp    1907 <main+0x697>
cmpl   $0x4,-0x8(%rbp)
jge    1649 <main+0x3d9>
lea    0xb51(%rip),%rdi
call   10a0 <strlen@plt>
add    $0x13,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1120 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
lea    0xaee(%rip),%rsi
lea    0xb2c(%rip),%rdx
lea    0xb1f(%rip),%rcx
call   1160 <sprintf@plt>
mov    -0x48(%rbp),%rdi
call   1070 <fail@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
mov    $0x0,%al
call   1130 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1934 <main+0x6c4>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1060 <search_regexp@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jne    1671 <main+0x401>
movl   $0x2,-0x1c(%rbp)
jmp    1907 <main+0x697>
mov    $0x0,%al
call   1130 <usage@plt>
jmp    1907 <main+0x697>
mov    0x296f(%rip),%rax
mov    (%rax),%edi
call   1080 <add_notes_from_stdin@plt>
jmp    1907 <main+0x697>
mov    0x295c(%rip),%rax
mov    (%rax),%edi
call   1090 <show_notes_tree@plt>
jmp    1907 <main+0x697>
cmpl   $0x4,-0x8(%rbp)
jge    1715 <main+0x4a5>
lea    0xa8d(%rip),%rdi
call   10a0 <strlen@plt>
add    $0x13,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1120 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
lea    0xa22(%rip),%rsi
lea    0xa69(%rip),%rdx
lea    0xa5b(%rip),%rcx
call   1160 <sprintf@plt>
mov    -0x50(%rbp),%rdi
call   1070 <fail@plt>
mov    -0x50(%rbp),%rdi
call   1040 <free@plt>
mov    $0x0,%al
call   1130 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1934 <main+0x6c4>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1150 <atoi@plt>
mov    -0x80(%rbp),%rdi
mov    %eax,%esi
call   1180 <show_latest@plt>
jmp    1907 <main+0x697>
mov    $0x0,%al
call   1190 <show_categories@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jg     1758 <main+0x4e8>
movl   $0x2,-0x1c(%rbp)
jmp    1907 <main+0x697>
mov    $0x0,%al
call   1110 <show_memo_file_path@plt>
jmp    1907 <main+0x697>
cmpl   $0x5,-0x8(%rbp)
jge    17d6 <main+0x566>
lea    0x9d5(%rip),%rdi
call   10a0 <strlen@plt>
add    $0x13,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1120 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
lea    0x961(%rip),%rsi
lea    0x9a6(%rip),%rdx
lea    0x9a3(%rip),%rcx
call   1160 <sprintf@plt>
mov    -0x58(%rbp),%rdi
call   1070 <fail@plt>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    $0x0,%al
call   1130 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1934 <main+0x6c4>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x88(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1150 <atoi@plt>
mov    -0x88(%rbp),%rdi
mov    %eax,%esi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
call   1030 <replace_note@plt>
jmp    1907 <main+0x697>
mov    0x27e4(%rip),%rax
mov    (%rax),%edi
call   10b0 <show_notes@plt>
jmp    1907 <main+0x697>
lea    0x93c(%rip),%rdi
movsd  0x7d1(%rip),%xmm0
mov    $0x1,%al
call   10d0 <printf@plt>
jmp    1907 <main+0x697>
lea    0x935(%rip),%rax
mov    %rax,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x60(%rbp),%rdi
call   10a0 <strlen@plt>
mov    %eax,%ecx
mov    -0x8c(%rbp),%eax
cmp    %ecx,%eax
jge    18d9 <main+0x669>
mov    -0x60(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    0x2757(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    18c6 <main+0x656>
movl   $0x1,-0x64(%rbp)
mov    0x273e(%rip),%rax
movsbl (%rax),%esi
lea    0x8d7(%rip),%rdi
mov    $0x0,%al
call   10d0 <printf@plt>
mov    $0x0,%al
call   1130 <usage@plt>
movl   $0x1,-0x1c(%rbp)
jmp    18d9 <main+0x669>
jmp    18cb <main+0x65b>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1854 <main+0x5e4>
cmpl   $0x0,-0x64(%rbp)
jne    1902 <main+0x692>
mov    0x26f6(%rip),%rax
movsbl (%rax),%esi
lea    0x8b8(%rip),%rdi
mov    $0x0,%al
call   10d0 <printf@plt>
movl   $0x1,-0x1c(%rbp)
jmp    1907 <main+0x697>
jmp    12c2 <main+0x52>
cmpl   $0x1,-0x8(%rbp)
jle    192e <main+0x6be>
cmpl   $0x0,-0x18(%rbp)
jne    192e <main+0x6be>
lea    0x8b1(%rip),%rdi
mov    $0x0,%al
call   10d0 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2d3e(%rip),%rax
movq   $0x0,(%rax)
cmp    $0x1,%edi
jne    12b0 <main+0x30>
xor    %eax,%eax
call   1140 <usage@plt>
mov    $0xffffffff,%r13d
jmp    16f9 <main+0x479>
mov    %rsi,%r12
mov    %edi,%r14d
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    12d0 <main+0x50>
xor    %eax,%eax
call   1120 <show_memo_file_path@plt>
mov    %r13d,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r15d,%ebx
mov    %ebp,%r13d
mov    %r14d,%edi
mov    %r12,%rsi
lea    0xef9(%rip),%rdx
call   1150 <getopt@plt>
mov    $0x1,%r15b
add    $0x1,%eax
cmp    $0x74,%eax
ja     12d0 <main+0x50>
lea    0xd0e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
mov    %r13d,%ebp
jmp    *%rax
lea    0xf6a(%rip),%rbp
mov    %rbp,%rdi
call   10b0 <strlen@plt>
test   %eax,%eax
mov    0x2cc2(%rip),%r13
jle    1351 <main+0xd1>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl (%rbx,%rbp,1),%esi
cmp    0x0(%r13),%sil
je     1563 <main+0x2e3>
add    $0x1,%rbx
mov    %rbp,%rdi
call   10b0 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1330 <main+0xb0>
movsbl 0x0(%r13),%esi
lea    0xf4f(%rip),%rdi
xor    %eax,%eax
call   10e0 <printf@plt>
mov    $0x1,%ebp
jmp    12d0 <main+0x50>
xor    %eax,%eax
call   11a0 <show_categories@plt>
test   %eax,%eax
mov    $0x2,%eax
cmovle %eax,%r13d
mov    %r13d,%ebp
jmp    12d0 <main+0x50>
xor    %eax,%eax
call   1140 <usage@plt>
mov    %r13d,%ebp
jmp    12d0 <main+0x50>
mov    0x2c5a(%rip),%rax
mov    (%rax),%edi
call   1090 <add_notes_from_stdin@plt>
mov    %r13d,%ebp
jmp    12d0 <main+0x50>
mov    0x2c44(%rip),%rax
mov    (%rax),%edi
call   1050 <delete_all@plt>
jmp    1447 <main+0x1c7>
cmp    $0x3,%r14d
jle    15a4 <main+0x324>
mov    0x10(%r12),%rdi
mov    0x18(%r12),%rsi
call   1070 <search_regexp@plt>
jmp    1494 <main+0x214>
mov    $0x1,%r15b
lea    0xe7b(%rip),%rdi
movsd  0xc10(%rip),%xmm0
mov    $0x1,%al
call   10e0 <printf@plt>
mov    %r13d,%ebp
jmp    12d0 <main+0x50>
cmp    $0x3,%r14d
jle    15d1 <main+0x351>
cmp    $0x4,%r14d
jne    152e <main+0x2ae>
mov    0x10(%r12),%rdi
mov    0x18(%r12),%rsi
xor    %edx,%edx
jmp    1556 <main+0x2d6>
cmp    $0x3,%r14d
jle    15fe <main+0x37e>
mov    0x10(%r12),%rbx
mov    0x18(%r12),%rdi
call   1160 <atoi@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1100 <delete_note@plt>
test   %eax,%eax
mov    $0x2,%eax
cmovne %eax,%r13d
mov    %r13d,%ebp
jmp    12d0 <main+0x50>
cmp    $0x3,%r14d
jle    162b <main+0x3ab>
mov    0x10(%r12),%rdi
mov    0x18(%r12),%rsi
call   10d0 <export_html@plt>
mov    %r13d,%ebp
jmp    12d0 <main+0x50>
cmp    $0x3,%r14d
jle    1655 <main+0x3d5>
mov    0x10(%r12),%rdi
mov    0x18(%r12),%rsi
call   1110 <search_notes@plt>
test   %eax,%eax
mov    $0x2,%eax
cmove  %eax,%r13d
mov    %r13d,%ebp
jmp    12d0 <main+0x50>
cmp    $0x3,%r14d
jle    167f <main+0x3ff>
mov    0x10(%r12),%rbx
mov    0x18(%r12),%rdi
call   1160 <atoi@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1190 <show_latest@plt>
mov    %r13d,%ebp
jmp    12d0 <main+0x50>
mov    0x2b1f(%rip),%rax
mov    (%rax),%edi
call   10a0 <show_notes_tree@plt>
mov    %r13d,%ebp
jmp    12d0 <main+0x50>
cmp    $0x4,%r14d
jle    16a9 <main+0x429>
mov    0x10(%r12),%rbx
mov    0x18(%r12),%rdi
call   1160 <atoi@plt>
mov    0x20(%r12),%rdx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <replace_note@plt>
mov    %r13d,%ebp
jmp    12d0 <main+0x50>
mov    0x2ad9(%rip),%rax
mov    (%rax),%edi
call   10c0 <show_notes@plt>
mov    %r13d,%ebp
jmp    12d0 <main+0x50>
mov    0x20(%r12),%rdi
xor    %esi,%esi
call   1180 <is_valid_date_format@plt>
mov    $0x1,%ebp
test   %eax,%eax
jne    12d0 <main+0x50>
mov    0x10(%r12),%rdi
mov    0x18(%r12),%rsi
mov    0x20(%r12),%rdx
call   10f0 <add_note@plt>
mov    %r13d,%ebp
jmp    12d0 <main+0x50>
lea    0xd19(%rip),%rdi
xor    %eax,%eax
call   10e0 <printf@plt>
xor    %eax,%eax
call   1140 <usage@plt>
mov    $0x1,%ebp
jmp    12d0 <main+0x50>
cmp    $0x2,%r14d
setl   %al
or     %bl,%al
test   $0x1,%al
jne    16f9 <main+0x479>
lea    0xd3e(%rip),%rdi
call   1060 <puts@plt>
jmp    16f9 <main+0x479>
lea    0xc93(%rip),%rbx
mov    %rbx,%rdi
call   10b0 <strlen@plt>
lea    0x13(%rax),%edi
call   1130 <malloc@plt>
mov    %rax,%rbp
lea    0xc3a(%rip),%rsi
lea    0xc78(%rip),%rdx
jmp    16d1 <main+0x451>
lea    0xc1f(%rip),%rbx
mov    %rbx,%rdi
call   10b0 <strlen@plt>
lea    0x13(%rax),%edi
call   1130 <malloc@plt>
mov    %rax,%rbp
lea    0xc0d(%rip),%rsi
lea    0xc29(%rip),%rdx
jmp    16d1 <main+0x451>
lea    0xc1f(%rip),%rbx
mov    %rbx,%rdi
call   10b0 <strlen@plt>
lea    0x13(%rax),%edi
call   1130 <malloc@plt>
mov    %rax,%rbp
lea    0xbe0(%rip),%rsi
lea    0xc01(%rip),%rdx
jmp    16d1 <main+0x451>
lea    0xbf7(%rip),%rbx
mov    %rbx,%rdi
call   10b0 <strlen@plt>
lea    0x13(%rax),%edi
call   1130 <malloc@plt>
mov    %rax,%rbp
lea    0xbb3(%rip),%rsi
lea    0xc0e(%rip),%rdx
jmp    16d1 <main+0x451>
lea    0xbd2(%rip),%rbx
mov    %rbx,%rdi
call   10b0 <strlen@plt>
lea    0x13(%rax),%edi
call   1130 <malloc@plt>
mov    %rax,%rbp
lea    0xb89(%rip),%rsi
lea    0xbbf(%rip),%rdx
jmp    16d1 <main+0x451>
lea    0xbc0(%rip),%rbx
mov    %rbx,%rdi
call   10b0 <strlen@plt>
lea    0x13(%rax),%edi
call   1130 <malloc@plt>
mov    %rax,%rbp
lea    0xb5f(%rip),%rsi
lea    0xba6(%rip),%rdx
jmp    16d1 <main+0x451>
lea    0xb9f(%rip),%rbx
mov    %rbx,%rdi
call   10b0 <strlen@plt>
lea    0x13(%rax),%edi
call   1130 <malloc@plt>
mov    %rax,%rbp
lea    0xb35(%rip),%rsi
lea    0xb7a(%rip),%rdx
mov    %rax,%rdi
mov    %rbx,%rcx
call   1170 <sprintf@plt>
mov    %rbp,%rdi
call   1080 <fail@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
xor    %eax,%eax
call   1140 <usage@plt>
mov    $0x1,%r13d
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@opterr = global i64 0
@.str = [27 x i8] c"a:d:D:e:f:F:hi:l:Lo:pr:s:V\00"
@.str.1 = [8 x i8] c"content\00"
@.str.2 = [35 x i8] c"Error: -%s missing an argument %s\0A\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [3 x i8] c"ID\00"
@.str.5 = [2 x i8] c"d\00"
@optarg = global i32 0
@.str.6 = [5 x i8] c"path\00"
@.str.7 = [2 x i8] c"e\00"
@.str.8 = [14 x i8] c"search string\00"
@.str.9 = [2 x i8] c"f\00"
@.str.10 = [6 x i8] c"regex\00"
@.str.11 = [2 x i8] c"F\00"
@.str.12 = [7 x i8] c"number\00"
@.str.13 = [2 x i8] c"l\00"
@.str.14 = [20 x i8] c"id, content or date\00"
@.str.15 = [2 x i8] c"r\00"
@.str.16 = [20 x i8] c"Stamp version %.1f\0A\00"
@.str.17 = [12 x i8] c"adDefFilors\00"
@optopt = global i8 0
@.str.18 = [41 x i8] c"Error: -%c missing an argument category\0A\00"
@.str.19 = [44 x i8] c"invalid option '%c', see stamp -h for help\0A\00"
@.str.20 = [38 x i8] c"invalid input, see stamp -h for help\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i32
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i64 0, i64* @opterr
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %24
22: ; preds = %2
%23 = call i32 (...) @usage()
store i32 -1, i32* %3
br label %322
24: ; preds = %2
store i32 0, i32* %8
br label %25
25: ; preds = %311, %24
%26 = load i32, i32* %4
%27 = load i8**, i8*** %5
%28 = call i32 @getopt(i32 %26, i8** %27, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 %28, i32* %6
%29 = icmp ne i32 %28, -1
br i1 %29, label %30, label %312
30: ; preds = %25
store i32 1, i32* %7
%31 = load i32, i32* %6
switch i32 %31, label %311 [
i32 97, label %32
i32 100, label %81
i32 68, label %111
i32 101, label %117
i32 102, label %143
i32 70, label %172
i32 104, label %201
i32 105, label %203
i32 111, label %206
i32 108, label %209
i32 76, label %236
i32 112, label %241
i32 114, label %243
i32 115, label %273
i32 86, label %276
i32 63, label %278
]
32: ; preds = %30
%33 = load i32, i32* %4
%34 = icmp slt i32 %33, 4
br i1 %34, label %35, label %50
35: ; preds = %32
%36 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%37 = add nsw i32 19, %36
%38 = sext i32 %37 to i64
%39 = mul i64 %38, 1
%40 = trunc i64 %39 to i32
%41 = call i64 @malloc(i32 %40)
%42 = inttoptr i64 %41 to i8*
store i8* %42, i8** %10
%43 = load i8*, i8** %10
%44 = call i32 @sprintf(i8* %43, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%45 = load i8*, i8** %10
%46 = call i32 @fail(i8* %45)
%47 = load i8*, i8** %10
%48 = call i32 @free(i8* %47)
%49 = call i32 (...) @usage()
store i32 1, i32* %3
br label %322
50: ; preds = %32
%51 = load i32, i32* %4
%52 = icmp sgt i32 %51, 4
br i1 %52, label %53, label %72
53: ; preds = %50
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 4
%56 = load i8*, i8** %55
%57 = call i32 @is_valid_date_format(i8* %56, i32 0)
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %70
59: ; preds = %53
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 2
%62 = load i8*, i8** %61
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 3
%65 = load i8*, i8** %64
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 4
%68 = load i8*, i8** %67
%69 = call i32 @add_note(i8* %62, i8* %65, i8* %68)
br label %71
70: ; preds = %53
store i32 1, i32* %8
br label %71
71: ; preds = %70, %59
br label %80
72: ; preds = %50
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 2
%75 = load i8*, i8** %74
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 3
%78 = load i8*, i8** %77
%79 = call i32 @add_note(i8* %75, i8* %78, i8* null)
br label %80
80: ; preds = %72, %71
br label %311
81: ; preds = %30
%82 = load i32, i32* %4
%83 = icmp slt i32 %82, 4
br i1 %83, label %84, label %99
84: ; preds = %81
%85 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%86 = add nsw i32 19, %85
%87 = sext i32 %86 to i64
%88 = mul i64 %87, 1
%89 = trunc i64 %88 to i32
%90 = call i64 @malloc(i32 %89)
%91 = inttoptr i64 %90 to i8*
store i8* %91, i8** %11
%92 = load i8*, i8** %11
%93 = call i32 @sprintf(i8* %92, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%94 = load i8*, i8** %11
%95 = call i32 @fail(i8* %94)
%96 = load i8*, i8** %11
%97 = call i32 @free(i8* %96)
%98 = call i32 (...) @usage()
store i32 1, i32* %3
br label %322
99: ; preds = %81
%100 = load i8**, i8*** %5
%101 = getelementptr inbounds i8*, i8** %100, i64 2
%102 = load i8*, i8** %101
%103 = load i8**, i8*** %5
%104 = getelementptr inbounds i8*, i8** %103, i64 3
%105 = load i8*, i8** %104
%106 = call i32 @atoi(i8* %105)
%107 = call i32 @delete_note(i8* %102, i32 %106)
store i32 %107, i32* %9
%108 = icmp ne i32 %107, 0
br i1 %108, label %109, label %110
109: ; preds = %99
store i32 2, i32* %8
br label %110
110: ; preds = %109, %99
br label %311
111: ; preds = %30
%112 = load i32, i32* @optarg
%113 = call i32 @delete_all(i32 %112)
store i32 %113, i32* %9
%114 = icmp ne i32 %113, 0
br i1 %114, label %115, label %116
115: ; preds = %111
store i32 2, i32* %8
br label %116
116: ; preds = %115, %111
br label %311
117: ; preds = %30
%118 = load i32, i32* %4
%119 = icmp slt i32 %118, 4
br i1 %119, label %120, label %135
120: ; preds = %117
%121 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%122 = add nsw i32 19, %121
%123 = sext i32 %122 to i64
%124 = mul i64 %123, 1
%125 = trunc i64 %124 to i32
%126 = call i64 @malloc(i32 %125)
%127 = inttoptr i64 %126 to i8*
store i8* %127, i8** %12
%128 = load i8*, i8** %12
%129 = call i32 @sprintf(i8* %128, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%130 = load i8*, i8** %12
%131 = call i32 @fail(i8* %130)
%132 = load i8*, i8** %12
%133 = call i32 @free(i8* %132)
%134 = call i32 (...) @usage()
store i32 1, i32* %3
br label %322
135: ; preds = %117
%136 = load i8**, i8*** %5
%137 = getelementptr inbounds i8*, i8** %136, i64 2
%138 = load i8*, i8** %137
%139 = load i8**, i8*** %5
%140 = getelementptr inbounds i8*, i8** %139, i64 3
%141 = load i8*, i8** %140
%142 = call i32 @export_html(i8* %138, i8* %141)
br label %311
143: ; preds = %30
%144 = load i32, i32* %4
%145 = icmp slt i32 %144, 4
br i1 %145, label %146, label %161
146: ; preds = %143
%147 = call i32 @strlen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%148 = add nsw i32 19, %147
%149 = sext i32 %148 to i64
%150 = mul i64 %149, 1
%151 = trunc i64 %150 to i32
%152 = call i64 @malloc(i32 %151)
%153 = inttoptr i64 %152 to i8*
store i8* %153, i8** %13
%154 = load i8*, i8** %13
%155 = call i32 @sprintf(i8* %154, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%156 = load i8*, i8** %13
%157 = call i32 @fail(i8* %156)
%158 = load i8*, i8** %13
%159 = call i32 @free(i8* %158)
%160 = call i32 (...) @usage()
store i32 1, i32* %3
br label %322
161: ; preds = %143
%162 = load i8**, i8*** %5
%163 = getelementptr inbounds i8*, i8** %162, i64 2
%164 = load i8*, i8** %163
%165 = load i8**, i8*** %5
%166 = getelementptr inbounds i8*, i8** %165, i64 3
%167 = load i8*, i8** %166
%168 = call i32 @search_notes(i8* %164, i8* %167)
store i32 %168, i32* %9
%169 = icmp eq i32 %168, 0
br i1 %169, label %170, label %171
170: ; preds = %161
store i32 2, i32* %8
br label %171
171: ; preds = %170, %161
br label %311
172: ; preds = %30
%173 = load i32, i32* %4
%174 = icmp slt i32 %173, 4
br i1 %174, label %175, label %190
175: ; preds = %172
%176 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%177 = add nsw i32 19, %176
%178 = sext i32 %177 to i64
%179 = mul i64 %178, 1
%180 = trunc i64 %179 to i32
%181 = call i64 @malloc(i32 %180)
%182 = inttoptr i64 %181 to i8*
store i8* %182, i8** %14
%183 = load i8*, i8** %14
%184 = call i32 @sprintf(i8* %183, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%185 = load i8*, i8** %14
%186 = call i32 @fail(i8* %185)
%187 = load i8*, i8** %14
%188 = call i32 @free(i8* %187)
%189 = call i32 (...) @usage()
store i32 1, i32* %3
br label %322
190: ; preds = %172
%191 = load i8**, i8*** %5
%192 = getelementptr inbounds i8*, i8** %191, i64 2
%193 = load i8*, i8** %192
%194 = load i8**, i8*** %5
%195 = getelementptr inbounds i8*, i8** %194, i64 3
%196 = load i8*, i8** %195
%197 = call i32 @search_regexp(i8* %193, i8* %196)
store i32 %197, i32* %9
%198 = icmp eq i32 %197, 0
br i1 %198, label %199, label %200
199: ; preds = %190
store i32 2, i32* %8
br label %200
200: ; preds = %199, %190
br label %311
201: ; preds = %30
%202 = call i32 (...) @usage()
br label %311
203: ; preds = %30
%204 = load i32, i32* @optarg
%205 = call i32 @add_notes_from_stdin(i32 %204)
br label %311
206: ; preds = %30
%207 = load i32, i32* @optarg
%208 = call i32 @show_notes_tree(i32 %207)
br label %311
209: ; preds = %30
%210 = load i32, i32* %4
%211 = icmp slt i32 %210, 4
br i1 %211, label %212, label %227
212: ; preds = %209
%213 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%214 = add nsw i32 19, %213
%215 = sext i32 %214 to i64
%216 = mul i64 %215, 1
%217 = trunc i64 %216 to i32
%218 = call i64 @malloc(i32 %217)
%219 = inttoptr i64 %218 to i8*
store i8* %219, i8** %15
%220 = load i8*, i8** %15
%221 = call i32 @sprintf(i8* %220, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%222 = load i8*, i8** %15
%223 = call i32 @fail(i8* %222)
%224 = load i8*, i8** %15
%225 = call i32 @free(i8* %224)
%226 = call i32 (...) @usage()
store i32 1, i32* %3
br label %322
227: ; preds = %209
%228 = load i8**, i8*** %5
%229 = getelementptr inbounds i8*, i8** %228, i64 2
%230 = load i8*, i8** %229
%231 = load i8**, i8*** %5
%232 = getelementptr inbounds i8*, i8** %231, i64 3
%233 = load i8*, i8** %232
%234 = call i32 @atoi(i8* %233)
%235 = call i32 @show_latest(i8* %230, i32 %234)
br label %311
236: ; preds = %30
%237 = call i32 (...) @show_categories()
store i32 %237, i32* %9
%238 = icmp sle i32 %237, 0
br i1 %238, label %239, label %240
239: ; preds = %236
store i32 2, i32* %8
br label %240
240: ; preds = %239, %236
br label %311
241: ; preds = %30
%242 = call i32 (...) @show_memo_file_path()
br label %311
243: ; preds = %30
%244 = load i32, i32* %4
%245 = icmp slt i32 %244, 5
br i1 %245, label %246, label %261
246: ; preds = %243
%247 = call i32 @strlen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
%248 = add nsw i32 19, %247
%249 = sext i32 %248 to i64
%250 = mul i64 %249, 1
%251 = trunc i64 %250 to i32
%252 = call i64 @malloc(i32 %251)
%253 = inttoptr i64 %252 to i8*
store i8* %253, i8** %16
%254 = load i8*, i8** %16
%255 = call i32 @sprintf(i8* %254, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
%256 = load i8*, i8** %16
%257 = call i32 @fail(i8* %256)
%258 = load i8*, i8** %16
%259 = call i32 @free(i8* %258)
%260 = call i32 (...) @usage()
store i32 1, i32* %3
br label %322
261: ; preds = %243
%262 = load i8**, i8*** %5
%263 = getelementptr inbounds i8*, i8** %262, i64 2
%264 = load i8*, i8** %263
%265 = load i8**, i8*** %5
%266 = getelementptr inbounds i8*, i8** %265, i64 3
%267 = load i8*, i8** %266
%268 = call i32 @atoi(i8* %267)
%269 = load i8**, i8*** %5
%270 = getelementptr inbounds i8*, i8** %269, i64 4
%271 = load i8*, i8** %270
%272 = call i32 @replace_note(i8* %264, i32 %268, i8* %271)
br label %311
273: ; preds = %30
%274 = load i32, i32* @optarg
%275 = call i32 @show_notes(i32 %274)
br label %311
276: ; preds = %30
%277 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.16, i64 0, i64 0), double 1.400000e+00)
br label %311
278: ; preds = %30
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0), i8** %17
store i32 0, i32* %18
store i32 0, i32* %19
br label %279
279: ; preds = %300, %278
%280 = load i32, i32* %19
%281 = load i8*, i8** %17
%282 = call i32 @strlen(i8* %281)
%283 = icmp slt i32 %280, %282
br i1 %283, label %284, label %303
284: ; preds = %279
%285 = load i8*, i8** %17
%286 = load i32, i32* %19
%287 = sext i32 %286 to i64
%288 = getelementptr inbounds i8, i8* %285, i64 %287
%289 = load i8, i8* %288
%290 = sext i8 %289 to i32
%291 = load i8, i8* @optopt
%292 = sext i8 %291 to i32
%293 = icmp eq i32 %290, %292
br i1 %293, label %294, label %299
294: ; preds = %284
store i32 1, i32* %18
%295 = load i8, i8* @optopt
%296 = sext i8 %295 to i32
%297 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.18, i64 0, i64 0), i32 %296)
%298 = call i32 (...) @usage()
store i32 1, i32* %8
br label %303
299: ; preds = %284
br label %300
300: ; preds = %299
%301 = load i32, i32* %19
%302 = add nsw i32 %301, 1
store i32 %302, i32* %19
br label %279
303: ; preds = %294, %279
%304 = load i32, i32* %18
%305 = icmp eq i32 %304, 0
br i1 %305, label %306, label %310
306: ; preds = %303
%307 = load i8, i8* @optopt
%308 = sext i8 %307 to i32
%309 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.19, i64 0, i64 0), i32 %308)
store i32 1, i32* %8
br label %310
310: ; preds = %306, %303
br label %311
311: ; preds = %30, %310, %276, %273, %261, %241, %240, %227, %206, %203, %201, %200, %171, %135, %116, %110, %80
br label %25
312: ; preds = %25
%313 = load i32, i32* %4
%314 = icmp sgt i32 %313, 1
br i1 %314, label %315, label %320
315: ; preds = %312
%316 = load i32, i32* %7
%317 = icmp ne i32 %316, 0
br i1 %317, label %320, label %318
318: ; preds = %315
%319 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.20, i64 0, i64 0))
br label %320
320: ; preds = %318, %315, %312
%321 = load i32, i32* %8
store i32 %321, i32* %3
br label %322
322: ; preds = %320, %246, %212, %175, %146, %120, %84, %35, %22
%323 = load i32, i32* %3
ret i32 %323
}

LLVM IR (-O2):
@opterr = global i64 0
@.str = [27 x i8] c"a:d:D:e:f:F:hi:l:Lo:pr:s:V\00"
@.str.1 = [8 x i8] c"content\00"
@.str.2 = [35 x i8] c"Error: -%s missing an argument %s\0A\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [3 x i8] c"ID\00"
@.str.5 = [2 x i8] c"d\00"
@optarg = global i32 0
@.str.6 = [5 x i8] c"path\00"
@.str.7 = [2 x i8] c"e\00"
@.str.8 = [14 x i8] c"search string\00"
@.str.9 = [2 x i8] c"f\00"
@.str.10 = [6 x i8] c"regex\00"
@.str.11 = [2 x i8] c"F\00"
@.str.12 = [7 x i8] c"number\00"
@.str.13 = [2 x i8] c"l\00"
@.str.14 = [20 x i8] c"id, content or date\00"
@.str.15 = [2 x i8] c"r\00"
@.str.16 = [20 x i8] c"Stamp version %.1f\0A\00"
@.str.17 = [12 x i8] c"adDefFilors\00"
@optopt = global i8 0
@.str.18 = [41 x i8] c"Error: -%c missing an argument category\0A\00"
@.str.19 = [44 x i8] c"invalid option '%c', see stamp -h for help\0A\00"
@str = [37 x i8] c"invalid input, see stamp -h for help\00"
define i32 @main(i32 %0, i8** %1) {
store i64 0, i64* @opterr
%3 = icmp eq i32 %0, 1
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = icmp slt i32 %0, 5
%6 = getelementptr inbounds i8*, i8** %1, i64 2
%7 = getelementptr inbounds i8*, i8** %1, i64 3
%8 = getelementptr inbounds i8*, i8** %1, i64 4
%9 = icmp slt i32 %0, 4
%10 = icmp eq i32 %0, 4
br label %13
11: ; preds = %2
%12 = tail call i32 (...) @usage()
br label %188
13: ; preds = %177, %4
%14 = phi i32 [ 0, %4 ], [ %178, %177 ]
%15 = phi i1 [ false, %4 ], [ true, %177 ]
%16 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
switch i32 %16, label %177 [
i32 -1, label %183
i32 97, label %20
i32 100, label %44
i32 68, label %61
i32 101, label %66
i32 102, label %80
i32 70, label %96
i32 104, label %112
i32 105, label %114
i32 111, label %117
i32 108, label %120
i32 76, label %135
i32 112, label %139
i32 114, label %141
i32 115, label %157
i32 86, label %160
i32 63, label %17
]
17: ; preds = %13
%18 = tail call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0))
%19 = icmp sgt i32 %18, 0
br i1 %19, label %166, label %179
20: ; preds = %13
br i1 %9, label %21, label %30
21: ; preds = %20
%22 = tail call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%23 = add nsw i32 %22, 19
%24 = tail call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i8*
%26 = tail call i32 @sprintf(i8* dereferenceable(1) %25, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%27 = tail call i32 @fail(i8* %25)
%28 = tail call i32 @free(i8* %25)
%29 = tail call i32 (...) @usage()
br label %188
30: ; preds = %20
br i1 %10, label %40, label %31
31: ; preds = %30
%32 = load i8*, i8** %8
%33 = tail call i32 @is_valid_date_format(i8* %32, i32 0)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %177
35: ; preds = %31
%36 = load i8*, i8** %6
%37 = load i8*, i8** %7
%38 = load i8*, i8** %8
%39 = tail call i32 @add_note(i8* %36, i8* %37, i8* %38)
br label %177
40: ; preds = %30
%41 = load i8*, i8** %6
%42 = load i8*, i8** %7
%43 = tail call i32 @add_note(i8* %41, i8* %42, i8* null)
br label %177
44: ; preds = %13
br i1 %9, label %45, label %54
45: ; preds = %44
%46 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%47 = add nsw i32 %46, 19
%48 = tail call i64 @malloc(i32 %47)
%49 = inttoptr i64 %48 to i8*
%50 = tail call i32 @sprintf(i8* dereferenceable(1) %49, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%51 = tail call i32 @fail(i8* %49)
%52 = tail call i32 @free(i8* %49)
%53 = tail call i32 (...) @usage()
br label %188
54: ; preds = %44
%55 = load i8*, i8** %6
%56 = load i8*, i8** %7
%57 = tail call i32 @atoi(i8* %56)
%58 = tail call i32 @delete_note(i8* %55, i32 %57)
%59 = icmp eq i32 %58, 0
%60 = select i1 %59, i32 %14, i32 2
br label %177
61: ; preds = %13
%62 = load i32, i32* @optarg
%63 = tail call i32 @delete_all(i32 %62)
%64 = icmp eq i32 %63, 0
%65 = select i1 %64, i32 %14, i32 2
br label %177
66: ; preds = %13
br i1 %9, label %67, label %76
67: ; preds = %66
%68 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%69 = add nsw i32 %68, 19
%70 = tail call i64 @malloc(i32 %69)
%71 = inttoptr i64 %70 to i8*
%72 = tail call i32 @sprintf(i8* dereferenceable(1) %71, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%73 = tail call i32 @fail(i8* %71)
%74 = tail call i32 @free(i8* %71)
%75 = tail call i32 (...) @usage()
br label %188
76: ; preds = %66
%77 = load i8*, i8** %6
%78 = load i8*, i8** %7
%79 = tail call i32 @export_html(i8* %77, i8* %78)
br label %177
80: ; preds = %13
br i1 %9, label %81, label %90
81: ; preds = %80
%82 = tail call i32 @strlen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%83 = add nsw i32 %82, 19
%84 = tail call i64 @malloc(i32 %83)
%85 = inttoptr i64 %84 to i8*
%86 = tail call i32 @sprintf(i8* dereferenceable(1) %85, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%87 = tail call i32 @fail(i8* %85)
%88 = tail call i32 @free(i8* %85)
%89 = tail call i32 (...) @usage()
br label %188
90: ; preds = %80
%91 = load i8*, i8** %6
%92 = load i8*, i8** %7
%93 = tail call i32 @search_notes(i8* %91, i8* %92)
%94 = icmp eq i32 %93, 0
%95 = select i1 %94, i32 2, i32 %14
br label %177
96: ; preds = %13
br i1 %9, label %97, label %106
97: ; preds = %96
%98 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%99 = add nsw i32 %98, 19
%100 = tail call i64 @malloc(i32 %99)
%101 = inttoptr i64 %100 to i8*
%102 = tail call i32 @sprintf(i8* dereferenceable(1) %101, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%103 = tail call i32 @fail(i8* %101)
%104 = tail call i32 @free(i8* %101)
%105 = tail call i32 (...) @usage()
br label %188
106: ; preds = %96
%107 = load i8*, i8** %6
%108 = load i8*, i8** %7
%109 = tail call i32 @search_regexp(i8* %107, i8* %108)
%110 = icmp eq i32 %109, 0
%111 = select i1 %110, i32 2, i32 %14
br label %177
112: ; preds = %13
%113 = tail call i32 (...) @usage()
br label %177
114: ; preds = %13
%115 = load i32, i32* @optarg
%116 = tail call i32 @add_notes_from_stdin(i32 %115)
br label %177
117: ; preds = %13
%118 = load i32, i32* @optarg
%119 = tail call i32 @show_notes_tree(i32 %118)
br label %177
120: ; preds = %13
br i1 %9, label %121, label %130
121: ; preds = %120
%122 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%123 = add nsw i32 %122, 19
%124 = tail call i64 @malloc(i32 %123)
%125 = inttoptr i64 %124 to i8*
%126 = tail call i32 @sprintf(i8* dereferenceable(1) %125, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%127 = tail call i32 @fail(i8* %125)
%128 = tail call i32 @free(i8* %125)
%129 = tail call i32 (...) @usage()
br label %188
130: ; preds = %120
%131 = load i8*, i8** %6
%132 = load i8*, i8** %7
%133 = tail call i32 @atoi(i8* %132)
%134 = tail call i32 @show_latest(i8* %131, i32 %133)
br label %177
135: ; preds = %13
%136 = tail call i32 (...) @show_categories()
%137 = icmp slt i32 %136, 1
%138 = select i1 %137, i32 2, i32 %14
br label %177
139: ; preds = %13
%140 = tail call i32 (...) @show_memo_file_path()
br label %177
141: ; preds = %13
br i1 %5, label %142, label %151
142: ; preds = %141
%143 = tail call i32 @strlen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
%144 = add nsw i32 %143, 19
%145 = tail call i64 @malloc(i32 %144)
%146 = inttoptr i64 %145 to i8*
%147 = tail call i32 @sprintf(i8* dereferenceable(1) %146, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
%148 = tail call i32 @fail(i8* %146)
%149 = tail call i32 @free(i8* %146)
%150 = tail call i32 (...) @usage()
br label %188
151: ; preds = %141
%152 = load i8*, i8** %6
%153 = load i8*, i8** %7
%154 = tail call i32 @atoi(i8* %153)
%155 = load i8*, i8** %8
%156 = tail call i32 @replace_note(i8* %152, i32 %154, i8* %155)
br label %177
157: ; preds = %13
%158 = load i32, i32* @optarg
%159 = tail call i32 @show_notes(i32 %158)
br label %177
160: ; preds = %13
%161 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.16, i64 0, i64 0), double 1.400000e+00)
br label %177
162: ; preds = %166
%163 = tail call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0))
%164 = sext i32 %163 to i64
%165 = icmp slt i64 %172, %164
br i1 %165, label %166, label %179
166: ; preds = %17, %162
%167 = phi i64 [ %172, %162 ], [ 0, %17 ]
%168 = getelementptr inbounds [12 x i8], [12 x i8]* @.str.17, i64 0, i64 %167
%169 = load i8, i8* %168
%170 = load i8, i8* @optopt
%171 = icmp eq i8 %169, %170
%172 = add nuw nsw i64 %167, 1
br i1 %171, label %173, label %162
173: ; preds = %166
%174 = sext i8 %169 to i32
%175 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.18, i64 0, i64 0), i32 %174)
%176 = tail call i32 (...) @usage()
br label %177
177: ; preds = %173, %135, %106, %90, %61, %54, %179, %31, %13, %40, %35, %160, %157, %151, %139, %130, %117, %114, %112, %76
%178 = phi i32 [ %14, %160 ], [ %14, %157 ], [ %14, %151 ], [ %14, %139 ], [ %14, %130 ], [ %14, %117 ], [ %14, %114 ], [ %14, %112 ], [ %14, %76 ], [ %14, %35 ], [ %14, %40 ], [ %14, %13 ], [ 1, %31 ], [ %60, %54 ], [ %65, %61 ], [ %95, %90 ], [ %111, %106 ], [ %138, %135 ], [ 1, %179 ], [ 1, %173 ]
br label %13
179: ; preds = %162, %17
%180 = load i8, i8* @optopt
%181 = sext i8 %180 to i32
%182 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.19, i64 0, i64 0), i32 %181)
br label %177
183: ; preds = %13
%184 = icmp slt i32 %0, 2
%185 = or i1 %184, %15
br i1 %185, label %188, label %186
186: ; preds = %183
%187 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %188
188: ; preds = %21, %45, %67, %81, %97, %121, %142, %186, %183, %11
%189 = phi i32 [ -1, %11 ], [ 1, %142 ], [ 1, %121 ], [ 1, %97 ], [ 1, %81 ], [ 1, %67 ], [ 1, %45 ], [ 1, %21 ], [ %14, %186 ], [ %14, %183 ]
ret i32 %189
}