#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 */
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ const member_1;
};
struct NotifyData {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ atoi(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int getopt_long(int, char **, char *, struct option *, int /*<<< orphan*/ *);
#define no_argument 129
struct NotifyData *notif_create_data();
int /*<<< orphan*/ notif_free_data(struct NotifyData *);
int /*<<< orphan*/ notif_free_error_message();
int /*<<< orphan*/ *notif_get_body(struct NotifyData *);
char *notif_get_error_message();
int /*<<< orphan*/ *notif_get_id_file(struct NotifyData *);
int /*<<< orphan*/ notif_get_replaces_id(struct NotifyData *);
int /*<<< orphan*/ *notif_get_summary(struct NotifyData *);
int notif_send_notification(struct NotifyData *);
int /*<<< orphan*/ notif_set_app_name(struct NotifyData *, int /*<<< orphan*/);
int /*<<< orphan*/ notif_set_body(struct NotifyData *, char *);
int /*<<< orphan*/ notif_set_category(struct NotifyData *, int /*<<< orphan*/);
int /*<<< orphan*/ notif_set_expire_time(struct NotifyData *,
                                         int /*<<< orphan*/);
int /*<<< orphan*/ notif_set_icon(struct NotifyData *, int /*<<< orphan*/);
int /*<<< orphan*/ notif_set_id_file(struct NotifyData *, int /*<<< orphan*/ *);
int /*<<< orphan*/ notif_set_replaces_id(struct NotifyData *,
                                         int /*<<< orphan*/);
int /*<<< orphan*/ notif_set_replaces_id_from_file(struct NotifyData *);
int /*<<< orphan*/ notif_set_summary(struct NotifyData *, char *);
int /*<<< orphan*/ notif_set_urgency(struct NotifyData *, int);
scalar_t__ notif_validate_data(struct NotifyData *);
int /*<<< orphan*/ optarg;
int optind;
int parse_urgency(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
#define required_argument 128
int /*<<< orphan*/ show_help();
int /*<<< orphan*/ show_version();
int main(int argc, char **argv) {
  struct NotifyData *data;
  int opt, urgency;
  static struct option options[] = {{"help", no_argument, 0, 'h'},
                                    {"version", no_argument, 0, 'v'},
                                    {"replaces-id", required_argument, 0, 'r'},
                                    {"urgency", required_argument, 0, 'u'},
                                    {"expire", required_argument, 0, 't'},
                                    {"app-name", required_argument, 0, 'a'},
                                    {"id-file", required_argument, 0, 'R'},
                                    {"icon", required_argument, 0, 'i'},
                                    {"category", required_argument, 0, 'c'},
                                    {0, 0, 0, 0}};
  if (argc < 1) {
    show_help();
    return 1;
  }
  data = notif_create_data();
  while ((opt = getopt_long(argc, argv, "hvr:R:u:t:a:i:c:", options, NULL)) !=
         -1) {
    switch (opt) {
    case 'h':
      show_help();
      notif_free_data(data);
      return 0;
    case 'v':
      show_version();
      notif_free_data(data);
      return 0;
    case 'r':
      if (notif_get_id_file(data) != NULL) {
        printf("-r and -R are incompatible options\n");
        goto error;
      }
      notif_set_replaces_id(data, atoi(optarg));
      break;
    case 'R': {
      if (notif_get_replaces_id(data) != 0) {
        printf("-r and -R are incompatible options\n");
        goto error;
      }
      FILE *file = fopen(optarg, "r+");
      if (file == NULL) {
        perror("Could not open the id_file");
        goto error;
      }
      notif_set_id_file(data, file);
      notif_set_replaces_id_from_file(data);
      break;
    }
    case 'u':
      urgency = parse_urgency(optarg);
      if (urgency == -1) {
        printf("Invalid urgency value!\n");
        goto error;
      }
      notif_set_urgency(data, urgency);
      break;
    case 't':
      notif_set_expire_time(data, atoi(optarg));
      break;
    case 'a':
      notif_set_app_name(data, optarg);
      break;
    case 'i':
      notif_set_icon(data, optarg);
      break;
    case 'c':
      notif_set_category(data, optarg);
      break;
    default:
      printf("Usage:\nnotify-desktop [OPTION...] <SUMMARY> [BODY] - create a "
             "notification\n");
      goto error;
    }
  }
  for (; optind < argc; ++optind) {
    if (notif_get_summary(data) == NULL) {
      notif_set_summary(data, argv[optind]);
    } else if (notif_get_body(data) == NULL) {
      notif_set_body(data, argv[optind]);
    } else {
      printf("Too many arguments!\n");
      goto error;
    }
  }
  if (notif_validate_data(data)) {
    int id;
    id = notif_send_notification(data);
    if (id == -1) {
      printf("Error: %s\n", notif_get_error_message());
      notif_free_error_message();
      goto error;
    } else {
      fprintf(notif_get_id_file(data), "%i\n", id);
    }
  }
  notif_free_data(data);
  return 0;
error:
  notif_free_data(data);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    1303 <main+0x33>
mov    $0x0,%al
call   1120 <show_help@plt>
movl   $0x1,-0x4(%rbp)
jmp    1663 <main+0x393>
mov    $0x0,%al
call   1150 <notif_create_data@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdbf(%rip),%rdx
lea    0x2ded(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   10b0 <getopt_long@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     151d <main+0x24d>
mov    -0x1c(%rbp),%eax
add    $0xffffffae,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x24,%eax
ja     1505 <main+0x235>
mov    -0x38(%rbp),%rax
lea    0xca7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1120 <show_help@plt>
mov    -0x18(%rbp),%rdi
call   1050 <notif_free_data@plt>
movl   $0x0,-0x4(%rbp)
jmp    1663 <main+0x393>
mov    $0x0,%al
call   1030 <show_version@plt>
mov    -0x18(%rbp),%rdi
call   1050 <notif_free_data@plt>
movl   $0x0,-0x4(%rbp)
jmp    1663 <main+0x393>
mov    -0x18(%rbp),%rdi
call   11d0 <notif_get_id_file@plt>
cmp    $0x0,%rax
je     13c0 <main+0xf0>
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   10c0 <printf@plt>
jmp    1653 <main+0x383>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    0x2c29(%rip),%rax
mov    (%rax),%edi
call   11b0 <atoi@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   10e0 <notif_set_replaces_id@plt>
jmp    1518 <main+0x248>
mov    -0x18(%rbp),%rdi
call   11f0 <notif_get_replaces_id@plt>
cmp    $0x0,%eax
je     140b <main+0x13b>
lea    0xced(%rip),%rdi
mov    $0x0,%al
call   10c0 <printf@plt>
jmp    1653 <main+0x383>
mov    0x2be6(%rip),%rax
mov    (%rax),%edi
lea    0xcf5(%rip),%rsi
call   1180 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1440 <main+0x170>
lea    0xcdd(%rip),%rdi
call   1190 <perror@plt>
jmp    1653 <main+0x383>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <notif_set_id_file@plt>
mov    -0x18(%rbp),%rdi
call   11a0 <notif_set_replaces_id_from_file@plt>
jmp    1518 <main+0x248>
mov    0x2b96(%rip),%rax
mov    (%rax),%edi
call   1100 <parse_urgency@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    1489 <main+0x1b9>
lea    0xcb1(%rip),%rdi
mov    $0x0,%al
call   10c0 <printf@plt>
jmp    1653 <main+0x383>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1160 <notif_set_urgency@plt>
jmp    1518 <main+0x248>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2b4f(%rip),%rax
mov    (%rax),%edi
call   11b0 <atoi@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
call   10d0 <notif_set_expire_time@plt>
jmp    1518 <main+0x248>
mov    -0x18(%rbp),%rdi
mov    0x2b2d(%rip),%rax
mov    (%rax),%esi
call   1090 <notif_set_app_name@plt>
jmp    1518 <main+0x248>
mov    -0x18(%rbp),%rdi
mov    0x2b16(%rip),%rax
mov    (%rax),%esi
call   1070 <notif_set_icon@plt>
jmp    1518 <main+0x248>
mov    -0x18(%rbp),%rdi
mov    0x2aff(%rip),%rax
mov    (%rax),%esi
call   11e0 <notif_set_category@plt>
jmp    1518 <main+0x248>
lea    0xc3a(%rip),%rdi
mov    $0x0,%al
call   10c0 <printf@plt>
jmp    1653 <main+0x383>
jmp    130e <main+0x3e>
jmp    1522 <main+0x252>
mov    0x2ab7(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    15d1 <main+0x301>
mov    -0x18(%rbp),%rdi
call   1140 <notif_get_summary@plt>
cmp    $0x0,%rax
jne    1567 <main+0x297>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x2a8a(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
call   10f0 <notif_set_summary@plt>
jmp    15b2 <main+0x2e2>
mov    -0x18(%rbp),%rdi
call   10a0 <notif_get_body@plt>
cmp    $0x0,%rax
jne    159a <main+0x2ca>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x2a57(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
call   1080 <notif_set_body@plt>
jmp    15ad <main+0x2dd>
lea    0xbf1(%rip),%rdi
mov    $0x0,%al
call   10c0 <printf@plt>
jmp    1653 <main+0x383>
jmp    15b2 <main+0x2e2>
jmp    15b7 <main+0x2e7>
mov    0x2a22(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2a16(%rip),%rax
mov    %ecx,(%rax)
jmp    1522 <main+0x252>
mov    -0x18(%rbp),%rdi
call   1130 <notif_validate_data@plt>
cmp    $0x0,%rax
je     163e <main+0x36e>
mov    -0x18(%rbp),%rdi
call   1060 <notif_send_notification@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    161e <main+0x34e>
mov    $0x0,%al
call   1170 <notif_get_error_message@plt>
mov    %rax,%rsi
lea    0xb9c(%rip),%rdi
mov    $0x0,%al
call   10c0 <printf@plt>
mov    $0x0,%al
call   11c0 <notif_free_error_message@plt>
jmp    1653 <main+0x383>
mov    -0x18(%rbp),%rdi
call   11d0 <notif_get_id_file@plt>
mov    %rax,%rdi
mov    -0x2c(%rbp),%edx
lea    0xb7e(%rip),%rsi
call   1110 <fprintf@plt>
jmp    163e <main+0x36e>
mov    -0x18(%rbp),%rdi
call   1050 <notif_free_data@plt>
movl   $0x0,-0x4(%rbp)
jmp    1663 <main+0x393>
mov    -0x18(%rbp),%rdi
call   1050 <notif_free_data@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    1432 <main+0x152>
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1160 <notif_create_data@plt>
mov    %rax,%r14
lea    0xdd2(%rip),%r15
lea    0x2e10(%rip),%r12
lea    0xce9(%rip),%r13
jmp    1330 <main+0x50>
mov    0x2cd8(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   11f0 <notif_set_category@plt>
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
xor    %r8d,%r8d
call   10c0 <getopt_long@plt>
lea    -0x52(%rax),%ecx
cmp    $0x24,%ecx
ja     144a <main+0x16a>
movslq 0x0(%r13,%rcx,4),%rax
add    %r13,%rax
jmp    *%rax
mov    %r14,%rdi
call   1200 <notif_get_replaces_id@plt>
test   %eax,%eax
jne    143e <main+0x15e>
mov    0x2c88(%rip),%rax
mov    (%rax),%edi
lea    0xd73(%rip),%rsi
call   1190 <fopen@plt>
test   %rax,%rax
je     1572 <main+0x292>
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <notif_set_id_file@plt>
mov    %r14,%rdi
call   11b0 <notif_set_replaces_id_from_file@plt>
jmp    1330 <main+0x50>
mov    0x2c55(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   10a0 <notif_set_app_name@plt>
jmp    1330 <main+0x50>
mov    0x2c42(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1070 <notif_set_icon@plt>
jmp    1330 <main+0x50>
mov    %r14,%rdi
call   11e0 <notif_get_id_file@plt>
test   %rax,%rax
jne    143e <main+0x15e>
mov    0x2c1f(%rip),%rax
mov    (%rax),%edi
call   11c0 <atoi@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   10f0 <notif_set_replaces_id@plt>
jmp    1330 <main+0x50>
mov    0x2c02(%rip),%rax
mov    (%rax),%edi
call   11c0 <atoi@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   10e0 <notif_set_expire_time@plt>
jmp    1330 <main+0x50>
mov    0x2be5(%rip),%rax
mov    (%rax),%edi
call   1110 <parse_urgency@plt>
cmp    $0xffffffff,%eax
je     151e <main+0x23e>
mov    %r14,%rdi
mov    %eax,%esi
call   1170 <notif_set_urgency@plt>
jmp    1330 <main+0x50>
xor    %eax,%eax
call   1130 <show_help@plt>
jmp    1532 <main+0x252>
lea    0xcff(%rip),%rdi
jmp    1525 <main+0x245>
cmp    $0xffffffff,%eax
jne    14f7 <main+0x217>
mov    0x2b86(%rip),%r15
cmp    %ebp,(%r15)
jl     14cc <main+0x1ec>
mov    %r14,%rdi
call   1140 <notif_validate_data@plt>
test   %rax,%rax
je     1498 <main+0x1b8>
mov    %r14,%rdi
call   1060 <notif_send_notification@plt>
cmp    $0xffffffff,%eax
je     1551 <main+0x271>
mov    %eax,%ebx
mov    %r14,%rdi
call   11e0 <notif_get_id_file@plt>
lea    0xc87(%rip),%rsi
mov    %rax,%rdi
mov    %ebx,%edx
call   1120 <fprintf@plt>
mov    %r14,%rdi
call   1050 <notif_free_data@plt>
xor    %ebx,%ebx
jmp    1537 <main+0x257>
nopw   0x0(%rax,%rax,1)
movslq (%r15),%rax
mov    (%rbx,%rax,8),%rsi
mov    %r14,%rdi
call   1100 <notif_set_summary@plt>
mov    (%r15),%eax
add    $0x1,%eax
mov    %eax,(%r15)
cmp    %ebp,%eax
jge    145f <main+0x17f>
mov    %r14,%rdi
call   1150 <notif_get_summary@plt>
test   %rax,%rax
je     14b0 <main+0x1d0>
mov    %r14,%rdi
call   10b0 <notif_get_body@plt>
test   %rax,%rax
jne    1548 <main+0x268>
movslq (%r15),%rax
mov    (%rbx,%rax,8),%rsi
mov    %r14,%rdi
call   1080 <notif_set_body@plt>
jmp    14bf <main+0x1df>
lea    0xc69(%rip),%rdi
jmp    1525 <main+0x245>
xor    %ebx,%ebx
xor    %eax,%eax
call   1130 <show_help@plt>
jmp    1514 <main+0x234>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <show_version@plt>
mov    %r14,%rdi
call   1050 <notif_free_data@plt>
jmp    1537 <main+0x257>
lea    0xc08(%rip),%rdi
call   1090 <puts@plt>
mov    %r14,%rdi
call   1050 <notif_free_data@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbca(%rip),%rdi
jmp    1525 <main+0x245>
xor    %eax,%eax
call   1180 <notif_get_error_message@plt>
lea    0xbab(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   10d0 <printf@plt>
xor    %eax,%eax
call   11d0 <notif_free_error_message@plt>
jmp    152a <main+0x24a>
lea    0xb76(%rip),%rdi
call   11a0 <perror@plt>
jmp    152a <main+0x24a>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
%struct.NotifyData = type { i32 }
@main.options = internal global [10 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -127, i32 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8 -127, i32 0, i32 118 }, %struct.option { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32 0, i32 114 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 117 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8 -128, i32 0, i32 116 }, %struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i32 0, i32 0), i8 -128, i32 0, i32 97 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0), i8 -128, i32 0, i32 82 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i8 -128, i32 0, i32 105 }, %struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i32 0, i32 0), i8 -128, i32 0, i32 99 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [12 x i8] c"replaces-id\00"
@.str.3 = [8 x i8] c"urgency\00"
@.str.4 = [7 x i8] c"expire\00"
@.str.5 = [9 x i8] c"app-name\00"
@.str.6 = [8 x i8] c"id-file\00"
@.str.7 = [5 x i8] c"icon\00"
@.str.8 = [9 x i8] c"category\00"
@.str.9 = [17 x i8] c"hvr:R:u:t:a:i:c:\00"
@.str.10 = [36 x i8] c"-r and -R are incompatible options\0A\00"
@optarg = global i32 0
@.str.11 = [3 x i8] c"r+\00"
@.str.12 = [27 x i8] c"Could not open the id_file\00"
@.str.13 = [24 x i8] c"Invalid urgency value!\0A\00"
@.str.14 = [76 x i8] c"Usage:\0Anotify-desktop [OPTION...] <SUMMARY> [BODY] - create a notification\0A\00"
@optind = global i32 0
@.str.15 = [21 x i8] c"Too many arguments!\0A\00"
@.str.16 = [11 x i8] c"Error: %s\0A\00"
@.str.17 = [4 x i8] c"%i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.NotifyData*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (...) @show_help()
store i32 1, i32* %3
br label %154
15: ; preds = %2
%16 = call %struct.NotifyData* (...) @notif_create_data()
store %struct.NotifyData* %16, %struct.NotifyData** %6
br label %17
17: ; preds = %92, %15
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = call i32 @getopt_long(i32 %18, i8** %19, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), %struct.option* getelementptr inbounds ([10 x %struct.option], [10 x %struct.option]* @main.options, i64 0, i64 0), i32* null)
store i32 %20, i32* %7
%21 = icmp ne i32 %20, -1
br i1 %21, label %22, label %93
22: ; preds = %17
%23 = load i32, i32* %7
switch i32 %23, label %90 [
i32 104, label %24
i32 118, label %28
i32 114, label %32
i32 82, label %43
i32 117, label %62
i32 116, label %73
i32 97, label %78
i32 105, label %82
i32 99, label %86
]
24: ; preds = %22
%25 = call i32 (...) @show_help()
%26 = load %struct.NotifyData*, %struct.NotifyData** %6
%27 = call i32 @notif_free_data(%struct.NotifyData* %26)
store i32 0, i32* %3
br label %154
28: ; preds = %22
%29 = call i32 (...) @show_version()
%30 = load %struct.NotifyData*, %struct.NotifyData** %6
%31 = call i32 @notif_free_data(%struct.NotifyData* %30)
store i32 0, i32* %3
br label %154
32: ; preds = %22
%33 = load %struct.NotifyData*, %struct.NotifyData** %6
%34 = call i32* @notif_get_id_file(%struct.NotifyData* %33)
%35 = icmp ne i32* %34, null
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
br label %151
38: ; preds = %32
%39 = load %struct.NotifyData*, %struct.NotifyData** %6
%40 = load i32, i32* @optarg
%41 = call i32 @atoi(i32 %40)
%42 = call i32 @notif_set_replaces_id(%struct.NotifyData* %39, i32 %41)
br label %92
43: ; preds = %22
%44 = load %struct.NotifyData*, %struct.NotifyData** %6
%45 = call i32 @notif_get_replaces_id(%struct.NotifyData* %44)
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
br label %151
49: ; preds = %43
%50 = load i32, i32* @optarg
%51 = call i32* @fopen(i32 %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
store i32* %51, i32** %9
%52 = load i32*, i32** %9
%53 = icmp eq i32* %52, null
br i1 %53, label %54, label %56
54: ; preds = %49
%55 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0))
br label %151
56: ; preds = %49
%57 = load %struct.NotifyData*, %struct.NotifyData** %6
%58 = load i32*, i32** %9
%59 = call i32 @notif_set_id_file(%struct.NotifyData* %57, i32* %58)
%60 = load %struct.NotifyData*, %struct.NotifyData** %6
%61 = call i32 @notif_set_replaces_id_from_file(%struct.NotifyData* %60)
br label %92
62: ; preds = %22
%63 = load i32, i32* @optarg
%64 = call i32 @parse_urgency(i32 %63)
store i32 %64, i32* %8
%65 = load i32, i32* %8
%66 = icmp eq i32 %65, -1
br i1 %66, label %67, label %69
67: ; preds = %62
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0))
br label %151
69: ; preds = %62
%70 = load %struct.NotifyData*, %struct.NotifyData** %6
%71 = load i32, i32* %8
%72 = call i32 @notif_set_urgency(%struct.NotifyData* %70, i32 %71)
br label %92
73: ; preds = %22
%74 = load %struct.NotifyData*, %struct.NotifyData** %6
%75 = load i32, i32* @optarg
%76 = call i32 @atoi(i32 %75)
%77 = call i32 @notif_set_expire_time(%struct.NotifyData* %74, i32 %76)
br label %92
78: ; preds = %22
%79 = load %struct.NotifyData*, %struct.NotifyData** %6
%80 = load i32, i32* @optarg
%81 = call i32 @notif_set_app_name(%struct.NotifyData* %79, i32 %80)
br label %92
82: ; preds = %22
%83 = load %struct.NotifyData*, %struct.NotifyData** %6
%84 = load i32, i32* @optarg
%85 = call i32 @notif_set_icon(%struct.NotifyData* %83, i32 %84)
br label %92
86: ; preds = %22
%87 = load %struct.NotifyData*, %struct.NotifyData** %6
%88 = load i32, i32* @optarg
%89 = call i32 @notif_set_category(%struct.NotifyData* %87, i32 %88)
br label %92
90: ; preds = %22
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.14, i64 0, i64 0))
br label %151
92: ; preds = %86, %82, %78, %73, %69, %56, %38
br label %17
93: ; preds = %17
br label %94
94: ; preds = %126, %93
%95 = load i32, i32* @optind
%96 = load i32, i32* %4
%97 = icmp slt i32 %95, %96
br i1 %97, label %98, label %129
98: ; preds = %94
%99 = load %struct.NotifyData*, %struct.NotifyData** %6
%100 = call i32* @notif_get_summary(%struct.NotifyData* %99)
%101 = icmp eq i32* %100, null
br i1 %101, label %102, label %110
102: ; preds = %98
%103 = load %struct.NotifyData*, %struct.NotifyData** %6
%104 = load i8**, i8*** %5
%105 = load i32, i32* @optind
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i8*, i8** %104, i64 %106
%108 = load i8*, i8** %107
%109 = call i32 @notif_set_summary(%struct.NotifyData* %103, i8* %108)
br label %125
110: ; preds = %98
%111 = load %struct.NotifyData*, %struct.NotifyData** %6
%112 = call i32* @notif_get_body(%struct.NotifyData* %111)
%113 = icmp eq i32* %112, null
br i1 %113, label %114, label %122
114: ; preds = %110
%115 = load %struct.NotifyData*, %struct.NotifyData** %6
%116 = load i8**, i8*** %5
%117 = load i32, i32* @optind
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds i8*, i8** %116, i64 %118
%120 = load i8*, i8** %119
%121 = call i32 @notif_set_body(%struct.NotifyData* %115, i8* %120)
br label %124
122: ; preds = %110
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.15, i64 0, i64 0))
br label %151
124: ; preds = %114
br label %125
125: ; preds = %124, %102
br label %126
126: ; preds = %125
%127 = load i32, i32* @optind
%128 = add nsw i32 %127, 1
store i32 %128, i32* @optind
br label %94
129: ; preds = %94
%130 = load %struct.NotifyData*, %struct.NotifyData** %6
%131 = call i64 @notif_validate_data(%struct.NotifyData* %130)
%132 = icmp ne i64 %131, 0
br i1 %132, label %133, label %148
133: ; preds = %129
%134 = load %struct.NotifyData*, %struct.NotifyData** %6
%135 = call i32 @notif_send_notification(%struct.NotifyData* %134)
store i32 %135, i32* %10
%136 = load i32, i32* %10
%137 = icmp eq i32 %136, -1
br i1 %137, label %138, label %142
138: ; preds = %133
%139 = call i8* (...) @notif_get_error_message()
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.16, i64 0, i64 0), i8* %139)
%141 = call i32 (...) @notif_free_error_message()
br label %151
142: ; preds = %133
%143 = load %struct.NotifyData*, %struct.NotifyData** %6
%144 = call i32* @notif_get_id_file(%struct.NotifyData* %143)
%145 = load i32, i32* %10
%146 = call i32 @fprintf(i32* %144, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0), i32 %145)
br label %147
147: ; preds = %142
br label %148
148: ; preds = %147, %129
%149 = load %struct.NotifyData*, %struct.NotifyData** %6
%150 = call i32 @notif_free_data(%struct.NotifyData* %149)
store i32 0, i32* %3
br label %154
151: ; preds = %138, %122, %90, %67, %54, %47, %36
%152 = load %struct.NotifyData*, %struct.NotifyData** %6
%153 = call i32 @notif_free_data(%struct.NotifyData* %152)
store i32 1, i32* %3
br label %154
154: ; preds = %151, %148, %28, %24, %13
%155 = load i32, i32* %3
ret i32 %155
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
%struct.NotifyData = type { i32 }
@main.options = internal global [10 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -127, i32 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8 -127, i32 0, i32 118 }, %struct.option { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32 0, i32 114 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 117 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8 -128, i32 0, i32 116 }, %struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i32 0, i32 0), i8 -128, i32 0, i32 97 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0), i8 -128, i32 0, i32 82 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i8 -128, i32 0, i32 105 }, %struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i32 0, i32 0), i8 -128, i32 0, i32 99 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [12 x i8] c"replaces-id\00"
@.str.3 = [8 x i8] c"urgency\00"
@.str.4 = [7 x i8] c"expire\00"
@.str.5 = [9 x i8] c"app-name\00"
@.str.6 = [8 x i8] c"id-file\00"
@.str.7 = [5 x i8] c"icon\00"
@.str.8 = [9 x i8] c"category\00"
@.str.9 = [17 x i8] c"hvr:R:u:t:a:i:c:\00"
@optarg = global i32 0
@.str.11 = [3 x i8] c"r+\00"
@.str.12 = [27 x i8] c"Could not open the id_file\00"
@optind = global i32 0
@.str.16 = [11 x i8] c"Error: %s\0A\00"
@.str.17 = [4 x i8] c"%i\0A\00"
@str = [20 x i8] c"Too many arguments!\00"
@str.18 = [23 x i8] c"Invalid urgency value!\00"
@str.20 = [35 x i8] c"-r and -R are incompatible options\00"
@str.21 = [75 x i8] c"Usage:\0Anotify-desktop [OPTION...] <SUMMARY> [BODY] - create a notification\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @show_help()
br label %107
6: ; preds = %2
%7 = tail call %struct.NotifyData* (...) @notif_create_data()
br label %8
8: ; preds = %40, %6
%9 = tail call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), %struct.option* getelementptr inbounds ([10 x %struct.option], [10 x %struct.option]* @main.options, i64 0, i64 0), i32* null)
switch i32 %9, label %64 [
i32 -1, label %10
i32 104, label %13
i32 118, label %16
i32 114, label %19
i32 82, label %28
i32 117, label %43
i32 116, label %51
i32 97, label %55
i32 105, label %58
i32 99, label %61
]
10: ; preds = %8
%11 = load i32, i32* @optind
%12 = icmp slt i32 %11, %0
br i1 %12, label %66, label %90
13: ; preds = %8
%14 = tail call i32 (...) @show_help()
%15 = tail call i32 @notif_free_data(%struct.NotifyData* %7)
br label %107
16: ; preds = %8
%17 = tail call i32 (...) @show_version()
%18 = tail call i32 @notif_free_data(%struct.NotifyData* %7)
br label %107
19: ; preds = %8
%20 = tail call i32* @notif_get_id_file(%struct.NotifyData* %7)
%21 = icmp eq i32* %20, null
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.20, i64 0, i64 0))
br label %105
24: ; preds = %19
%25 = load i32, i32* @optarg
%26 = tail call i32 @atoi(i32 %25)
%27 = tail call i32 @notif_set_replaces_id(%struct.NotifyData* %7, i32 %26)
br label %40
28: ; preds = %8
%29 = tail call i32 @notif_get_replaces_id(%struct.NotifyData* %7)
%30 = icmp eq i32 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.20, i64 0, i64 0))
br label %105
33: ; preds = %28
%34 = load i32, i32* @optarg
%35 = tail call i32* @fopen(i32 %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%36 = icmp eq i32* %35, null
br i1 %36, label %41, label %37
37: ; preds = %33
%38 = tail call i32 @notif_set_id_file(%struct.NotifyData* %7, i32* %35)
%39 = tail call i32 @notif_set_replaces_id_from_file(%struct.NotifyData* %7)
br label %40
40: ; preds = %37, %61, %58, %55, %51, %49, %24
br label %8
41: ; preds = %33
%42 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0))
br label %105
43: ; preds = %8
%44 = load i32, i32* @optarg
%45 = tail call i32 @parse_urgency(i32 %44)
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.18, i64 0, i64 0))
br label %105
49: ; preds = %43
%50 = tail call i32 @notif_set_urgency(%struct.NotifyData* %7, i32 %45)
br label %40
51: ; preds = %8
%52 = load i32, i32* @optarg
%53 = tail call i32 @atoi(i32 %52)
%54 = tail call i32 @notif_set_expire_time(%struct.NotifyData* %7, i32 %53)
br label %40
55: ; preds = %8
%56 = load i32, i32* @optarg
%57 = tail call i32 @notif_set_app_name(%struct.NotifyData* %7, i32 %56)
br label %40
58: ; preds = %8
%59 = load i32, i32* @optarg
%60 = tail call i32 @notif_set_icon(%struct.NotifyData* %7, i32 %59)
br label %40
61: ; preds = %8
%62 = load i32, i32* @optarg
%63 = tail call i32 @notif_set_category(%struct.NotifyData* %7, i32 %62)
br label %40
64: ; preds = %8
%65 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @str.21, i64 0, i64 0))
br label %105
66: ; preds = %10, %86
%67 = tail call i32* @notif_get_summary(%struct.NotifyData* %7)
%68 = icmp eq i32* %67, null
br i1 %68, label %69, label %75
69: ; preds = %66
%70 = load i32, i32* @optind
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8*, i8** %1, i64 %71
%73 = load i8*, i8** %72
%74 = tail call i32 @notif_set_summary(%struct.NotifyData* %7, i8* %73)
br label %86
75: ; preds = %66
%76 = tail call i32* @notif_get_body(%struct.NotifyData* %7)
%77 = icmp eq i32* %76, null
br i1 %77, label %78, label %84
78: ; preds = %75
%79 = load i32, i32* @optind
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8*, i8** %1, i64 %80
%82 = load i8*, i8** %81
%83 = tail call i32 @notif_set_body(%struct.NotifyData* %7, i8* %82)
br label %86
84: ; preds = %75
%85 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %105
86: ; preds = %69, %78
%87 = load i32, i32* @optind
%88 = add nsw i32 %87, 1
store i32 %88, i32* @optind
%89 = icmp slt i32 %88, %0
br i1 %89, label %66, label %90
90: ; preds = %86, %10
%91 = tail call i64 @notif_validate_data(%struct.NotifyData* %7)
%92 = icmp eq i64 %91, 0
br i1 %92, label %103, label %93
93: ; preds = %90
%94 = tail call i32 @notif_send_notification(%struct.NotifyData* %7)
%95 = icmp eq i32 %94, -1
br i1 %95, label %99, label %96
96: ; preds = %93
%97 = tail call i32* @notif_get_id_file(%struct.NotifyData* %7)
%98 = tail call i32 @fprintf(i32* %97, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0), i32 %94)
br label %103
99: ; preds = %93
%100 = tail call i8* (...) @notif_get_error_message()
%101 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.16, i64 0, i64 0), i8* %100)
%102 = tail call i32 (...) @notif_free_error_message()
br label %105
103: ; preds = %96, %90
%104 = tail call i32 @notif_free_data(%struct.NotifyData* %7)
br label %107
105: ; preds = %99, %41, %84, %64, %47, %31, %22
%106 = tail call i32 @notif_free_data(%struct.NotifyData* %7)
br label %107
107: ; preds = %105, %103, %16, %13, %4
%108 = phi i32 [ 1, %4 ], [ 1, %105 ], [ 0, %16 ], [ 0, %13 ], [ 0, %103 ]
ret i32 %108
}