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

/* Variables and functions */
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ *fdopen(int, char *);
char *malloc(int);
int mkstemp(char *);
int read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strlcpy(char *, char *, int);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ unlink(char *);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  char ef[24] = {0};
  FILE *efp;
  int fd = -1;
  int n, rval, wval;
  char *bp;
  strlcpy(ef, "/tmp/ivox.XXXXXX", sizeof ef);
  fd = mkstemp(ef);
  efp = fdopen(fd, "w+");
  char *buf;
  buf = malloc(sizeof(char) * 1024);
  while ((rval = read(STDIN_FILENO, buf, 1024)) > 0) {
    n = rval;
    bp = buf;
    do {
      wval = write(fd, bp, n);
      bp += wval;
    } while (n -= wval);
  }
  close(fd);
  char cmd[1024] = {0};
  sprintf(cmd, "/home/da3m0n8t3r/elmboxo/elmboxo \"%s\"", ef);
  system(cmd);
  unlink(ef);
  return (1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1060 <memset@plt>
movl   $0xffffffff,-0x3c(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe15(%rip),%rsi
mov    $0x18,%edx
call   10b0 <strlcpy@plt>
lea    -0x30(%rbp),%rdi
call   10a0 <mkstemp@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
lea    0xe06(%rip),%rsi
call   10c0 <fdopen@plt>
mov    %rax,-0x38(%rbp)
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
mov    -0x58(%rbp),%rsi
mov    $0x400,%edx
call   1080 <read@plt>
mov    %eax,-0x44(%rbp)
cmp    $0x0,%eax
jle    128f <main+0xdf>
mov    -0x44(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    -0x40(%rbp),%edx
call   1040 <write@plt>
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%ecx
mov    -0x40(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x40(%rbp)
cmp    $0x0,%eax
jne    1253 <main+0xa3>
jmp    1222 <main+0x72>
mov    -0x3c(%rbp),%edi
call   1070 <close@plt>
lea    -0x460(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0x460(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xd58(%rip),%rsi
call   10d0 <sprintf@plt>
lea    -0x460(%rbp),%rdi
call   1050 <system@plt>
lea    -0x30(%rbp),%rdi
call   1030 <unlink@plt>
mov    $0x1,%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x420,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xe2a(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x18,%edx
call   10b0 <strlcpy@plt>
mov    %rbx,%rdi
call   10a0 <mkstemp@plt>
mov    %eax,%r15d
lea    0xe19(%rip),%rsi
mov    %eax,%edi
call   10c0 <fdopen@plt>
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    0x2dcd(%rip),%r12
mov    (%r12),%edi
mov    %rax,%rsi
mov    $0x400,%edx
call   1080 <read@plt>
test   %eax,%eax
jle    1260 <main+0xb0>
mov    %eax,%ebp
mov    %r14,%rbx
nopl   (%rax)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <write@plt>
cltq
add    %rax,%rbx
sub    %eax,%ebp
jne    1230 <main+0x80>
mov    (%r12),%edi
mov    %r14,%rsi
mov    $0x400,%edx
call   1080 <read@plt>
mov    %eax,%ebp
mov    %r14,%rbx
test   %eax,%eax
jg     1230 <main+0x80>
mov    %r15d,%edi
call   1070 <close@plt>
lea    0x20(%rsp),%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xd91(%rip),%rsi
mov    %rsp,%rbp
mov    %rbx,%rdi
mov    %rbp,%rdx
call   10d0 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
mov    %rbp,%rdi
call   1030 <unlink@plt>
mov    $0x1,%eax
add    $0x420,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"/tmp/ivox.XXXXXX\00"
@.str.1 = [3 x i8] c"w+\00"
@STDIN_FILENO = global i32 0
@.str.2 = [38 x i8] c"/home/da3m0n8t3r/elmboxo/elmboxo \22%s\22\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [24 x i8]
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = bitcast [24 x i8]* %6 to i8*
store i32 -1, i32* %8
%16 = getelementptr inbounds [24 x i8], [24 x i8]* %6, i64 0, i64 0
%17 = call i32 @strlcpy(i8* %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 24)
%18 = getelementptr inbounds [24 x i8], [24 x i8]* %6, i64 0, i64 0
%19 = call i32 @mkstemp(i8* %18)
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = call i32* @fdopen(i32 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %7
%22 = call i8* @malloc(i32 1024)
store i8* %22, i8** %13
br label %23
23: ; preds = %45, %2
%24 = load i32, i32* @STDIN_FILENO
%25 = load i8*, i8** %13
%26 = call i32 @read(i32 %24, i8* %25, i32 1024)
store i32 %26, i32* %10
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %46
28: ; preds = %23
%29 = load i32, i32* %10
store i32 %29, i32* %9
%30 = load i8*, i8** %13
store i8* %30, i8** %12
br label %31
31: ; preds = %40, %28
%32 = load i32, i32* %8
%33 = load i8*, i8** %12
%34 = load i32, i32* %9
%35 = call i32 @write(i32 %32, i8* %33, i32 %34)
store i32 %35, i32* %11
%36 = load i32, i32* %11
%37 = load i8*, i8** %12
%38 = sext i32 %36 to i64
%39 = getelementptr inbounds i8, i8* %37, i64 %38
store i8* %39, i8** %12
br label %40
40: ; preds = %31
%41 = load i32, i32* %11
%42 = load i32, i32* %9
%43 = sub nsw i32 %42, %41
store i32 %43, i32* %9
%44 = icmp ne i32 %43, 0
br i1 %44, label %31, label %45
45: ; preds = %40
br label %23
46: ; preds = %23
%47 = load i32, i32* %8
%48 = call i32 @close(i32 %47)
%49 = bitcast [1024 x i8]* %14 to i8*
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%51 = getelementptr inbounds [24 x i8], [24 x i8]* %6, i64 0, i64 0
%52 = call i32 @sprintf(i8* %50, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %51)
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%54 = call i32 @system(i8* %53)
%55 = getelementptr inbounds [24 x i8], [24 x i8]* %6, i64 0, i64 0
%56 = call i32 @unlink(i8* %55)
ret i32 1
}

LLVM IR (-O2):
@.str = [17 x i8] c"/tmp/ivox.XXXXXX\00"
@.str.1 = [3 x i8] c"w+\00"
@STDIN_FILENO = global i32 0
@.str.2 = [38 x i8] c"/home/da3m0n8t3r/elmboxo/elmboxo \22%s\22\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [24 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 0
%6 = call i32 @strlcpy(i8* %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 24)
%7 = call i32 @mkstemp(i8* %5)
%8 = call i32* @fdopen(i32 %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%10 = load i32, i32* @STDIN_FILENO
%11 = call i32 @read(i32 %10, i8* %9, i32 1024)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %17, label %28
13: ; preds = %17
%14 = load i32, i32* @STDIN_FILENO
%15 = call i32 @read(i32 %14, i8* %9, i32 1024)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %25, label %28
17: ; preds = %2, %25
%18 = phi i32 [ %26, %25 ], [ %11, %2 ]
%19 = phi i8* [ %27, %25 ], [ %9, %2 ]
%20 = call i32 @write(i32 %7, i8* %19, i32 %18)
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = sub nsw i32 %18, %20
%24 = icmp eq i32 %23, 0
br i1 %24, label %13, label %25
25: ; preds = %17, %13
%26 = phi i32 [ %23, %17 ], [ %15, %13 ]
%27 = phi i8* [ %22, %17 ], [ %9, %13 ]
br label %17
28: ; preds = %13, %2
%29 = call i32 @close(i32 %7)
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%31 = call i32 @sprintf(i8* %30, i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%32 = call i32 @system(i8* %30)
%33 = call i32 @unlink(i8* %5)
ret i32 1
}