#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*/ tbuf;

/* Variables and functions */
int PATH_MAX;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ getenv(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ realpath(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, char *);
int strlen(char *);
int write(int /*<<< orphan*/, char *, int);
int main(int argc, char **argv) {
  int i;
  if (!getenv("TERMINOLOGY"))
    return 0;
  if (argc <= 1) {
    printf("Usage: %s FILE1 [FILE2 ...]\n"
           "  Pop up a given media file/uri right now\n"
           "\n",
           argv[0]);
    return 0;
  }
  for (i = 1; i < argc; i++) {
    char *path, buf[PATH_MAX * 2], tbuf[PATH_MAX * 3];
    path = argv[i];
    if (realpath(path, buf))
      path = buf;
    snprintf(tbuf, sizeof(tbuf), "%c}pn%s", 0x1b, path);
    if (write(0, tbuf, strlen(tbuf)) < 1)
      perror("write");
    tbuf[0] = 0;
    if (write(0, tbuf, 1) < 1)
      perror("write");
  }
  exit(0);
  return 0;
}


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)
lea    0xe63(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%eax
jne    11b7 <main+0x37>
movl   $0x0,-0x4(%rbp)
jmp    1301 <main+0x181>
cmpl   $0x1,-0x8(%rbp)
jg     11e0 <main+0x60>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe3d(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1301 <main+0x181>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12fa <main+0x17a>
mov    0x2df6(%rip),%rax
mov    (%rax),%ecx
add    %ecx,%ecx
mov    %rsp,%rdx
mov    %rdx,-0x28(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rsi
sub    %rdx,%rsi
mov    %rsi,-0x50(%rbp)
mov    %rsi,%rsp
mov    %rcx,-0x30(%rbp)
mov    (%rax),%ecx
mov    %ecx,%eax
lea    (%rax,%rax,2),%eax
mov    %rax,-0x48(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <realpath@plt>
cmp    $0x0,%rax
je     1273 <main+0xf3>
mov    -0x50(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%esi
mov    -0x20(%rbp),%r8
lea    0xdcc(%rip),%rdx
mov    $0x1b,%ecx
call   1070 <snprintf@plt>
mov    -0x40(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
xor    %edi,%edi
call   1040 <write@plt>
cmp    $0x1,%eax
jge    12bd <main+0x13d>
lea    0xda4(%rip),%rdi
call   1090 <perror@plt>
mov    -0x40(%rbp),%rsi
movb   $0x0,(%rsi)
xor    %edi,%edi
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0x1,%eax
jge    12e5 <main+0x165>
lea    0xd7c(%rip),%rdi
call   1090 <perror@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e7 <main+0x67>
xor    %edi,%edi
call   10a0 <exit@plt>
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   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xe63(%rip),%rdi
call   1030 <getenv@plt>
test   %eax,%eax
je     11ba <main+0x3a>
cmp    $0x2,%ebx
jge    11cb <main+0x4b>
mov    (%r14),%rsi
lea    0xe57(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebx,%eax
mov    %rax,-0x30(%rbp)
mov    $0x1,%r12d
mov    %r14,-0x38(%rbp)
jmp    11f6 <main+0x76>
nopl   (%rax)
mov    -0x40(%rbp),%rsp
add    $0x1,%r12
cmp    %r12,-0x30(%rbp)
mov    -0x38(%rbp),%r14
je     12b0 <main+0x130>
mov    %rsp,-0x40(%rbp)
mov    0x2def(%rip),%rcx
mov    (%rcx),%eax
add    %eax,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    (%rcx),%eax
lea    (%rax,%rax,2),%r15d
lea    0xf(%r15),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r13
sub    %rax,%r13
mov    %r13,%rsp
mov    (%r14,%r12,8),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <realpath@plt>
test   %rax,%rax
cmove  %r14,%rbx
mov    %r13,%rdi
mov    %r15d,%esi
lea    0xe04(%rip),%rdx
mov    $0x1b,%ecx
mov    %rbx,%r8
call   1070 <snprintf@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
xor    %edi,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %eax,%eax
jle    12a2 <main+0x122>
movb   $0x0,0x0(%r13)
xor    %edi,%edi
mov    %r13,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
test   %eax,%eax
jg     11e0 <main+0x60>
lea    0xdc4(%rip),%rdi
call   1090 <perror@plt>
jmp    11e0 <main+0x60>
lea    0xdb3(%rip),%rdi
call   1090 <perror@plt>
jmp    1275 <main+0xf5>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"TERMINOLOGY\00"
@.str.1 = [72 x i8] c"Usage: %s FILE1 [FILE2 ...]\0A Pop up a given media file/uri right now\0A\0A\00"
@PATH_MAX = global i32 0
@.str.2 = [8 x i8] c"%c}pn%s\00"
@.str.3 = [6 x i8] c"write\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 i8*
%9 = alloca i64
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %2
store i32 0, i32* %3
br label %68
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp sle i32 %15, 1
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.1, i64 0, i64 0), i8* %20)
store i32 0, i32* %3
br label %68
22: ; preds = %14
store i32 1, i32* %6
br label %23
23: ; preds = %63, %22
%24 = load i32, i32* %6
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %66
27: ; preds = %23
%28 = load i32, i32* @PATH_MAX
%29 = mul nsw i32 %28, 2
%30 = zext i32 %29 to i64
%31 = call i8* @llvm.stacksave()
store i8* %31, i8** %8
%32 = alloca i8, i64 %30
store i64 %30, i64* %9
%33 = load i32, i32* @PATH_MAX
%34 = mul nsw i32 %33, 3
%35 = zext i32 %34 to i64
%36 = alloca i8, i64 %35
store i64 %35, i64* %10
%37 = load i8**, i8*** %5
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %37, i64 %39
%41 = load i8*, i8** %40
store i8* %41, i8** %7
%42 = load i8*, i8** %7
%43 = call i64 @realpath(i8* %42, i8* %32)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %27
store i8* %32, i8** %7
br label %46
46: ; preds = %45, %27
%47 = trunc i64 %35 to i32
%48 = load i8*, i8** %7
%49 = call i32 @snprintf(i8* %36, i32 %47, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 27, i8* %48)
%50 = call i32 @strlen(i8* %36)
%51 = call i32 @write(i32 0, i8* %36, i32 %50)
%52 = icmp slt i32 %51, 1
br i1 %52, label %53, label %55
53: ; preds = %46
%54 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %55
55: ; preds = %53, %46
%56 = getelementptr inbounds i8, i8* %36, i64 0
store i8 0, i8* %56
%57 = call i32 @write(i32 0, i8* %36, i32 1)
%58 = icmp slt i32 %57, 1
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %61
61: ; preds = %59, %55
%62 = load i8*, i8** %8
br label %63
63: ; preds = %61
%64 = load i32, i32* %6
%65 = add nsw i32 %64, 1
store i32 %65, i32* %6
br label %23
66: ; preds = %23
%67 = call i32 @exit(i32 0)
unreachable
68: ; preds = %17, %13
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@.str = [12 x i8] c"TERMINOLOGY\00"
@.str.1 = [72 x i8] c"Usage: %s FILE1 [FILE2 ...]\0A Pop up a given media file/uri right now\0A\0A\00"
@PATH_MAX = global i32 0
@.str.2 = [8 x i8] c"%c}pn%s\00"
@.str.3 = [6 x i8] c"write\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %44, label %5
5: ; preds = %2
%6 = icmp slt i32 %0, 2
br i1 %6, label %9, label %7
7: ; preds = %5
%8 = zext i32 %0 to i64
br label %12
9: ; preds = %5
%10 = load i8*, i8** %1
%11 = tail call i32 @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %44
12: ; preds = %7, %39
%13 = phi i64 [ 1, %7 ], [ %40, %39 ]
%14 = load i32, i32* @PATH_MAX
%15 = shl nsw i32 %14, 1
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
%18 = alloca i8, i64 %16
%19 = load i32, i32* @PATH_MAX
%20 = mul nsw i32 %19, 3
%21 = zext i32 %20 to i64
%22 = alloca i8, i64 %21
%23 = getelementptr inbounds i8*, i8** %1, i64 %13
%24 = load i8*, i8** %23
%25 = call i64 @realpath(i8* %24, i8* %18)
%26 = icmp eq i64 %25, 0
%27 = select i1 %26, i8* %24, i8* %18
%28 = call i32 @snprintf(i8* %22, i32 %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 27, i8* %27)
%29 = call i32 @strlen(i8* %22)
%30 = call i32 @write(i32 0, i8* %22, i32 %29)
%31 = icmp slt i32 %30, 1
br i1 %31, label %32, label %34
32: ; preds = %12
%33 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %12
store i8 0, i8* %22
%35 = call i32 @write(i32 0, i8* %22, i32 1)
%36 = icmp slt i32 %35, 1
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %39
39: ; preds = %37, %34
%40 = add nuw nsw i64 %13, 1
%41 = icmp eq i64 %40, %8
br i1 %41, label %42, label %12
42: ; preds = %39
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %2, %9
ret i32 0
}