#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 */
struct dirent {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int strlen(char *);
char *strrchr(char *, char);
int /*<<< orphan*/ system(char *);
int extract_variants(char *config[]) {
  DIR *dir;
  struct dirent *ent;
  char *subit;
  char *subit2;
  char *filename;
  FILE *logp;
  FILE *filelistfp;
  char description[100];
  char sample[50];
  char read1[1000];
  char read2[1000];
  char current_command[1000];
  char dir_trunk[1000];
  char filestring[50000];
  char current_directory[1000];
  char rmdup_job_file[1000];
  char snplist_job_file[1000];
  char sys_command[1000];
  char run_dir[1000];
  int i;
  i = 0;
  printf("within snplist_generation\n");
  sprintf(current_directory, "%s", config[2]);
  printf("Current directory is \t%s\n", current_directory);
  sprintf(sys_command, "mkdir %s/VCF_files", current_directory);
  system(sys_command);
  sprintf(sys_command, "mkdir %s/VCF_files/logs", current_directory);
  system(sys_command);
  filelistfp = fopen(config[1], "r");
  if (filelistfp == NULL) {
    printf("The filelist could not be opened.  Exiting \n");
    return 2;
  }
  while (fgets(filestring, 50000, filelistfp) != NULL) {
    filestring[strlen(filestring) - 1] = '\0';
    filename = strrchr(filestring, '/');
    if (filename == NULL) {
      filename = filestring;
    } else {
      filename++;
    }
    printf("filename is %s\n", filename);
    sprintf(snplist_job_file, "%s/VCF_files/logs/extractJob%d.job", config[2],
            i);
    logp = fopen(snplist_job_file, "w");
    if (logp == NULL) {
      printf("could not open log file for writing\n");
    } else {
      printf("hey we wrote a log file\n");
      fprintf(logp, "#!/bin/bash\n");
      fprintf(logp, "#BSUB -J extractJob%d\n", i);
      fprintf(logp, "#BSUB -o %s/VCF_files/logs/extractJob%d.out\n", config[2],
              i);
      fprintf(logp, "#BSUB -e %s/VCF_files/logs/extractJob%d.err\n", config[2],
              i);
      fprintf(logp, "#BSUB -W 5:00\n");
      fprintf(logp, "#BSUB -n 1\n");
      fprintf(logp, "#BSUB -q small\n");
      fprintf(logp, "#BSUB -u dvanbooven\n");
      fprintf(logp, "#BSUB -g /ex_var1\n\n");
      fprintf(logp,
              "/smoke/dvanbooven/extraction/extract_variants %s/snplist.txt %s "
              "%s/VCF_files/%s\n\n",
              config[2], filestring, config[2], filename);
    }
    fclose(logp);
    sprintf(sys_command, "bsub < %s/VCF_files/logs/extractJob%d.job\n",
            config[2], i);
    system(sys_command);
    sleep(1);
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<extract_variants>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe7c0,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0xe7b4(%rbp)
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xd7f0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0xd7f0(%rbp),%rsi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xe3c0(%rbp),%rdi
lea    -0xd7f0(%rbp),%rdx
lea    0xe2a(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0xe3c0(%rbp),%rdi
call   1050 <system@plt>
lea    -0xe3c0(%rbp),%rdi
lea    -0xd7f0(%rbp),%rdx
lea    0xe15(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0xe3c0(%rbp),%rdi
call   1050 <system@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe0b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1286 <extract_variants+0xe6>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    14c5 <extract_variants+0x325>
jmp    128b <extract_variants+0xeb>
lea    -0xd400(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    $0xc350,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     14be <extract_variants+0x31e>
lea    -0xd400(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0xd400(%rbp,%rax,1)
lea    -0xd400(%rbp),%rdi
mov    $0x2f,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    12f3 <extract_variants+0x153>
lea    -0xd400(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    12ff <extract_variants+0x15f>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xdfd0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0xe7b4(%rbp),%ecx
lea    0xd75(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0xdfd0(%rbp),%rdi
lea    0xd83(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1369 <extract_variants+0x1c9>
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1468 <extract_variants+0x2c8>
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%rdi
lea    0xd83(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x40(%rbp),%rdi
mov    -0xe7b4(%rbp),%edx
lea    0xd78(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0xe7b4(%rbp),%ecx
lea    0xd6f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0xe7b4(%rbp),%ecx
lea    0xd7c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xd97(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xd8e(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xd8c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xd8f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    -0xd400(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r8
mov    -0x38(%rbp),%r9
lea    0xd76(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0xe3c0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0xe7b4(%rbp),%ecx
lea    0xd9c(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0xe3c0(%rbp),%rdi
call   1050 <system@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    -0xe7b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe7b4(%rbp)
jmp    128b <extract_variants+0xeb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe7c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_variants>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xcf38,%rsp
mov    %rdi,%r14
lea    0xfe0(%rip),%rdi
call   1040 <puts@plt>
mov    0x10(%r14),%rsi
lea    0x7f0(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xdf5(%rip),%rdi
xor    %r12d,%r12d
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xdfb(%rip),%rsi
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   10d0 <sprintf@plt>
mov    %r15,%rdi
call   1070 <system@plt>
lea    0xded(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   10d0 <sprintf@plt>
mov    %r15,%rdi
call   1070 <system@plt>
mov    0x8(%r14),%rdi
lea    0xde5(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1485 <extract_variants+0x2b5>
mov    %rax,%rbx
lea    0xbe0(%rsp),%r15
mov    %r15,%rdi
mov    $0xc350,%esi
mov    %rax,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     1497 <extract_variants+0x2c7>
xor    %r13d,%r13d
mov    %rbx,0x8(%rsp)
jmp    1400 <extract_variants+0x230>
nop
lea    0xf3e(%rip),%rdi
call   1040 <puts@plt>
mov    $0xc,%esi
mov    $0x1,%edx
lea    0xdbf(%rip),%rdi
mov    %r12,%rcx
call   10e0 <fwrite@plt>
mov    %r12,%rdi
lea    0xdba(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    0x10(%r14),%rdx
mov    %r12,%rdi
lea    0xdb9(%rip),%rsi
mov    %r13d,%ecx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    0x10(%r14),%rdx
mov    %r12,%rdi
lea    0xdce(%rip),%rsi
mov    %r13d,%ecx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0xe,%esi
mov    $0x1,%edx
lea    0xde0(%rip),%rdi
mov    %r12,%rcx
call   10e0 <fwrite@plt>
mov    $0xb,%esi
mov    $0x1,%edx
lea    0xdd6(%rip),%rdi
mov    %r12,%rcx
call   10e0 <fwrite@plt>
mov    $0xf,%esi
mov    $0x1,%edx
lea    0xdc9(%rip),%rdi
mov    %r12,%rcx
call   10e0 <fwrite@plt>
mov    $0x14,%esi
mov    $0x1,%edx
lea    0xdc0(%rip),%rdi
mov    %r12,%rcx
call   10e0 <fwrite@plt>
mov    $0x13,%esi
mov    $0x1,%edx
lea    0xdbc(%rip),%rdi
mov    %r12,%rcx
call   10e0 <fwrite@plt>
mov    0x10(%r14),%rdx
mov    %r12,%rdi
lea    0xdba(%rip),%rsi
mov    %r15,%rcx
mov    %rdx,%r8
mov    %rbp,%r9
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    0x8(%rsp),%rbx
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    0x10(%r14),%rdx
xor    %r12d,%r12d
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
lea    0xdd9(%rip),%rsi
mov    %r13d,%ecx
xor    %eax,%eax
call   10d0 <sprintf@plt>
mov    %rbp,%rdi
call   1070 <system@plt>
mov    $0x1,%edi
call   10f0 <sleep@plt>
add    $0x1,%r13d
mov    %r15,%rdi
mov    $0xc350,%esi
mov    %rbx,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     1497 <extract_variants+0x2c7>
mov    %r15,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r15,1)
mov    %r15,%rdi
mov    $0x2f,%esi
call   1090 <strrchr@plt>
lea    0x1(%rax),%rbp
test   %rax,%rax
cmove  %r15,%rbp
lea    0xc18(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%r14),%rdx
lea    0x400(%rsp),%rbx
mov    %rbx,%rdi
lea    0xc08(%rip),%rsi
mov    %r13d,%ecx
xor    %eax,%eax
call   10d0 <sprintf@plt>
mov    %rbx,%rdi
lea    0xc17(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    12a0 <extract_variants+0xd0>
lea    0xd82(%rip),%rdi
call   1040 <puts@plt>
jmp    13a4 <extract_variants+0x1d4>
lea    0xd95(%rip),%rdi
call   1040 <puts@plt>
mov    $0x2,%r12d
mov    %r12d,%eax
add    $0xcf38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i32 }
@.str = [27 x i8] c"within snplist_generation\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [26 x i8] c"Current directory is \09%s\0A\00"
@.str.3 = [19 x i8] c"mkdir %s/VCF_files\00"
@.str.4 = [24 x i8] c"mkdir %s/VCF_files/logs\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [45 x i8] c"The filelist could not be opened. Exiting \0A\00"
@.str.7 = [16 x i8] c"filename is %s\0A\00"
@.str.8 = [35 x i8] c"%s/VCF_files/logs/extractJob%d.job\00"
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [37 x i8] c"could not open log file for writing\0A\00"
@.str.11 = [25 x i8] c"hey we wrote a log file\0A\00"
@.str.12 = [13 x i8] c"#!/bin/bash\0A\00"
@.str.13 = [23 x i8] c"#BSUB -J extractJob%d\0A\00"
@.str.14 = [45 x i8] c"#BSUB -o %s/VCF_files/logs/extractJob%d.out\0A\00"
@.str.15 = [45 x i8] c"#BSUB -e %s/VCF_files/logs/extractJob%d.err\0A\00"
@.str.16 = [15 x i8] c"#BSUB -W 5:00\0A\00"
@.str.17 = [12 x i8] c"#BSUB -n 1\0A\00"
@.str.18 = [16 x i8] c"#BSUB -q small\0A\00"
@.str.19 = [21 x i8] c"#BSUB -u dvanbooven\0A\00"
@.str.20 = [20 x i8] c"#BSUB -g /ex_var1\0A\0A\00"
@.str.21 = [82 x i8] c"/smoke/dvanbooven/extraction/extract_variants %s/snplist.txt %s %s/VCF_files/%s\0A\0A\00"
@.str.22 = [43 x i8] c"bsub < %s/VCF_files/logs/extractJob%d.job\0A\00"
define i32 @extract_variants(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32*
%5 = alloca %struct.dirent*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca [100 x i8]
%12 = alloca [50 x i8]
%13 = alloca [1000 x i8]
%14 = alloca [1000 x i8]
%15 = alloca [1000 x i8]
%16 = alloca [1000 x i8]
%17 = alloca [50000 x i8]
%18 = alloca [1000 x i8]
%19 = alloca [1000 x i8]
%20 = alloca [1000 x i8]
%21 = alloca [1000 x i8]
%22 = alloca [1000 x i8]
%23 = alloca i32
store i8** %0, i8*** %3
store i32 0, i32* %23
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 0
%26 = load i8**, i8*** %3
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [1000 x i8], [1000 x i8]* %21, i64 0, i64 0
%33 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 0
%34 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %33)
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %21, i64 0, i64 0
%36 = call i32 @system(i8* %35)
%37 = getelementptr inbounds [1000 x i8], [1000 x i8]* %21, i64 0, i64 0
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 0
%39 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %37, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %38)
%40 = getelementptr inbounds [1000 x i8], [1000 x i8]* %21, i64 0, i64 0
%41 = call i32 @system(i8* %40)
%42 = load i8**, i8*** %3
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = call i32* @fopen(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %45, i32** %10
%46 = load i32*, i32** %10
%47 = icmp eq i32* %46, null
br i1 %47, label %48, label %50
48: ; preds = %1
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0))
store i32 2, i32* %2
br label %140
50: ; preds = %1
br label %51
51: ; preds = %125, %50
%52 = getelementptr inbounds [50000 x i8], [50000 x i8]* %17, i64 0, i64 0
%53 = load i32*, i32** %10
%54 = call i32* @fgets(i8* %52, i32 50000, i32* %53)
%55 = icmp ne i32* %54, null
br i1 %55, label %56, label %139
56: ; preds = %51
%57 = getelementptr inbounds [50000 x i8], [50000 x i8]* %17, i64 0, i64 0
%58 = call i32 @strlen(i8* %57)
%59 = sub nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [50000 x i8], [50000 x i8]* %17, i64 0, i64 %60
store i8 0, i8* %61
%62 = getelementptr inbounds [50000 x i8], [50000 x i8]* %17, i64 0, i64 0
%63 = call i8* @strrchr(i8* %62, i8 signext 47)
store i8* %63, i8** %8
%64 = load i8*, i8** %8
%65 = icmp eq i8* %64, null
br i1 %65, label %66, label %68
66: ; preds = %56
%67 = getelementptr inbounds [50000 x i8], [50000 x i8]* %17, i64 0, i64 0
store i8* %67, i8** %8
br label %71
68: ; preds = %56
%69 = load i8*, i8** %8
%70 = getelementptr inbounds i8, i8* %69, i32 1
store i8* %70, i8** %8
br label %71
71: ; preds = %68, %66
%72 = load i8*, i8** %8
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %72)
%74 = getelementptr inbounds [1000 x i8], [1000 x i8]* %20, i64 0, i64 0
%75 = load i8**, i8*** %3
%76 = getelementptr inbounds i8*, i8** %75, i64 2
%77 = load i8*, i8** %76
%78 = load i32, i32* %23
%79 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %74, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i8* %77, i32 %78)
%80 = getelementptr inbounds [1000 x i8], [1000 x i8]* %20, i64 0, i64 0
%81 = call i32* @fopen(i8* %80, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %81, i32** %9
%82 = load i32*, i32** %9
%83 = icmp eq i32* %82, null
br i1 %83, label %84, label %86
84: ; preds = %71
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0))
br label %125
86: ; preds = %71
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0))
%88 = load i32*, i32** %9
%89 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
%90 = load i32*, i32** %9
%91 = load i32, i32* %23
%92 = call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i32 %91)
%93 = load i32*, i32** %9
%94 = load i8**, i8*** %3
%95 = getelementptr inbounds i8*, i8** %94, i64 2
%96 = load i8*, i8** %95
%97 = load i32, i32* %23
%98 = call i32 (i32*, i8*, ...) @fprintf(i32* %93, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.14, i64 0, i64 0), i8* %96, i32 %97)
%99 = load i32*, i32** %9
%100 = load i8**, i8*** %3
%101 = getelementptr inbounds i8*, i8** %100, i64 2
%102 = load i8*, i8** %101
%103 = load i32, i32* %23
%104 = call i32 (i32*, i8*, ...) @fprintf(i32* %99, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.15, i64 0, i64 0), i8* %102, i32 %103)
%105 = load i32*, i32** %9
%106 = call i32 (i32*, i8*, ...) @fprintf(i32* %105, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.16, i64 0, i64 0))
%107 = load i32*, i32** %9
%108 = call i32 (i32*, i8*, ...) @fprintf(i32* %107, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0))
%109 = load i32*, i32** %9
%110 = call i32 (i32*, i8*, ...) @fprintf(i32* %109, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.18, i64 0, i64 0))
%111 = load i32*, i32** %9
%112 = call i32 (i32*, i8*, ...) @fprintf(i32* %111, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.19, i64 0, i64 0))
%113 = load i32*, i32** %9
%114 = call i32 (i32*, i8*, ...) @fprintf(i32* %113, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.20, i64 0, i64 0))
%115 = load i32*, i32** %9
%116 = load i8**, i8*** %3
%117 = getelementptr inbounds i8*, i8** %116, i64 2
%118 = load i8*, i8** %117
%119 = getelementptr inbounds [50000 x i8], [50000 x i8]* %17, i64 0, i64 0
%120 = load i8**, i8*** %3
%121 = getelementptr inbounds i8*, i8** %120, i64 2
%122 = load i8*, i8** %121
%123 = load i8*, i8** %8
%124 = call i32 (i32*, i8*, ...) @fprintf(i32* %115, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.21, i64 0, i64 0), i8* %118, i8* %119, i8* %122, i8* %123)
br label %125
125: ; preds = %86, %84
%126 = load i32*, i32** %9
%127 = call i32 @fclose(i32* %126)
%128 = getelementptr inbounds [1000 x i8], [1000 x i8]* %21, i64 0, i64 0
%129 = load i8**, i8*** %3
%130 = getelementptr inbounds i8*, i8** %129, i64 2
%131 = load i8*, i8** %130
%132 = load i32, i32* %23
%133 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %128, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.22, i64 0, i64 0), i8* %131, i32 %132)
%134 = getelementptr inbounds [1000 x i8], [1000 x i8]* %21, i64 0, i64 0
%135 = call i32 @system(i8* %134)
%136 = call i32 @sleep(i32 1)
%137 = load i32, i32* %23
%138 = add nsw i32 %137, 1
store i32 %138, i32* %23
br label %51
139: ; preds = %51
store i32 0, i32* %2
br label %140
140: ; preds = %139, %48
%141 = load i32, i32* %2
ret i32 %141
}

LLVM IR (-O2):
%struct.dirent = type { i32 }
@.str.2 = [26 x i8] c"Current directory is \09%s\0A\00"
@.str.3 = [19 x i8] c"mkdir %s/VCF_files\00"
@.str.4 = [24 x i8] c"mkdir %s/VCF_files/logs\00"
@.str.5 = [2 x i8] c"r\00"
@.str.7 = [16 x i8] c"filename is %s\0A\00"
@.str.8 = [35 x i8] c"%s/VCF_files/logs/extractJob%d.job\00"
@.str.9 = [2 x i8] c"w\00"
@.str.12 = [13 x i8] c"#!/bin/bash\0A\00"
@.str.13 = [23 x i8] c"#BSUB -J extractJob%d\0A\00"
@.str.14 = [45 x i8] c"#BSUB -o %s/VCF_files/logs/extractJob%d.out\0A\00"
@.str.15 = [45 x i8] c"#BSUB -e %s/VCF_files/logs/extractJob%d.err\0A\00"
@.str.16 = [15 x i8] c"#BSUB -W 5:00\0A\00"
@.str.17 = [12 x i8] c"#BSUB -n 1\0A\00"
@.str.18 = [16 x i8] c"#BSUB -q small\0A\00"
@.str.19 = [21 x i8] c"#BSUB -u dvanbooven\0A\00"
@.str.20 = [20 x i8] c"#BSUB -g /ex_var1\0A\0A\00"
@.str.21 = [82 x i8] c"/smoke/dvanbooven/extraction/extract_variants %s/snplist.txt %s %s/VCF_files/%s\0A\0A\00"
@.str.22 = [43 x i8] c"bsub < %s/VCF_files/logs/extractJob%d.job\0A\00"
@str = [26 x i8] c"within snplist_generation\00"
@str.23 = [24 x i8] c"hey we wrote a log file\00"
@str.24 = [36 x i8] c"could not open log file for writing\00"
@str.25 = [44 x i8] c"The filelist could not be opened. Exiting \00"
define i32 @extract_variants(i8** nocapture %0) {
%2 = alloca [50000 x i8]
%3 = alloca [1000 x i8]
%4 = alloca [1000 x i8]
%5 = alloca [1000 x i8]
%6 = getelementptr inbounds [50000 x i8], [50000 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%11 = getelementptr inbounds i8*, i8** %0, i64 2
%12 = load i8*, i8** %11
%13 = call i8* @strcpy(i8* %7, i8* dereferenceable(1) %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%15 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%16 = call i32 @system(i8* %9)
%17 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%18 = call i32 @system(i8* %9)
%19 = getelementptr inbounds i8*, i8** %0, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %26, label %23
23: ; preds = %1
%24 = call i32* @fgets(i8* %6, i32 50000, i32* %21)
%25 = icmp eq i32* %24, null
br i1 %25, label %69, label %28
26: ; preds = %1
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.25, i64 0, i64 0))
br label %69
28: ; preds = %23, %60
%29 = phi i32 [ %66, %60 ], [ 0, %23 ]
%30 = call i32 @strlen(i8* %6)
%31 = add nsw i32 %30, -1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [50000 x i8], [50000 x i8]* %2, i64 0, i64 %32
store i8 0, i8* %33
%34 = call i8* @strrchr(i8* %6, i8 signext 47)
%35 = icmp eq i8* %34, null
%36 = getelementptr inbounds i8, i8* %34, i64 1
%37 = select i1 %35, i8* %6, i8* %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %37)
%39 = load i8*, i8** %11
%40 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i8* %39, i32 %29)
%41 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %45
43: ; preds = %28
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.24, i64 0, i64 0))
br label %60
45: ; preds = %28
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.23, i64 0, i64 0))
%47 = call i64 @fwrite(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), i64 12, i64 1, i32* %41)
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i32 %29)
%49 = load i8*, i8** %11
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.14, i64 0, i64 0), i8* %49, i32 %29)
%51 = load i8*, i8** %11
%52 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.15, i64 0, i64 0), i8* %51, i32 %29)
%53 = call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.16, i64 0, i64 0), i64 14, i64 1, i32* %41)
%54 = call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0), i64 11, i64 1, i32* %41)
%55 = call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.18, i64 0, i64 0), i64 15, i64 1, i32* %41)
%56 = call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.19, i64 0, i64 0), i64 20, i64 1, i32* %41)
%57 = call i64 @fwrite(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.20, i64 0, i64 0), i64 19, i64 1, i32* %41)
%58 = load i8*, i8** %11
%59 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.21, i64 0, i64 0), i8* %58, i8* %6, i8* %58, i8* %37)
br label %60
60: ; preds = %45, %43
%61 = call i32 @fclose(i32* %41)
%62 = load i8*, i8** %11
%63 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.22, i64 0, i64 0), i8* %62, i32 %29)
%64 = call i32 @system(i8* %9)
%65 = call i32 @sleep(i32 1)
%66 = add nuw nsw i32 %29, 1
%67 = call i32* @fgets(i8* %6, i32 50000, i32* %21)
%68 = icmp eq i32* %67, null
br i1 %68, label %69, label %28
69: ; preds = %60, %23, %26
%70 = phi i32 [ 2, %26 ], [ 0, %23 ], [ 0, %60 ]
ret i32 %70
}