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

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
scalar_t__ WEXITSTATUS(int);
int /*<<< orphan*/ WIFEXITED(int);
int /*<<< orphan*/ _exit(int);
int /*<<< orphan*/ close(int);
int dup2(int, int /*<<< orphan*/);
int /*<<< orphan*/ execl(char *, char *, char *, char const *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ fputs(char *, int /*<<< orphan*/ *);
int fread(char *, int, int, int /*<<< orphan*/ *);
long ftell(int /*<<< orphan*/ *);
char *getenv(char *);
int lseek(int /*<<< orphan*/, long, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ stderr;
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ unlink(char const *);
int /*<<< orphan*/ unsetenv(char *);
int waitpid(int, int *, int /*<<< orphan*/);
int transcode(const char *input, const char *output) {
  FILE *in_f = NULL;
  FILE *out_f = NULL;
  char buf[4096];
  char *p;
  int transcoded = 0;
  int is_mp3 = 0;
  in_f = fopen(input, "rb");
  if (!in_f) {
    perror(input);
    goto cleanup;
  }
  out_f = fopen(output, "wb");
  if (!out_f) {
    perror(output);
    goto cleanup;
  }
  while (1) {
    p = fgets(buf, 4096, in_f);
    if (!p) {
      perror("fgets");
      goto cleanup;
    }
    if (buf[0] == '\r' && buf[1] == '\n' && buf[2] == '\000')
      break;
    if (strncmp(buf, "content-type: ", 14) == 0) {
      p = buf + 14;
      if (strncmp(p, "audio/mpeg", 10) != 0 &&
          strncmp(p, "audio/mp3", 9) != 0) {
        fprintf(stderr, "not transcoding %s, not MP3\n", input);
        goto cleanup;
      }
      is_mp3 = 1;
      continue;
    }
    if (fputs(buf, out_f) == 0) {
      perror("fputs");
      goto cleanup;
    }
  }
  if (!is_mp3) {
    fprintf(stderr, "not transcoding %s, not MP3\n", input);
    goto cleanup;
  }
  if (fputs("content-type: application/ogg\r\n\r\n", out_f) == 0) {
    perror("fputs");
    goto cleanup;
  }
  fflush(out_f);
  long input_pos = ftell(in_f);
  int bytes_read = fread(buf, 1, 3, in_f);
  if (bytes_read == 3 && buf[0] == 'O' && buf[1] == 'g' && buf[2] == 'g') {
    fprintf(stderr,
            "File served as MP3, but looks like an OGG. Not transcoding.\n");
    goto cleanup;
  }
  fprintf(stderr, "Transcoding %s to %s\n", input, output);
  int in_fd = fileno(in_f);
  int out_fd = fileno(out_f);
  pid_t pid = fork();
  if (pid == -1) {
    perror("fork");
    goto cleanup;
  }
  if (pid == 0) {
    if (dup2(in_fd, STDIN_FILENO) == -1) {
      perror("dup2(stdin)");
      _exit(1);
    }
    close(in_fd);
    if (lseek(STDIN_FILENO, input_pos, SEEK_SET) == -1) {
      perror("lseek(stdin)");
      _exit(1);
    }
    if (dup2(out_fd, STDOUT_FILENO) == -1) {
      perror("dup2(stdout)");
      _exit(1);
    }
    unsetenv("LD_PRELOAD");
    const char *transcoder = getenv("YOUSICIAN_TRANSCODER");
    if (!transcoder)
      transcoder = "sox -t mp3 - -t ogg -";
    execl("/bin/sh", "sh", "-c", transcoder, (char *)0);
    perror("execl");
    _exit(1);
  } else {
    int wstatus;
    pid_t rpid = waitpid(pid, &wstatus, 0);
    if (rpid == -1) {
      perror("waitpid");
      goto cleanup;
    }
    if (!WIFEXITED(wstatus) || WEXITSTATUS(wstatus) != 0) {
      fprintf(stderr, "Transcoder failed!\n");
      goto cleanup;
    }
  }
  fprintf(stderr, "Transcoded!\n");
  transcoded = 1;
cleanup:
  if (in_f)
    fclose(in_f);
  if (out_f)
    fclose(out_f);
  if (!transcoded)
    unlink(output);
  return transcoded;
}


x86 assembly (clang, -O0):
<transcode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1060,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x102c(%rbp)
movl   $0x0,-0x1030(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xd4e(%rip),%rsi
call   1140 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12d4 <transcode+0x64>
mov    -0x8(%rbp),%rdi
call   1150 <perror@plt>
jmp    1774 <transcode+0x504>
mov    -0x10(%rbp),%rdi
lea    0xd24(%rip),%rsi
call   1140 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1301 <transcode+0x91>
mov    -0x10(%rbp),%rdi
call   1150 <perror@plt>
jmp    1774 <transcode+0x504>
jmp    1306 <transcode+0x96>
lea    -0x1020(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x1000,%esi
call   10d0 <fgets@plt>
mov    %rax,-0x1028(%rbp)
cmpq   $0x0,-0x1028(%rbp)
jne    1341 <transcode+0xd1>
lea    0xccf(%rip),%rdi
call   1150 <perror@plt>
jmp    1774 <transcode+0x504>
movsbl -0x1020(%rbp),%eax
cmp    $0xd,%eax
jne    1376 <transcode+0x106>
movsbl -0x101f(%rbp),%eax
cmp    $0xa,%eax
jne    1376 <transcode+0x106>
movsbl -0x101e(%rbp),%eax
cmp    $0x0,%eax
jne    1376 <transcode+0x106>
jmp    144d <transcode+0x1dd>
lea    -0x1020(%rbp),%rdi
lea    0xc88(%rip),%rsi
mov    $0xe,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    141d <transcode+0x1ad>
lea    -0x1020(%rbp),%rax
add    $0xe,%rax
mov    %rax,-0x1028(%rbp)
mov    -0x1028(%rbp),%rdi
lea    0xc63(%rip),%rsi
mov    $0xa,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     140e <transcode+0x19e>
mov    -0x1028(%rbp),%rdi
lea    0xc4c(%rip),%rsi
mov    $0x9,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     140e <transcode+0x19e>
mov    0x2be3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xc2e(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
jmp    1774 <transcode+0x504>
movl   $0x1,-0x1030(%rbp)
jmp    1306 <transcode+0x96>
lea    -0x1020(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10b0 <fputs@plt>
cmp    $0x0,%rax
jne    1448 <transcode+0x1d8>
lea    0xc0f(%rip),%rdi
call   1150 <perror@plt>
jmp    1774 <transcode+0x504>
jmp    1306 <transcode+0x96>
cmpl   $0x0,-0x1030(%rbp)
jne    147a <transcode+0x20a>
mov    0x2b77(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xbc2(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
jmp    1774 <transcode+0x504>
mov    -0x20(%rbp),%rsi
lea    0xbce(%rip),%rdi
call   10b0 <fputs@plt>
cmp    $0x0,%rax
jne    14a5 <transcode+0x235>
lea    0xbb2(%rip),%rdi
call   1150 <perror@plt>
jmp    1774 <transcode+0x504>
mov    -0x20(%rbp),%rdi
call   1110 <fflush@plt>
mov    -0x18(%rbp),%rdi
call   10f0 <ftell@plt>
mov    %rax,-0x1038(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x3,%edx
call   1070 <fread@plt>
mov    %eax,-0x103c(%rbp)
cmpl   $0x3,-0x103c(%rbp)
jne    1537 <transcode+0x2c7>
movsbl -0x1020(%rbp),%eax
cmp    $0x4f,%eax
jne    1537 <transcode+0x2c7>
movsbl -0x101f(%rbp),%eax
cmp    $0x67,%eax
jne    1537 <transcode+0x2c7>
movsbl -0x101e(%rbp),%eax
cmp    $0x67,%eax
jne    1537 <transcode+0x2c7>
mov    0x2ab6(%rip),%rax
mov    (%rax),%edi
lea    0xb4a(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
jmp    1774 <transcode+0x504>
mov    0x2a9a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xb63(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1100 <fileno@plt>
mov    %eax,-0x1040(%rbp)
mov    -0x20(%rbp),%rdi
call   1100 <fileno@plt>
mov    %eax,-0x1044(%rbp)
mov    $0x0,%al
call   1190 <fork@plt>
mov    %eax,-0x1048(%rbp)
cmpl   $0xffffffff,-0x1048(%rbp)
jne    159f <transcode+0x32f>
lea    0xb33(%rip),%rdi
call   1150 <perror@plt>
jmp    1774 <transcode+0x504>
cmpl   $0x0,-0x1048(%rbp)
jne    16d1 <transcode+0x461>
mov    -0x1040(%rbp),%edi
mov    0x2a0f(%rip),%rax
mov    (%rax),%esi
call   1090 <dup2@plt>
cmp    $0xffffffff,%eax
jne    15df <transcode+0x36f>
lea    0xafd(%rip),%rdi
call   1150 <perror@plt>
mov    $0x1,%edi
call   1060 <_exit@plt>
mov    -0x1040(%rbp),%edi
call   10c0 <close@plt>
mov    0x29d7(%rip),%rax
mov    (%rax),%edi
mov    -0x1038(%rbp),%rsi
mov    0x29cf(%rip),%rax
mov    (%rax),%edx
call   10a0 <lseek@plt>
cmp    $0xffffffff,%eax
jne    1627 <transcode+0x3b7>
lea    0xac1(%rip),%rdi
call   1150 <perror@plt>
mov    $0x1,%edi
call   1060 <_exit@plt>
mov    -0x1044(%rbp),%edi
mov    0x29bc(%rip),%rax
mov    (%rax),%esi
call   1090 <dup2@plt>
cmp    $0xffffffff,%eax
jne    165a <transcode+0x3ea>
lea    0xa9b(%rip),%rdi
call   1150 <perror@plt>
mov    $0x1,%edi
call   1060 <_exit@plt>
lea    0xa92(%rip),%rdi
call   1160 <unsetenv@plt>
lea    0xa91(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x1050(%rbp)
cmpq   $0x0,-0x1050(%rbp)
jne    1695 <transcode+0x425>
lea    0xa85(%rip),%rax
mov    %rax,-0x1050(%rbp)
mov    -0x1050(%rbp),%rcx
lea    0xa86(%rip),%rdi
lea    0xa84(%rip),%rsi
lea    0xa80(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1180 <execl@plt>
lea    0xa72(%rip),%rdi
call   1150 <perror@plt>
mov    $0x1,%edi
call   1060 <_exit@plt>
mov    -0x1048(%rbp),%edi
lea    -0x1054(%rbp),%rsi
xor    %edx,%edx
call   1130 <waitpid@plt>
mov    %eax,-0x1058(%rbp)
cmpl   $0xffffffff,-0x1058(%rbp)
jne    1709 <transcode+0x499>
lea    0xa3b(%rip),%rdi
call   1150 <perror@plt>
jmp    1774 <transcode+0x504>
mov    -0x1054(%rbp),%edi
call   1170 <WIFEXITED@plt>
cmp    $0x0,%eax
je     1732 <transcode+0x4c2>
mov    -0x1054(%rbp),%edi
call   1120 <WEXITSTATUS@plt>
cmp    $0x0,%rax
je     174e <transcode+0x4de>
mov    0x289f(%rip),%rax
mov    (%rax),%edi
lea    0xa00(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
jmp    1774 <transcode+0x504>
jmp    1753 <transcode+0x4e3>
mov    0x287e(%rip),%rax
mov    (%rax),%edi
lea    0x9f3(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
movl   $0x1,-0x102c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1788 <transcode+0x518>
mov    -0x18(%rbp),%rdi
call   1080 <fclose@plt>
cmpq   $0x0,-0x20(%rbp)
je     179c <transcode+0x52c>
mov    -0x20(%rbp),%rdi
call   1080 <fclose@plt>
cmpl   $0x0,-0x102c(%rbp)
jne    17b2 <transcode+0x542>
mov    -0x10(%rbp),%rdi
call   1040 <unlink@plt>
mov    -0x102c(%rbp),%eax
add    $0x1060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transcode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %rsi,%rbp
mov    %rdi,%r12
lea    0xd72(%rip),%rsi
call   1140 <fopen@plt>
test   %rax,%rax
mov    %rbp,0x8(%rsp)
je     14b5 <transcode+0x245>
mov    %rax,%rbx
lea    0xd58(%rip),%rsi
mov    %rbp,%rdi
call   1140 <fopen@plt>
test   %rax,%rax
je     14c1 <transcode+0x251>
mov    %rax,%r15
mov    $0x1,%bpl
lea    0x10(%rsp),%r14
lea    0xd3e(%rip),%r13
xchg   %ax,%ax
mov    %r14,%rdi
mov    $0x1000,%esi
mov    %rbx,%rdx
call   10d0 <fgets@plt>
test   %rax,%rax
je     14d5 <transcode+0x265>
cmpb   $0xd,0x10(%rsp)
jne    12fe <transcode+0x8e>
cmpb   $0xa,0x11(%rsp)
jne    12fe <transcode+0x8e>
cmpb   $0x0,0x12(%rsp)
je     1378 <transcode+0x108>
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0xe,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
je     1328 <transcode+0xb8>
mov    %r14,%rdi
mov    %r15,%rsi
call   10b0 <fputs@plt>
test   %rax,%rax
jne    12d0 <transcode+0x60>
jmp    14ac <transcode+0x23c>
lea    0x1e(%rsp),%rdi
lea    0xce7(%rip),%rsi
mov    $0xa,%edx
call   1050 <strncmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     12d0 <transcode+0x60>
lea    0x1e(%rsp),%rdi
lea    0xcd5(%rip),%rsi
mov    $0x9,%edx
call   1050 <strncmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     12d0 <transcode+0x60>
mov    0x2c6b(%rip),%rax
mov    (%rax),%edi
lea    0xcba(%rip),%rsi
jmp    1390 <transcode+0x120>
test   $0x1,%bpl
je     13a2 <transcode+0x132>
mov    0x2c53(%rip),%rax
mov    (%rax),%edi
lea    0xca2(%rip),%rsi
xor    %ebp,%ebp
mov    %r12,%rdx
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x1,%r14b
jmp    14e6 <transcode+0x276>
lea    0xcaa(%rip),%rdi
mov    %r15,%rsi
call   10b0 <fputs@plt>
test   %rax,%rax
je     14ac <transcode+0x23c>
mov    %r15,%rdi
call   1110 <fflush@plt>
mov    %rbx,%rdi
call   10f0 <ftell@plt>
mov    %rax,%r13
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    %rbx,%rcx
call   1070 <fread@plt>
mov    0x2bed(%rip),%r14
mov    (%r14),%edi
cmp    $0x3,%eax
jne    1420 <transcode+0x1b0>
cmpb   $0x4f,0x10(%rsp)
jne    1420 <transcode+0x1b0>
cmpb   $0x67,0x11(%rsp)
jne    1420 <transcode+0x1b0>
cmpb   $0x67,0x12(%rsp)
jne    1420 <transcode+0x1b0>
lea    0xc66(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x1,%r14b
jmp    14e6 <transcode+0x276>
lea    0xc8b(%rip),%rsi
xor    %ebp,%ebp
mov    %r12,%rdx
mov    0x8(%rsp),%rcx
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    %rbx,%rdi
call   1100 <fileno@plt>
mov    %eax,%r12d
mov    %r15,%rdi
call   1100 <fileno@plt>
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1190 <fork@plt>
cmp    $0xffffffff,%eax
je     1534 <transcode+0x2c4>
test   %eax,%eax
je     154e <transcode+0x2de>
mov    %rsp,%rsi
mov    %eax,%edi
xor    %edx,%edx
call   1130 <waitpid@plt>
cmp    $0xffffffff,%eax
je     1545 <transcode+0x2d5>
mov    (%rsp),%edi
call   1170 <WIFEXITED@plt>
test   %eax,%eax
je     1499 <transcode+0x229>
mov    (%rsp),%edi
call   1120 <WEXITSTATUS@plt>
test   %rax,%rax
je     1519 <transcode+0x2a9>
mov    (%r14),%edi
lea    0xc9f(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
jmp    14e1 <transcode+0x271>
lea    0xb9a(%rip),%rdi
jmp    14dc <transcode+0x26c>
mov    %r12,%rdi
call   1150 <perror@plt>
xor    %ebp,%ebp
jmp    14fb <transcode+0x28b>
mov    %rbp,%rdi
call   1150 <perror@plt>
mov    %rbx,%rdi
call   1080 <fclose@plt>
xor    %ebp,%ebp
jmp    14fb <transcode+0x28b>
lea    0xb2a(%rip),%rdi
call   1150 <perror@plt>
mov    $0x1,%r14b
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1080 <fclose@plt>
mov    %r15,%rdi
call   1080 <fclose@plt>
test   %r14b,%r14b
je     1505 <transcode+0x295>
mov    0x8(%rsp),%rdi
call   1040 <unlink@plt>
mov    %ebp,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r14),%edi
lea    0xc33(%rip),%rsi
xor    %r14d,%r14d
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x1,%ebp
jmp    14e6 <transcode+0x276>
lea    0xb8d(%rip),%rdi
call   1150 <perror@plt>
mov    $0x1,%r14b
jmp    14e6 <transcode+0x276>
lea    0xbee(%rip),%rdi
jmp    14dc <transcode+0x26c>
mov    0x2a73(%rip),%rbx
mov    (%rbx),%esi
mov    %r12d,%edi
call   1090 <dup2@plt>
cmp    $0xffffffff,%eax
jne    1570 <transcode+0x300>
lea    0xb62(%rip),%rdi
jmp    1603 <transcode+0x393>
mov    %r12d,%edi
call   10c0 <close@plt>
mov    (%rbx),%edi
mov    0x2a4f(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rsi
call   10a0 <lseek@plt>
cmp    $0xffffffff,%eax
jne    1599 <transcode+0x329>
lea    0xb42(%rip),%rdi
jmp    1603 <transcode+0x393>
mov    0x2a50(%rip),%rax
mov    (%rax),%esi
mov    0x4(%rsp),%edi
call   1090 <dup2@plt>
cmp    $0xffffffff,%eax
jne    15b9 <transcode+0x349>
lea    0xb2f(%rip),%rdi
jmp    1603 <transcode+0x393>
lea    0xb33(%rip),%rdi
call   1160 <unsetenv@plt>
lea    0xb32(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
lea    0xb38(%rip),%rcx
cmovne %rax,%rcx
lea    0xb43(%rip),%rdi
lea    0xb41(%rip),%rsi
lea    0xb3d(%rip),%rdx
xor    %r8d,%r8d
call   1180 <execl@plt>
lea    0xb31(%rip),%rdi
call   1150 <perror@plt>
mov    $0x1,%edi
call   1060 <_exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [6 x i8] c"fgets\00"
@.str.3 = [15 x i8] c"content-type: \00"
@.str.4 = [11 x i8] c"audio/mpeg\00"
@.str.5 = [10 x i8] c"audio/mp3\00"
@stderr = global i32 0
@.str.6 = [29 x i8] c"not transcoding %s, not MP3\0A\00"
@.str.7 = [6 x i8] c"fputs\00"
@.str.8 = [34 x i8] c"content-type: application/ogg\0D\0A\0D\0A\00"
@.str.9 = [61 x i8] c"File served as MP3, but looks like an OGG. Not transcoding.\0A\00"
@.str.10 = [22 x i8] c"Transcoding %s to %s\0A\00"
@.str.11 = [5 x i8] c"fork\00"
@STDIN_FILENO = global i32 0
@.str.12 = [12 x i8] c"dup2(stdin)\00"
@SEEK_SET = global i32 0
@.str.13 = [13 x i8] c"lseek(stdin)\00"
@STDOUT_FILENO = global i32 0
@.str.14 = [13 x i8] c"dup2(stdout)\00"
@.str.15 = [11 x i8] c"LD_PRELOAD\00"
@.str.16 = [21 x i8] c"YOUSICIAN_TRANSCODER\00"
@.str.17 = [22 x i8] c"sox -t mp3 - -t ogg -\00"
@.str.18 = [8 x i8] c"/bin/sh\00"
@.str.19 = [3 x i8] c"sh\00"
@.str.20 = [3 x i8] c"-c\00"
@.str.21 = [6 x i8] c"execl\00"
@.str.22 = [8 x i8] c"waitpid\00"
@.str.23 = [20 x i8] c"Transcoder failed!\0A\00"
@.str.24 = [13 x i8] c"Transcoded!\0A\00"
define i32 @transcode(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca [4096 x i8]
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32* null, i32** %5
store i32* null, i32** %6
store i32 0, i32* %9
store i32 0, i32* %10
%19 = load i8*, i8** %3
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %5
%21 = load i32*, i32** %5
%22 = icmp ne i32* %21, null
br i1 %22, label %26, label %23
23: ; preds = %2
%24 = load i8*, i8** %3
%25 = call i32 @perror(i8* %24)
br label %204
26: ; preds = %2
%27 = load i8*, i8** %4
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %6
%29 = load i32*, i32** %6
%30 = icmp ne i32* %29, null
br i1 %30, label %34, label %31
31: ; preds = %26
%32 = load i8*, i8** %4
%33 = call i32 @perror(i8* %32)
br label %204
34: ; preds = %26
br label %35
35: ; preds = %34, %77, %85
%36 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%37 = load i32*, i32** %5
%38 = call i8* @fgets(i8* %36, i32 4096, i32* %37)
store i8* %38, i8** %8
%39 = load i8*, i8** %8
%40 = icmp ne i8* %39, null
br i1 %40, label %43, label %41
41: ; preds = %35
%42 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %204
43: ; preds = %35
%44 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 13
br i1 %47, label %48, label %59
48: ; preds = %43
%49 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 1
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 10
br i1 %52, label %53, label %59
53: ; preds = %48
%54 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 2
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %53
br label %86
59: ; preds = %53, %48, %43
%60 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%61 = call i64 @strncmp(i8* %60, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 14)
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %78
63: ; preds = %59
%64 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%65 = getelementptr inbounds i8, i8* %64, i64 14
store i8* %65, i8** %8
%66 = load i8*, i8** %8
%67 = call i64 @strncmp(i8* %66, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 10)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %77
69: ; preds = %63
%70 = load i8*, i8** %8
%71 = call i64 @strncmp(i8* %70, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 9)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %77
73: ; preds = %69
%74 = load i32, i32* @stderr
%75 = load i8*, i8** %3
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* %75)
br label %204
77: ; preds = %69, %63
store i32 1, i32* %10
br label %35
78: ; preds = %59
%79 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%80 = load i32*, i32** %6
%81 = call i64 @fputs(i8* %79, i32* %80)
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %78
%84 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %204
85: ; preds = %78
br label %35
86: ; preds = %58
%87 = load i32, i32* %10
%88 = icmp ne i32 %87, 0
br i1 %88, label %93, label %89
89: ; preds = %86
%90 = load i32, i32* @stderr
%91 = load i8*, i8** %3
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* %91)
br label %204
93: ; preds = %86
%94 = load i32*, i32** %6
%95 = call i64 @fputs(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i32* %94)
%96 = icmp eq i64 %95, 0
br i1 %96, label %97, label %99
97: ; preds = %93
%98 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %204
99: ; preds = %93
%100 = load i32*, i32** %6
%101 = call i32 @fflush(i32* %100)
%102 = load i32*, i32** %5
%103 = call i64 @ftell(i32* %102)
store i64 %103, i64* %11
%104 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%105 = load i32*, i32** %5
%106 = call i32 @fread(i8* %104, i32 1, i32 3, i32* %105)
store i32 %106, i32* %12
%107 = load i32, i32* %12
%108 = icmp eq i32 %107, 3
br i1 %108, label %109, label %127
109: ; preds = %99
%110 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%111 = load i8, i8* %110
%112 = sext i8 %111 to i32
%113 = icmp eq i32 %112, 79
br i1 %113, label %114, label %127
114: ; preds = %109
%115 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 1
%116 = load i8, i8* %115
%117 = sext i8 %116 to i32
%118 = icmp eq i32 %117, 103
br i1 %118, label %119, label %127
119: ; preds = %114
%120 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 2
%121 = load i8, i8* %120
%122 = sext i8 %121 to i32
%123 = icmp eq i32 %122, 103
br i1 %123, label %124, label %127
124: ; preds = %119
%125 = load i32, i32* @stderr
%126 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.9, i64 0, i64 0))
br label %204
127: ; preds = %119, %114, %109, %99
%128 = load i32, i32* @stderr
%129 = load i8*, i8** %3
%130 = load i8*, i8** %4
%131 = call i32 (i32, i8*, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i8* %129, i8* %130)
%132 = load i32*, i32** %5
%133 = call i32 @fileno(i32* %132)
store i32 %133, i32* %13
%134 = load i32*, i32** %6
%135 = call i32 @fileno(i32* %134)
store i32 %135, i32* %14
%136 = call i32 (...) @fork()
store i32 %136, i32* %15
%137 = load i32, i32* %15
%138 = icmp eq i32 %137, -1
br i1 %138, label %139, label %141
139: ; preds = %127
%140 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
br label %204
141: ; preds = %127
%142 = load i32, i32* %15
%143 = icmp eq i32 %142, 0
br i1 %143, label %144, label %182
144: ; preds = %141
%145 = load i32, i32* %13
%146 = load i32, i32* @STDIN_FILENO
%147 = call i32 @dup2(i32 %145, i32 %146)
%148 = icmp eq i32 %147, -1
br i1 %148, label %149, label %152
149: ; preds = %144
%150 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
%151 = call i32 @_exit(i32 1)
unreachable
152: ; preds = %144
%153 = load i32, i32* %13
%154 = call i32 @close(i32 %153)
%155 = load i32, i32* @STDIN_FILENO
%156 = load i64, i64* %11
%157 = load i32, i32* @SEEK_SET
%158 = call i32 @lseek(i32 %155, i64 %156, i32 %157)
%159 = icmp eq i32 %158, -1
br i1 %159, label %160, label %163
160: ; preds = %152
%161 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0))
%162 = call i32 @_exit(i32 1)
unreachable
163: ; preds = %152
%164 = load i32, i32* %14
%165 = load i32, i32* @STDOUT_FILENO
%166 = call i32 @dup2(i32 %164, i32 %165)
%167 = icmp eq i32 %166, -1
br i1 %167, label %168, label %171
168: ; preds = %163
%169 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
%170 = call i32 @_exit(i32 1)
unreachable
171: ; preds = %163
%172 = call i32 @unsetenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0))
%173 = call i8* @getenv(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0))
store i8* %173, i8** %16
%174 = load i8*, i8** %16
%175 = icmp ne i8* %174, null
br i1 %175, label %177, label %176
176: ; preds = %171
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0), i8** %16
br label %177
177: ; preds = %176, %171
%178 = load i8*, i8** %16
%179 = call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0), i8* %178, i8* null)
%180 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i64 0, i64 0))
%181 = call i32 @_exit(i32 1)
unreachable
182: ; preds = %141
%183 = load i32, i32* %15
%184 = call i32 @waitpid(i32 %183, i32* %17, i32 0)
store i32 %184, i32* %18
%185 = load i32, i32* %18
%186 = icmp eq i32 %185, -1
br i1 %186, label %187, label %189
187: ; preds = %182
%188 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.22, i64 0, i64 0))
br label %204
189: ; preds = %182
%190 = load i32, i32* %17
%191 = call i32 @WIFEXITED(i32 %190)
%192 = icmp ne i32 %191, 0
br i1 %192, label %193, label %197
193: ; preds = %189
%194 = load i32, i32* %17
%195 = call i64 @WEXITSTATUS(i32 %194)
%196 = icmp ne i64 %195, 0
br i1 %196, label %197, label %200
197: ; preds = %193, %189
%198 = load i32, i32* @stderr
%199 = call i32 (i32, i8*, ...) @fprintf(i32 %198, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.23, i64 0, i64 0))
br label %204
200: ; preds = %193
br label %201
201: ; preds = %200
%202 = load i32, i32* @stderr
%203 = call i32 (i32, i8*, ...) @fprintf(i32 %202, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.24, i64 0, i64 0))
store i32 1, i32* %9
br label %204
204: ; preds = %201, %197, %187, %139, %124, %97, %89, %83, %73, %41, %31, %23
%205 = load i32*, i32** %5
%206 = icmp ne i32* %205, null
br i1 %206, label %207, label %210
207: ; preds = %204
%208 = load i32*, i32** %5
%209 = call i32 @fclose(i32* %208)
br label %210
210: ; preds = %207, %204
%211 = load i32*, i32** %6
%212 = icmp ne i32* %211, null
br i1 %212, label %213, label %216
213: ; preds = %210
%214 = load i32*, i32** %6
%215 = call i32 @fclose(i32* %214)
br label %216
216: ; preds = %213, %210
%217 = load i32, i32* %9
%218 = icmp ne i32 %217, 0
br i1 %218, label %222, label %219
219: ; preds = %216
%220 = load i8*, i8** %4
%221 = call i32 @unlink(i8* %220)
br label %222
222: ; preds = %219, %216
%223 = load i32, i32* %9
ret i32 %223
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [6 x i8] c"fgets\00"
@.str.3 = [15 x i8] c"content-type: \00"
@.str.4 = [11 x i8] c"audio/mpeg\00"
@.str.5 = [10 x i8] c"audio/mp3\00"
@stderr = global i32 0
@.str.6 = [29 x i8] c"not transcoding %s, not MP3\0A\00"
@.str.7 = [6 x i8] c"fputs\00"
@.str.8 = [34 x i8] c"content-type: application/ogg\0D\0A\0D\0A\00"
@.str.9 = [61 x i8] c"File served as MP3, but looks like an OGG. Not transcoding.\0A\00"
@.str.10 = [22 x i8] c"Transcoding %s to %s\0A\00"
@.str.11 = [5 x i8] c"fork\00"
@STDIN_FILENO = global i32 0
@.str.12 = [12 x i8] c"dup2(stdin)\00"
@SEEK_SET = global i32 0
@.str.13 = [13 x i8] c"lseek(stdin)\00"
@STDOUT_FILENO = global i32 0
@.str.14 = [13 x i8] c"dup2(stdout)\00"
@.str.15 = [11 x i8] c"LD_PRELOAD\00"
@.str.16 = [21 x i8] c"YOUSICIAN_TRANSCODER\00"
@.str.17 = [22 x i8] c"sox -t mp3 - -t ogg -\00"
@.str.18 = [8 x i8] c"/bin/sh\00"
@.str.19 = [3 x i8] c"sh\00"
@.str.20 = [3 x i8] c"-c\00"
@.str.21 = [6 x i8] c"execl\00"
@.str.22 = [8 x i8] c"waitpid\00"
@.str.23 = [20 x i8] c"Transcoder failed!\0A\00"
@.str.24 = [13 x i8] c"Transcoded!\0A\00"
define i32 @transcode(i8* %0, i8* %1) {
%3 = alloca [4096 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @perror(i8* %0)
br label %144
10: ; preds = %2
%11 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 1
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 2
%16 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 14
br label %47
17: ; preds = %10
%18 = tail call i32 @perror(i8* %1)
%19 = call i32 @fclose(i32* %6)
br label %144
20: ; preds = %47, %49
%21 = call i8* @fgets(i8* %5, i32 4096, i32* %6)
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %139
25: ; preds = %20
%26 = load i8, i8* %5
%27 = icmp eq i8 %26, 13
%28 = load i8, i8* %14
%29 = icmp eq i8 %28, 10
%30 = select i1 %27, i1 %29, i1 false
%31 = load i8, i8* %15
%32 = icmp eq i8 %31, 0
%33 = select i1 %30, i1 %32, i1 false
br i1 %33, label %54, label %34
34: ; preds = %25
%35 = call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 14)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %49
37: ; preds = %34
%38 = call i64 @strncmp(i8* %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 10)
%39 = icmp eq i64 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = call i64 @strncmp(i8* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 9)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %40, %37
br label %47
44: ; preds = %40
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* %0)
br label %139
47: ; preds = %43, %13
%48 = phi i1 [ true, %13 ], [ false, %43 ]
br label %20
49: ; preds = %34
%50 = call i64 @fputs(i8* %5, i32* %11)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %20
52: ; preds = %49
%53 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %139
54: ; preds = %25
br i1 %48, label %55, label %58
55: ; preds = %54
%56 = load i32, i32* @stderr
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* %0)
br label %139
58: ; preds = %54
%59 = call i64 @fputs(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i32* %11)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %139
63: ; preds = %58
%64 = call i32 @fflush(i32* %11)
%65 = call i64 @ftell(i32* %6)
%66 = call i32 @fread(i8* %5, i32 1, i32 3, i32* %6)
%67 = icmp eq i32 %66, 3
%68 = load i8, i8* %5
%69 = icmp eq i8 %68, 79
%70 = select i1 %67, i1 %69, i1 false
%71 = load i8, i8* %14
%72 = icmp eq i8 %71, 103
%73 = select i1 %70, i1 %72, i1 false
%74 = load i8, i8* %15
%75 = icmp eq i8 %74, 103
%76 = select i1 %73, i1 %75, i1 false
%77 = load i32, i32* @stderr
br i1 %76, label %78, label %80
78: ; preds = %63
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.9, i64 0, i64 0))
br label %139
80: ; preds = %63
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i8* %0, i8* %1)
%82 = call i32 @fileno(i32* %6)
%83 = call i32 @fileno(i32* %11)
%84 = call i32 (...) @fork()
switch i32 %84, label %118 [
i32 -1, label %85
i32 0, label %87
]
85: ; preds = %80
%86 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
br label %139
87: ; preds = %80
%88 = load i32, i32* @STDIN_FILENO
%89 = call i32 @dup2(i32 %82, i32 %88)
%90 = icmp eq i32 %89, -1
br i1 %90, label %91, label %94
91: ; preds = %87
%92 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
%93 = call i32 @_exit(i32 1)
unreachable
94: ; preds = %87
%95 = call i32 @close(i32 %82)
%96 = load i32, i32* @STDIN_FILENO
%97 = load i32, i32* @SEEK_SET
%98 = call i32 @lseek(i32 %96, i64 %65, i32 %97)
%99 = icmp eq i32 %98, -1
br i1 %99, label %100, label %103
100: ; preds = %94
%101 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0))
%102 = call i32 @_exit(i32 1)
unreachable
103: ; preds = %94
%104 = load i32, i32* @STDOUT_FILENO
%105 = call i32 @dup2(i32 %83, i32 %104)
%106 = icmp eq i32 %105, -1
br i1 %106, label %107, label %110
107: ; preds = %103
%108 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
%109 = call i32 @_exit(i32 1)
unreachable
110: ; preds = %103
%111 = call i32 @unsetenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0))
%112 = call i8* @getenv(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0))
%113 = icmp eq i8* %112, null
%114 = select i1 %113, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0), i8* %112
%115 = call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0), i8* %114, i8* null)
%116 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i64 0, i64 0))
%117 = call i32 @_exit(i32 1)
unreachable
118: ; preds = %80
%119 = bitcast i32* %4 to i8*
%120 = call i32 @waitpid(i32 %84, i32* %4, i32 0)
%121 = icmp eq i32 %120, -1
br i1 %121, label %122, label %124
122: ; preds = %118
%123 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.22, i64 0, i64 0))
br label %135
124: ; preds = %118
%125 = load i32, i32* %4
%126 = call i32 @WIFEXITED(i32 %125)
%127 = icmp eq i32 %126, 0
br i1 %127, label %132, label %128
128: ; preds = %124
%129 = load i32, i32* %4
%130 = call i64 @WEXITSTATUS(i32 %129)
%131 = icmp eq i64 %130, 0
br i1 %131, label %136, label %132
132: ; preds = %128, %124
%133 = load i32, i32* @stderr
%134 = call i32 (i32, i8*, ...) @fprintf(i32 %133, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.23, i64 0, i64 0))
br label %135
135: ; preds = %122, %132
br label %139
136: ; preds = %128
%137 = load i32, i32* @stderr
%138 = call i32 (i32, i8*, ...) @fprintf(i32 %137, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.24, i64 0, i64 0))
br label %139
139: ; preds = %135, %136, %85, %78, %61, %55, %52, %44, %23
%140 = phi i32 [ 1, %136 ], [ 0, %85 ], [ 0, %78 ], [ 0, %61 ], [ 0, %55 ], [ 0, %52 ], [ 0, %44 ], [ 0, %23 ], [ 0, %135 ]
%141 = phi i1 [ false, %136 ], [ true, %85 ], [ true, %78 ], [ true, %61 ], [ true, %55 ], [ true, %52 ], [ true, %44 ], [ true, %23 ], [ true, %135 ]
%142 = call i32 @fclose(i32* %6)
%143 = call i32 @fclose(i32* %11)
br i1 %141, label %144, label %147
144: ; preds = %17, %139, %8
%145 = phi i32 [ 0, %8 ], [ %140, %139 ], [ 0, %17 ]
%146 = call i32 @unlink(i8* %1)
br label %147
147: ; preds = %139, %144
%148 = phi i32 [ %145, %144 ], [ %140, %139 ]
ret i32 %148
}