#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*/ getenv(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ realpath(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, char *);
scalar_t__ strlen(char *);
int write(int /*<<< orphan*/, char *, scalar_t__);
int main(int argc, char **argv) {
  int i;
  if (!getenv("TERMINOLOGY"))
    return 0;
  if (argc <= 1) {
    printf("Usage: %s FILE1 [FILE2 ...]\n"
           "  Queue a given media file/uri to the popped up\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}pq%s", 0x1b, path);
    if (write(0, tbuf, strlen(tbuf) + 1) != (signed)(strlen(tbuf) + 1))
      perror("write");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe73(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%eax
jne    11a7 <main+0x37>
movl   $0x0,-0x4(%rbp)
jmp    12e3 <main+0x173>
cmpl   $0x1,-0x8(%rbp)
jg     11d0 <main+0x60>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe4d(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12e3 <main+0x173>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12dc <main+0x16c>
mov    0x2e06(%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     1263 <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    0xde2(%rip),%rdx
mov    $0x1b,%ecx
call   1070 <snprintf@plt>
mov    -0x40(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x40(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
xor    %edi,%edi
call   1040 <write@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,-0x54(%rbp)
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x54(%rbp),%eax
add    $0x1,%rcx
cmp    %ecx,%eax
je     12c7 <main+0x157>
lea    0xda0(%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    11d7 <main+0x67>
movl   $0x0,-0x4(%rbp)
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,-0x30(%rbp)
mov    %edi,%ebx
lea    0xe72(%rip),%rdi
call   1030 <getenv@plt>
test   %eax,%eax
je     11af <main+0x3f>
cmp    $0x2,%ebx
jge    11c0 <main+0x50>
mov    -0x30(%rbp),%rax
mov    (%rax),%rsi
lea    0xe62(%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,-0x38(%rbp)
mov    $0x1,%r12d
jmp    11de <main+0x6e>
xchg   %ax,%ax
mov    -0x40(%rbp),%rsp
add    $0x1,%r12
cmp    %r12,-0x38(%rbp)
je     11af <main+0x3f>
mov    %rsp,-0x40(%rbp)
mov    0x2e07(%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    -0x30(%rbp),%rax
mov    (%rax,%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    0xe1e(%rip),%rdx
mov    $0x1b,%ecx
mov    %rbx,%r8
call   1070 <snprintf@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdx
xor    %edi,%edi
mov    %r13,%rsi
call   1040 <write@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
cmp    %eax,%ebx
je     11d0 <main+0x60>
lea    0xde7(%rip),%rdi
call   1090 <perror@plt>
jmp    11d0 <main+0x60>

LLVM IR (-O0):
@.str = [12 x i8] c"TERMINOLOGY\00"
@.str.1 = [78 x i8] c"Usage: %s FILE1 [FILE2 ...]\0A Queue a given media file/uri to the popped up\0A\0A\00"
@PATH_MAX = global i32 0
@.str.2 = [8 x i8] c"%c}pq%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 %65
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 ([78 x i8], [78 x i8]* @.str.1, i64 0, i64 0), i8* %20)
store i32 0, i32* %3
br label %65
22: ; preds = %14
store i32 1, i32* %6
br label %23
23: ; preds = %61, %22
%24 = load i32, i32* %6
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %64
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 i64 @strlen(i8* %36)
%51 = add nsw i64 %50, 1
%52 = call i32 @write(i32 0, i8* %36, i64 %51)
%53 = call i64 @strlen(i8* %36)
%54 = add nsw i64 %53, 1
%55 = trunc i64 %54 to i32
%56 = icmp ne i32 %52, %55
br i1 %56, label %57, label %59
57: ; preds = %46
%58 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %59
59: ; preds = %57, %46
%60 = load i8*, i8** %8
br label %61
61: ; preds = %59
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
store i32 %63, i32* %6
br label %23
64: ; preds = %23
store i32 0, i32* %3
br label %65
65: ; preds = %64, %17, %13
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@.str = [12 x i8] c"TERMINOLOGY\00"
@.str.1 = [78 x i8] c"Usage: %s FILE1 [FILE2 ...]\0A Queue a given media file/uri to the popped up\0A\0A\00"
@PATH_MAX = global i32 0
@.str.2 = [8 x i8] c"%c}pq%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 %41, 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 ([78 x i8], [78 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %41
12: ; preds = %7, %38
%13 = phi i64 [ 1, %7 ], [ %39, %38 ]
%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 i64 @strlen(i8* %22)
%30 = add nsw i64 %29, 1
%31 = call i32 @write(i32 0, i8* %22, i64 %30)
%32 = call i64 @strlen(i8* %22)
%33 = trunc i64 %32 to i32
%34 = add i32 %33, 1
%35 = icmp eq i32 %31, %34
br i1 %35, label %38, label %36
36: ; preds = %12
%37 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %38
38: ; preds = %36, %12
%39 = add nuw nsw i64 %13, 1
%40 = icmp eq i64 %39, %8
br i1 %40, label %41, label %12
41: ; preds = %38, %2, %9
ret i32 0
}