#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 */
scalar_t__ PATH_MAX;
int /*<<< orphan*/ snprintf(char *, scalar_t__, char *, char *, char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    return -1;
  }
  if (strlen(argv[1]) + strlen(argv[2]) > PATH_MAX) {
    return -1;
  }
  int i;
  char buf[PATH_MAX + 25];
  snprintf(buf, PATH_MAX + 25, "echo %s %s >> %s", argv[1], argv[2],
           "/opt/share/noti/pm_event");
  system(buf);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     115c <main+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1219 <main+0xe9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
add    %rcx,%rax
mov    0x2e65(%rip),%rcx
cmp    (%rcx),%rax
jle    11a0 <main+0x70>
movl   $0xffffffff,-0x4(%rbp)
jmp    1219 <main+0xe9>
mov    0x2e49(%rip),%rax
mov    (%rax),%rcx
mov    %rcx,%rax
add    $0x19,%rax
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
add    $0x28,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    0x2e18(%rip),%rax
mov    (%rax),%rsi
add    $0x19,%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r8
lea    0xe0a(%rip),%rdx
lea    0xe14(%rip),%r9
call   1050 <snprintf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <system@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%ebx
cmp    $0x3,%edi
jne    11b7 <main+0x87>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   1030 <strlen@plt>
mov    %rax,%r15
mov    0x10(%r14),%rdi
call   1030 <strlen@plt>
add    %r15,%rax
mov    0x2e8a(%rip),%rcx
mov    (%rcx),%rdx
cmp    %rdx,%rax
jg     11b7 <main+0x87>
mov    %rsp,%r15
mov    %rsp,%rbx
add    $0x28,%rdx
and    $0xfffffffffffffff0,%rdx
sub    %rdx,%rbx
mov    %rbx,%rsp
mov    (%rcx),%rsi
add    $0x19,%rsi
mov    0x8(%r14),%rcx
mov    0x10(%r14),%r8
lea    0xe68(%rip),%rdx
lea    0xe72(%rip),%r9
mov    %rbx,%rdi
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    $0x1,%ebx
mov    %r15,%rsp
mov    %ebx,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i64 0
@.str = [17 x i8] c"echo %s %s >> %s\00"
@.str.1 = [25 x i8] c"/opt/share/noti/pm_event\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %41
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @strlen(i8* %15)
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i64 @strlen(i8* %19)
%21 = add nsw i64 %16, %20
%22 = load i64, i64* @PATH_MAX
%23 = icmp sgt i64 %21, %22
br i1 %23, label %24, label %25
24: ; preds = %12
store i32 -1, i32* %3
br label %41
25: ; preds = %12
%26 = load i64, i64* @PATH_MAX
%27 = add nsw i64 %26, 25
%28 = call i8* @llvm.stacksave()
store i8* %28, i8** %7
%29 = alloca i8, i64 %27
store i64 %27, i64* %8
%30 = load i64, i64* @PATH_MAX
%31 = add nsw i64 %30, 25
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 @snprintf(i8* %29, i64 %31, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %34, i8* %37, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%39 = call i32 @system(i8* %29)
store i32 1, i32* %3
%40 = load i8*, i8** %7
br label %41
41: ; preds = %25, %24, %11
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@PATH_MAX = global i64 0
@.str = [17 x i8] c"echo %s %s >> %s\00"
@.str.1 = [25 x i8] c"/opt/share/noti/pm_event\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %24
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strlen(i8* dereferenceable(1) %6)
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i64 @strlen(i8* dereferenceable(1) %9)
%11 = add nsw i64 %10, %7
%12 = load i64, i64* @PATH_MAX
%13 = icmp sgt i64 %11, %12
br i1 %13, label %24, label %14
14: ; preds = %4
%15 = add nsw i64 %12, 25
%16 = tail call i8* @llvm.stacksave()
%17 = alloca i8, i64 %15
%18 = load i64, i64* @PATH_MAX
%19 = add nsw i64 %18, 25
%20 = load i8*, i8** %5
%21 = load i8*, i8** %8
%22 = call i32 @snprintf(i8* %17, i64 %19, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %20, i8* %21, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @system(i8* %17)
br label %24
24: ; preds = %4, %2, %14
%25 = phi i32 [ 1, %14 ], [ -1, %2 ], [ -1, %4 ]
ret i32 %25
}