#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 */
typedef int /*<<< orphan*/ cmd;

/* Variables and functions */
int /*<<< orphan*/ execl(char *, char *, char *, char *, char *);
int /*<<< orphan*/ get_filename(char *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int strlen(char *);
void write_note(char *path, char *name) {
  char cmd[100];
  size_t len = (strlen("vis") + strlen(path) + 1);
  get_filename(path, name);
  if (len > sizeof(cmd))
    puts("WARNING:Filepath truncated. Filename likely too long.");
  snprintf(cmd, sizeof(cmd), "%s %s", "vis", path);
  execl("/bin/sh", "sh", "-c", cmd, (char *)NULL);
}


x86 assembly (clang, -O0):
<write_note>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe96(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x8c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x8c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
mov    %rax,-0x88(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <get_filename@plt>
cmpq   $0x64,-0x88(%rbp)
64
jbe    11bb <write_note+0x6b>
lea    0xe4e(%rip),%rdi
call   1040 <puts@plt>
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%r8
mov    $0x64,%esi
lea    0xe6b(%rip),%rdx
lea    0xe2a(%rip),%rcx
call   1060 <snprintf@plt>
lea    -0x80(%rbp),%rcx
lea    0xe5a(%rip),%rdi
lea    0xe58(%rip),%rsi
lea    0xe54(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1070 <execl@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_note>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe98(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <get_filename@plt>
lea    (%r15,%r12,1),%eax
add    $0xffffff9c,%eax
cmp    $0xffffff9a,%eax
ja     119e <write_note+0x4e>
lea    0xe6b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe95(%rip),%rdx
lea    0xe54(%rip),%rcx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x64,%esi
mov    %rbx,%r8
call   1060 <snprintf@plt>
lea    0xe7a(%rip),%rdi
lea    0xe78(%rip),%rsi
lea    0xe74(%rip),%rdx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1070 <execl@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"vis\00"
@.str.1 = [54 x i8] c"WARNING:Filepath truncated. Filename likely too long.\00"
@.str.2 = [6 x i8] c"%s %s\00"
@.str.3 = [8 x i8] c"/bin/sh\00"
@.str.4 = [3 x i8] c"sh\00"
@.str.5 = [3 x i8] c"-c\00"
define void @write_note(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [100 x i8]
%6 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = add nsw i32 %7, %9
%11 = add nsw i32 %10, 1
%12 = sext i32 %11 to i64
store i64 %12, i64* %6
%13 = load i8*, i8** %3
%14 = load i8*, i8** %4
%15 = call i32 @get_filename(i8* %13, i8* %14)
%16 = load i64, i64* %6
%17 = icmp ugt i64 %16, 100
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 @puts(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %2
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%22 = load i8*, i8** %3
%23 = call i32 @snprintf(i8* %21, i32 100, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%25 = call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %24, i8* null)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"vis\00"
@.str.1 = [54 x i8] c"WARNING:Filepath truncated. Filename likely too long.\00"
@.str.2 = [6 x i8] c"%s %s\00"
@.str.3 = [8 x i8] c"/bin/sh\00"
@.str.4 = [3 x i8] c"sh\00"
@.str.5 = [3 x i8] c"-c\00"
define void @write_note(i8* %0, i8* %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @strlen(i8* %0)
%7 = tail call i32 @get_filename(i8* %0, i8* %1)
%8 = add i32 %5, -100
%9 = add i32 %8, %6
%10 = icmp ult i32 %9, -101
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
%14 = call i32 @snprintf(i8* %4, i32 100, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%15 = call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %4, i8* null)
ret void
}