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

/* Variables and functions */
int /*<<< orphan*/ EOF;
int EXIT_FAILURE;
int /*<<< orphan*/ PR_SET_PDEATHSIG;
int /*<<< orphan*/ SIGHUP;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ getline(char **, size_t *, int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ prctl(int /*<<< orphan*/, int /*<<< orphan*/,
                         int /*<<< orphan*/, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, ...);
int rand();
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int strlen(char *);
int system(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ unlink(char *);
int main(int argc, char **argv) {
  int return_val = 0;
  char *new_command = NULL;
  char *tmp_folder = "/tmp";
  char *output_path = NULL;
  FILE *f = NULL;
  char *line = NULL;
  int random_number = 0;
  size_t len = 0;
  ssize_t read;
  if (argc < 2) {
    printf("%s: \"command <arguments>\" \"<newline-chars>\" \"<tmp-folder>\" "
           "\"<print-before>\" \"<print-after>\"\n",
           argv[0]);
    return EXIT_FAILURE;
  }
  if (argc > 3) {
    tmp_folder = argv[3];
  }
  prctl(PR_SET_PDEATHSIG, SIGHUP, 0, 0, 0);
  srand(time(NULL));
  random_number = rand() % 100000000;
  output_path = malloc(strlen(tmp_folder) + 24);
  sprintf(output_path, "%s/.monitor_%08d_time", tmp_folder, random_number);
  new_command = malloc(26 + strlen(output_path) + strlen(argv[1]));
  if (argc > 2) {
    sprintf(new_command, "/usr/bin/env time -v -o %s %s", output_path, argv[1]);
  } else {
    sprintf(new_command, "/usr/bin/env time -v %s", argv[1]);
  }
  return_val = system(new_command);
  if (return_val < 0) {
    printf("%s: failed launching %s\n", argv[0], argv[1]);
    return EXIT_FAILURE;
  }
  if (argc > 2) {
    f = fopen(output_path, "r");
    if (f == NULL) {
      exit(EXIT_FAILURE);
    }
    if (argc > 4) {
      printf("%s", argv[4]);
    }
    while ((read = getline(&line, &len, f)) != EOF) {
      len = strlen(line) - 1;
      if (len >= 0) {
        line[len] = '\0';
      }
      printf("%s%s", line, argv[2]);
    }
    fclose(f);
    free(line);
    if (argc > 5) {
      printf("%s\n", argv[5]);
      fflush(stdout);
    }
    unlink(output_path);
  }
  free(new_command);
  return return_val;
}


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)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xdd4(%rip),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movq   $0x0,-0x50(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1287 <main+0x87>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2d4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14e3 <main+0x2e3>
cmpl   $0x3,-0x8(%rbp)
jle    129d <main+0x9d>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2d2c(%rip),%rax
mov    (%rax),%edi
mov    0x2d43(%rip),%rax
mov    (%rax),%esi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   10a0 <prctl@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <time@plt>
mov    %eax,%edi
call   1090 <srand@plt>
mov    $0x0,%al
call   1120 <rand@plt>
mov    $0x5f5e100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x44(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%edi
add    $0x18,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x44(%rbp),%ecx
lea    0xd5a(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x1a,%eax
mov    %eax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    -0x58(%rbp),%edi
add    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1366 <main+0x166>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xd1e(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
jmp    1380 <main+0x180>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd1d(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
mov    -0x20(%rbp),%rdi
call   1070 <system@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    13c4 <main+0x1c4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd02(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2c0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14e3 <main+0x2e3>
cmpl   $0x2,-0x8(%rbp)
jle    14d4 <main+0x2d4>
mov    -0x30(%rbp),%rdi
lea    0xcee(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    13fb <main+0x1fb>
mov    0x2bd4(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jle    141b <main+0x21b>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
lea    0xc7f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1420 <main+0x220>
mov    -0x38(%rbp),%rdx
lea    -0x40(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   10f0 <getline@plt>
mov    %eax,-0x54(%rbp)
mov    0x2ba5(%rip),%rcx
cmp    (%rcx),%eax
je     148b <main+0x28b>
mov    -0x40(%rbp),%rdi
call   1060 <strlen@plt>
sub    $0x1,%eax
cltq
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jb     146c <main+0x26c>
mov    -0x40(%rbp),%rax
mov    -0x50(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x40(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xc4a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1420 <main+0x220>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x5,-0x8(%rbp)
jle    14cb <main+0x2cb>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rsi
lea    0xc0d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2afc(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    -0x30(%rbp),%rdi
call   1040 <unlink@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r13
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
cmp    $0x1,%edi
jg     123e <main+0x3e>
mov    0x0(%r13),%rsi
lea    0xdd3(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1470 <main+0x270>
mov    %edi,%r15d
cmp    $0x4,%edi
jb     124c <main+0x4c>
mov    0x18(%r13),%r14
jmp    1253 <main+0x53>
lea    0xdad(%rip),%r14
mov    0x2d76(%rip),%rax
mov    (%rax),%edi
mov    0x2d8d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10a0 <prctl@plt>
xor    %edi,%edi
call   10b0 <time@plt>
mov    %eax,%edi
call   1090 <srand@plt>
xor    %eax,%eax
call   1120 <rand@plt>
movslq %eax,%rbp
imul   $0x55e63b89,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x39,%rax
add    %ecx,%eax
imul   $0x5f5e100,%eax,%eax
sub    %eax,%ebp
mov    %r14,%rdi
call   1060 <strlen@plt>
lea    0x18(%rax),%edi
call   10c0 <malloc@plt>
mov    %rax,%r12
lea    0xda3(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1100 <sprintf@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    0x8(%r13),%rdi
call   1060 <strlen@plt>
lea    (%rax,%rbp,1),%edi
add    $0x1a,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbx
mov    0x8(%r13),%rcx
cmp    $0x3,%r15d
jb     142e <main+0x22e>
lea    0xd74(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1100 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <system@plt>
test   %eax,%eax
js     145a <main+0x25a>
mov    %eax,%r14d
lea    0xd9c(%rip),%rsi
mov    %r12,%rdi
call   10e0 <fopen@plt>
test   %rax,%rax
je     148a <main+0x28a>
mov    %rax,%rbp
mov    %r14d,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r12,0x20(%rsp)
mov    %r15d,0x14(%rsp)
cmp    $0x5,%r15d
jb     136b <main+0x16b>
mov    0x20(%r13),%rsi
lea    0xd2f(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %rbp,%rdx
call   10f0 <getline@plt>
mov    0x2c5e(%rip),%rbx
cmp    (%rbx),%eax
je     13e1 <main+0x1e1>
lea    0xd3c(%rip),%r15
mov    %rsp,%r14
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rsp),%rdi
call   1060 <strlen@plt>
cltq
lea    -0x1(%rax),%rcx
mov    %rcx,0x8(%rsp)
mov    (%rsp),%rcx
movb   $0x0,-0x1(%rcx,%rax,1)
mov    (%rsp),%rsi
mov    0x10(%r13),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   10f0 <getline@plt>
cmp    (%rbx),%eax
jne    13a0 <main+0x1a0>
mov    %rbp,%rdi
call   1050 <fclose@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
cmpl   $0x6,0x14(%rsp)
jl     1419 <main+0x219>
mov    0x28(%r13),%rsi
lea    0xcbf(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2bae(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    0x20(%rsp),%rdi
call   1040 <unlink@plt>
mov    0x18(%rsp),%rbx
mov    0x10(%rsp),%ebp
jmp    1450 <main+0x250>
lea    0xc61(%rip),%rsi
mov    %rbx,%rdi
mov    %rcx,%rdx
xor    %eax,%eax
call   1100 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <system@plt>
mov    %eax,%ebp
test   %eax,%eax
js     145a <main+0x25a>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1479 <main+0x279>
mov    0x0(%r13),%rsi
mov    0x8(%r13),%rdx
lea    0xc45(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2b51(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b37(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"/tmp\00"
@.str.1 = [93 x i8] c"%s: \22command <arguments>\22 \22<newline-chars>\22 \22<tmp-folder>\22 \22<print-before>\22 \22<print-after>\22\0A\00"
@EXIT_FAILURE = global i32 0
@PR_SET_PDEATHSIG = global i32 0
@SIGHUP = global i32 0
@.str.2 = [22 x i8] c"%s/.monitor_%08d_time\00"
@.str.3 = [30 x i8] c"/usr/bin/env time -v -o %s %s\00"
@.str.4 = [24 x i8] c"/usr/bin/env time -v %s\00"
@.str.5 = [25 x i8] c"%s: failed launching %s\0A\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [3 x i8] c"%s\00"
@EOF = global i32 0
@.str.8 = [5 x i8] c"%s%s\00"
@.str.9 = [4 x i8] c"%s\0A\00"
@stdout = global i32 0
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 i8*
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i64
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i8* null, i8** %7
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %8
store i8* null, i8** %9
store i32* null, i32** %10
store i8* null, i8** %11
store i32 0, i32* %12
store i64 0, i64* %13
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %23
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
store i32 %22, i32* %3
br label %147
23: ; preds = %2
%24 = load i32, i32* %4
%25 = icmp sgt i32 %24, 3
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 3
%29 = load i8*, i8** %28
store i8* %29, i8** %8
br label %30
30: ; preds = %26, %23
%31 = load i32, i32* @PR_SET_PDEATHSIG
%32 = load i32, i32* @SIGHUP
%33 = call i32 @prctl(i32 %31, i32 %32, i32 0, i32 0, i32 0)
%34 = call i32 @time(i32* null)
%35 = call i32 @srand(i32 %34)
%36 = call i32 (...) @rand()
%37 = srem i32 %36, 100000000
store i32 %37, i32* %12
%38 = load i8*, i8** %8
%39 = call i32 @strlen(i8* %38)
%40 = add nsw i32 %39, 24
%41 = call i8* @malloc(i32 %40)
store i8* %41, i8** %9
%42 = load i8*, i8** %9
%43 = load i8*, i8** %8
%44 = load i32, i32* %12
%45 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %42, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %43, i32 %44)
%46 = load i8*, i8** %9
%47 = call i32 @strlen(i8* %46)
%48 = add nsw i32 26, %47
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = call i32 @strlen(i8* %51)
%53 = add nsw i32 %48, %52
%54 = call i8* @malloc(i32 %53)
store i8* %54, i8** %7
%55 = load i32, i32* %4
%56 = icmp sgt i32 %55, 2
br i1 %56, label %57, label %64
57: ; preds = %30
%58 = load i8*, i8** %7
%59 = load i8*, i8** %9
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 1
%62 = load i8*, i8** %61
%63 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %58, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %59, i8* %62)
br label %70
64: ; preds = %30
%65 = load i8*, i8** %7
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 1
%68 = load i8*, i8** %67
%69 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %65, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %68)
br label %70
70: ; preds = %64, %57
%71 = load i8*, i8** %7
%72 = call i32 @system(i8* %71)
store i32 %72, i32* %6
%73 = load i32, i32* %6
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %84
75: ; preds = %70
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 0
%78 = load i8*, i8** %77
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 1
%81 = load i8*, i8** %80
%82 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %78, i8* %81)
%83 = load i32, i32* @EXIT_FAILURE
store i32 %83, i32* %3
br label %147
84: ; preds = %70
%85 = load i32, i32* %4
%86 = icmp sgt i32 %85, 2
br i1 %86, label %87, label %143
87: ; preds = %84
%88 = load i8*, i8** %9
%89 = call i32* @fopen(i8* %88, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %89, i32** %10
%90 = load i32*, i32** %10
%91 = icmp eq i32* %90, null
br i1 %91, label %92, label %95
92: ; preds = %87
%93 = load i32, i32* @EXIT_FAILURE
%94 = call i32 @exit(i32 %93)
unreachable
95: ; preds = %87
%96 = load i32, i32* %4
%97 = icmp sgt i32 %96, 4
br i1 %97, label %98, label %103
98: ; preds = %95
%99 = load i8**, i8*** %5
%100 = getelementptr inbounds i8*, i8** %99, i64 4
%101 = load i8*, i8** %100
%102 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %101)
br label %103
103: ; preds = %98, %95
br label %104
104: ; preds = %120, %103
%105 = load i32*, i32** %10
%106 = call i32 @getline(i8** %11, i64* %13, i32* %105)
store i32 %106, i32* %14
%107 = load i32, i32* @EOF
%108 = icmp ne i32 %106, %107
br i1 %108, label %109, label %126
109: ; preds = %104
%110 = load i8*, i8** %11
%111 = call i32 @strlen(i8* %110)
%112 = sub nsw i32 %111, 1
%113 = sext i32 %112 to i64
store i64 %113, i64* %13
%114 = load i64, i64* %13
%115 = icmp uge i64 %114, 0
br i1 %115, label %116, label %120
116: ; preds = %109
%117 = load i8*, i8** %11
%118 = load i64, i64* %13
%119 = getelementptr inbounds i8, i8* %117, i64 %118
store i8 0, i8* %119
br label %120
120: ; preds = %116, %109
%121 = load i8*, i8** %11
%122 = load i8**, i8*** %5
%123 = getelementptr inbounds i8*, i8** %122, i64 2
%124 = load i8*, i8** %123
%125 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %121, i8* %124)
br label %104
126: ; preds = %104
%127 = load i32*, i32** %10
%128 = call i32 @fclose(i32* %127)
%129 = load i8*, i8** %11
%130 = call i32 @free(i8* %129)
%131 = load i32, i32* %4
%132 = icmp sgt i32 %131, 5
br i1 %132, label %133, label %140
133: ; preds = %126
%134 = load i8**, i8*** %5
%135 = getelementptr inbounds i8*, i8** %134, i64 5
%136 = load i8*, i8** %135
%137 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %136)
%138 = load i32, i32* @stdout
%139 = call i32 @fflush(i32 %138)
br label %140
140: ; preds = %133, %126
%141 = load i8*, i8** %9
%142 = call i32 @unlink(i8* %141)
br label %143
143: ; preds = %140, %84
%144 = load i8*, i8** %7
%145 = call i32 @free(i8* %144)
%146 = load i32, i32* %6
store i32 %146, i32* %3
br label %147
147: ; preds = %143, %75, %17
%148 = load i32, i32* %3
ret i32 %148
}

LLVM IR (-O2):
@.str = [5 x i8] c"/tmp\00"
@.str.1 = [93 x i8] c"%s: \22command <arguments>\22 \22<newline-chars>\22 \22<tmp-folder>\22 \22<print-before>\22 \22<print-after>\22\0A\00"
@EXIT_FAILURE = global i32 0
@PR_SET_PDEATHSIG = global i32 0
@SIGHUP = global i32 0
@.str.2 = [22 x i8] c"%s/.monitor_%08d_time\00"
@.str.3 = [30 x i8] c"/usr/bin/env time -v -o %s %s\00"
@.str.4 = [24 x i8] c"/usr/bin/env time -v %s\00"
@.str.5 = [25 x i8] c"%s: failed launching %s\0A\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [3 x i8] c"%s\00"
@EOF = global i32 0
@.str.8 = [5 x i8] c"%s%s\00"
@.str.9 = [4 x i8] c"%s\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%7 = icmp slt i32 %0, 2
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @EXIT_FAILURE
br label %99
12: ; preds = %2
%13 = icmp ugt i32 %0, 3
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
br label %17
17: ; preds = %14, %12
%18 = phi i8* [ %16, %14 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %12 ]
%19 = load i32, i32* @PR_SET_PDEATHSIG
%20 = load i32, i32* @SIGHUP
%21 = tail call i32 @prctl(i32 %19, i32 %20, i32 0, i32 0, i32 0)
%22 = tail call i32 @time(i32* null)
%23 = tail call i32 @srand(i32 %22)
%24 = tail call i32 (...) @rand()
%25 = srem i32 %24, 100000000
%26 = tail call i32 @strlen(i8* %18)
%27 = add nsw i32 %26, 24
%28 = tail call i8* @malloc(i32 %27)
%29 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %28, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %18, i32 %25)
%30 = tail call i32 @strlen(i8* %28)
%31 = add nsw i32 %30, 26
%32 = getelementptr inbounds i8*, i8** %1, i64 1
%33 = load i8*, i8** %32
%34 = tail call i32 @strlen(i8* %33)
%35 = add nsw i32 %31, %34
%36 = tail call i8* @malloc(i32 %35)
%37 = icmp ugt i32 %0, 2
%38 = load i8*, i8** %32
br i1 %37, label %39, label %43
39: ; preds = %17
%40 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %36, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %28, i8* %38)
%41 = tail call i32 @system(i8* %36)
%42 = icmp slt i32 %41, 0
br i1 %42, label %47, label %52
43: ; preds = %17
%44 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %36, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %38)
%45 = tail call i32 @system(i8* %36)
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %96
47: ; preds = %43, %39
%48 = load i8*, i8** %1
%49 = load i8*, i8** %32
%50 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %48, i8* %49)
%51 = load i32, i32* @EXIT_FAILURE
br label %99
52: ; preds = %39
%53 = tail call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%54 = icmp eq i32* %53, null
br i1 %54, label %55, label %58
55: ; preds = %52
%56 = load i32, i32* @EXIT_FAILURE
%57 = tail call i32 @exit(i32 %56)
unreachable
58: ; preds = %52
%59 = icmp ugt i32 %0, 4
br i1 %59, label %60, label %64
60: ; preds = %58
%61 = getelementptr inbounds i8*, i8** %1, i64 4
%62 = load i8*, i8** %61
%63 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %62)
br label %64
64: ; preds = %60, %58
%65 = call i32 @getline(i8** %3, i64* %4, i32* %53)
%66 = load i32, i32* @EOF
%67 = icmp eq i32 %65, %66
br i1 %67, label %83, label %68
68: ; preds = %64
%69 = getelementptr inbounds i8*, i8** %1, i64 2
br label %70
70: ; preds = %68, %70
%71 = load i8*, i8** %3
%72 = call i32 @strlen(i8* %71)
%73 = add nsw i32 %72, -1
%74 = sext i32 %73 to i64
store i64 %74, i64* %4
%75 = load i8*, i8** %3
%76 = getelementptr inbounds i8, i8* %75, i64 %74
store i8 0, i8* %76
%77 = load i8*, i8** %3
%78 = load i8*, i8** %69
%79 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %77, i8* %78)
%80 = call i32 @getline(i8** %3, i64* %4, i32* %53)
%81 = load i32, i32* @EOF
%82 = icmp eq i32 %80, %81
br i1 %82, label %83, label %70
83: ; preds = %70, %64
%84 = call i32 @fclose(i32* %53)
%85 = load i8*, i8** %3
%86 = call i32 @free(i8* %85)
%87 = icmp sgt i32 %0, 5
br i1 %87, label %88, label %94
88: ; preds = %83
%89 = getelementptr inbounds i8*, i8** %1, i64 5
%90 = load i8*, i8** %89
%91 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %90)
%92 = load i32, i32* @stdout
%93 = call i32 @fflush(i32 %92)
br label %94
94: ; preds = %88, %83
%95 = call i32 @unlink(i8* %28)
br label %96
96: ; preds = %43, %94
%97 = phi i32 [ %41, %94 ], [ %45, %43 ]
%98 = call i32 @free(i8* %36)
br label %99
99: ; preds = %96, %47, %8
%100 = phi i32 [ %11, %8 ], [ %51, %47 ], [ %97, %96 ]
ret i32 %100
}