#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 stat {
  int st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int aleatW(int);
int atoi(char *);
int errno;
int /*<<< orphan*/ exit(int);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fprintf(int /*<<< orphan*/, char *, ...);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
main(int argc, char **argv) {
  int n, m, J, t;
  struct stat sdata;
  FILE *ifile, *ofile;
  unsigned char *buff;
  if (argc < 5) {
    fprintf(
        stderr,
        "\nUsage: %s <intsfile> <length> <number> <intervals file>\n\n"
        "  randomly extracts <number> intervals of length <length> from "
        "<intsfile>.\n"
        "  The output file, <intervals file> has a first line of the form:\n"
        "    # number=<number> length=<length> file=<intsfile>\n"
        "  and then <number> lines of the form <from>,<to>.\n\n",
        argv[0]);
    exit(1);
  }
  if (stat(argv[1], &sdata) != 0) {
    fprintf(stderr, "Error: cannot stat file %s\n", argv[1]);
    fprintf(stderr, " errno = %i\n", errno);
    exit(1);
  }
  n = sdata.st_size / sizeof(unsigned int);
  fprintf(stderr, "\n max value to be generated is %i\n", n);
  m = atoi(argv[2]);
  if ((m <= 0) || (m > n)) {
    fprintf(stderr,
            "Error: length must be >= 1 and <= file length"
            " (%i)\n",
            n);
    exit(1);
  }
  J = atoi(argv[3]);
  if (J < 1) {
    fprintf(stderr, "Error: number of intervals must be >= 1\n");
    exit(1);
  }
  ifile = fopen(argv[1], "r");
  if (ifile == NULL) {
    fprintf(stderr, "Error: cannot open file %s for reading\n", argv[1]);
    fprintf(stderr, " errno = %i\n", errno);
    exit(1);
  }
  buff = (unsigned char *)malloc(n);
  if (buff == NULL) {
    fprintf(stderr, "Error: cannot allocate %i bytes\n", n);
    fprintf(stderr, " errno = %i\n", errno);
    exit(1);
  }
  if (fread(buff, n, 1, ifile) != 1) {
    fprintf(stderr, "Error: cannot read file %s\n", argv[1]);
    fprintf(stderr, " errno = %i\n", errno);
    exit(1);
  }
  fclose(ifile);
  ofile = fopen(argv[4], "w");
  if (ofile == NULL) {
    fprintf(stderr, "Error: cannot open file %s for writing\n", argv[4]);
    fprintf(stderr, " errno = %i\n", errno);
    exit(1);
  }
  if (fprintf(ofile, "# number=%lu numwords=%i file=%s\n", J, m, argv[1]) <=
      0) {
    fprintf(stderr, "Error: cannot write file %s\n", argv[4]);
    fprintf(stderr, " errno = %i\n", errno);
    exit(1);
  }
  for (t = 0; t < J; t++) {
    int j, l;
    j = aleatW(n - m + 1);
    if (fprintf(ofile, "%i,%i\n", j, j + m - 1) <= 0) {
      fprintf(stderr, "Error: cannot write file %s\n", argv[4]);
      fprintf(stderr, " errno = %i\n", errno);
      exit(1);
    }
  }
  if (fclose(ofile) != 0) {
    fprintf(stderr, "Error: cannot write file %s\n", argv[4]);
    fprintf(stderr, " errno = %i\n", errno);
    exit(1);
  }
  fprintf(stderr, "File %s successfully generated\n", argv[4]);
  exit(1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    11d8 <main+0x48>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x28(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
je     123c <main+0xac>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xf27(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
mov    0x2db6(%rip),%rax
mov    (%rax),%edx
lea    0xf23(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
movslq -0x28(%rbp),%rax
shr    $0x2,%rax
mov    %eax,-0x14(%rbp)
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xf01(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1287 <main+0xf7>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    12ab <main+0x11b>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xee4(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jge    12e6 <main+0x156>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
lea    0xedd(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xee6(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1352 <main+0x1c2>
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xebc(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2cb1(%rip),%rax
mov    (%rax),%edi
mov    0x2ca0(%rip),%rax
mov    (%rax),%edx
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x14(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    13ad <main+0x21d>
mov    0x2c70(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c56(%rip),%rax
mov    (%rax),%edi
mov    0x2c45(%rip),%rax
mov    (%rax),%edx
lea    0xdb2(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x30(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1414 <main+0x284>
mov    0x2c0e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2bef(%rip),%rax
mov    (%rax),%edi
mov    0x2bde(%rip),%rax
mov    (%rax),%edx
lea    0xd4b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xe16(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1489 <main+0x2f9>
mov    0x2b99(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
lea    0xdec(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2b7a(%rip),%rax
mov    (%rax),%edi
mov    0x2b69(%rip),%rax
mov    (%rax),%edx
lea    0xcd6(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x38(%rbp),%rax
mov    %eax,%edi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8
lea    0xdc8(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
cmp    $0x0,%rax
jg     14fe <main+0x36e>
mov    0x2b24(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
lea    0xdc1(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2b05(%rip),%rax
mov    (%rax),%edi
mov    0x2af4(%rip),%rax
mov    (%rax),%edx
lea    0xc61(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    15a8 <main+0x418>
mov    -0x14(%rbp),%edi
sub    -0x18(%rbp),%edi
add    $0x1,%edi
call   10b0 <aleatW@plt>
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%rax
mov    %eax,%edi
mov    -0x44(%rbp),%edx
mov    -0x44(%rbp),%ecx
add    -0x18(%rbp),%ecx
sub    $0x1,%ecx
lea    0xd70(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
cmp    $0x0,%rax
jg     1595 <main+0x405>
mov    0x2a8d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
lea    0xd2a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2a6e(%rip),%rax
mov    (%rax),%edi
mov    0x2a5d(%rip),%rax
mov    (%rax),%edx
lea    0xbca(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    159a <main+0x40a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1505 <main+0x375>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     1604 <main+0x474>
mov    0x2a1e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
lea    0xcbb(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x29ff(%rip),%rax
mov    (%rax),%edi
mov    0x29ee(%rip),%rax
mov    (%rax),%edx
lea    0xb5b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    0x29d5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
lea    0xc96(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x4,%edi
jg     11c7 <main+0x37>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe4a(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    0x8(%r14),%rdi
mov    %rsp,%rsi
call   1060 <stat@plt>
test   %rax,%rax
jne    123b <main+0xab>
mov    (%rsp),%r12d
sar    $0x2,%r12d
mov    0x2df9(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xf6a(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x10(%r14),%rdi
call   1090 <atoi@plt>
test   %eax,%eax
jle    126a <main+0xda>
mov    %eax,%r15d
mov    %r12d,%r13d
sub    %eax,%r13d
jl     126a <main+0xda>
mov    0x18(%r14),%rdi
call   1090 <atoi@plt>
test   %eax,%eax
jg     1288 <main+0xf8>
mov    0x0(%rbp),%edi
lea    0xf88(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    0x2d9e(%rip),%rbx
mov    (%rbx),%edi
mov    0x8(%r14),%rdx
lea    0xee3(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
mov    0x2d79(%rip),%rax
mov    (%rax),%edx
lea    0xee6(%rip),%rsi
jmp    1277 <main+0xe7>
mov    0x0(%rbp),%edi
lea    0xf0a(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    %eax,%ebx
mov    0x8(%r14),%rdi
lea    0xf46(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
jne    12b5 <main+0x125>
mov    0x2d3a(%rip),%rbx
mov    (%rbx),%edi
mov    0x8(%r14),%rdx
lea    0xf2a(%rip),%rsi
jmp    124f <main+0xbf>
mov    %rax,%rbp
mov    %r12d,%edi
call   1070 <malloc@plt>
test   %rax,%rax
jne    12e4 <main+0x154>
mov    0x2d14(%rip),%rbx
mov    (%rbx),%edi
lea    0xf30(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1256 <main+0xc6>
mov    %rax,%rdi
mov    %r12d,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    1332 <main+0x1a2>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    0x20(%r14),%rdi
lea    0xf33(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
jne    134b <main+0x1bb>
mov    0x2cc0(%rip),%rbx
mov    (%rbx),%edi
mov    0x20(%r14),%rdx
lea    0xf17(%rip),%rsi
jmp    124f <main+0xbf>
mov    0x2ca7(%rip),%rbx
mov    (%rbx),%edi
mov    0x8(%r14),%rdx
lea    0xee0(%rip),%rsi
jmp    124f <main+0xbf>
mov    %rax,%rbp
mov    0x8(%r14),%r8
lea    0xf13(%rip),%rsi
mov    %ebp,%edi
mov    %ebx,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
test   %rax,%rax
jg     1385 <main+0x1f5>
mov    0x2c6d(%rip),%rbx
mov    (%rbx),%edi
mov    0x20(%r14),%rdx
lea    0xf0e(%rip),%rsi
jmp    124f <main+0xbf>
add    $0x1,%r13d
add    $0xffffffff,%r15d
lea    0xf17(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13d,%edi
call   10b0 <aleatW@plt>
lea    (%r15,%rax,1),%ecx
mov    %ebp,%edi
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
test   %rax,%rax
jle    136c <main+0x1dc>
add    $0xffffffff,%ebx
jne    13a0 <main+0x210>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    0x2c0d(%rip),%rbx
mov    (%rbx),%edi
mov    0x20(%r14),%rdx
test   %rax,%rax
jne    1379 <main+0x1e9>
lea    0xecd(%rip),%rsi
jmp    11b6 <main+0x26>

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [306 x i8] c"\0AUsage: %s <intsfile> <length> <number> <intervals file>\0A\0A randomly extracts <number> intervals of length <length> from <intsfile>.\0A The output file, <intervals file> has a first line of the form:\0A # number=<number> length=<length> file=<intsfile>\0A and then <number> lines of the form <from>,<to>.\0A\0A\00"
@.str.1 = [28 x i8] c"Error: cannot stat file %s\0A\00"
@.str.2 = [13 x i8] c" errno = %i\0A\00"
@errno = global i32 0
@.str.3 = [35 x i8] c"\0A max value to be generated is %i\0A\00"
@.str.4 = [52 x i8] c"Error: length must be >= 1 and <= file length (%i)\0A\00"
@.str.5 = [41 x i8] c"Error: number of intervals must be >= 1\0A\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [40 x i8] c"Error: cannot open file %s for reading\0A\00"
@.str.8 = [33 x i8] c"Error: cannot allocate %i bytes\0A\00"
@.str.9 = [28 x i8] c"Error: cannot read file %s\0A\00"
@.str.10 = [2 x i8] c"w\00"
@.str.11 = [40 x i8] c"Error: cannot open file %s for writing\0A\00"
@.str.12 = [34 x i8] c"# number=%lu numwords=%i file=%s\0A\00"
@.str.13 = [29 x i8] c"Error: cannot write file %s\0A\00"
@.str.14 = [7 x i8] c"%i,%i\0A\00"
@.str.15 = [32 x i8] c"File %s successfully generated\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.stat
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 5
br i1 %17, label %18, label %25
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i64 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([306 x i8], [306 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i64 @stat(i8* %28, %struct.stat* %10)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %41
31: ; preds = %25
%32 = load i32, i32* @stderr
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i64 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %35)
%37 = load i32, i32* @stderr
%38 = load i32, i32* @errno
%39 = call i64 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %25
%42 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%43 = load i32, i32* %42
%44 = sext i32 %43 to i64
%45 = udiv i64 %44, 4
%46 = trunc i64 %45 to i32
store i32 %46, i32* %6
%47 = load i32, i32* @stderr
%48 = load i32, i32* %6
%49 = call i64 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 2
%52 = load i8*, i8** %51
%53 = call i32 @atoi(i8* %52)
store i32 %53, i32* %7
%54 = load i32, i32* %7
%55 = icmp sle i32 %54, 0
br i1 %55, label %60, label %56
56: ; preds = %41
%57 = load i32, i32* %7
%58 = load i32, i32* %6
%59 = icmp sgt i32 %57, %58
br i1 %59, label %60, label %65
60: ; preds = %56, %41
%61 = load i32, i32* @stderr
%62 = load i32, i32* %6
%63 = call i64 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0), i32 %62)
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %56
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 3
%68 = load i8*, i8** %67
%69 = call i32 @atoi(i8* %68)
store i32 %69, i32* %8
%70 = load i32, i32* %8
%71 = icmp slt i32 %70, 1
br i1 %71, label %72, label %76
72: ; preds = %65
%73 = load i32, i32* @stderr
%74 = call i64 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %65
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 1
%79 = load i8*, i8** %78
%80 = call i32* @fopen(i8* %79, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %80, i32** %11
%81 = load i32*, i32** %11
%82 = icmp eq i32* %81, null
br i1 %82, label %83, label %93
83: ; preds = %76
%84 = load i32, i32* @stderr
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 1
%87 = load i8*, i8** %86
%88 = call i64 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i8* %87)
%89 = load i32, i32* @stderr
%90 = load i32, i32* @errno
%91 = call i64 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %90)
%92 = call i32 @exit(i32 1)
unreachable
93: ; preds = %76
%94 = load i32, i32* %6
%95 = call i64 @malloc(i32 %94)
%96 = inttoptr i64 %95 to i8*
store i8* %96, i8** %13
%97 = load i8*, i8** %13
%98 = icmp eq i8* %97, null
br i1 %98, label %99, label %107
99: ; preds = %93
%100 = load i32, i32* @stderr
%101 = load i32, i32* %6
%102 = call i64 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %101)
%103 = load i32, i32* @stderr
%104 = load i32, i32* @errno
%105 = call i64 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %104)
%106 = call i32 @exit(i32 1)
unreachable
107: ; preds = %93
%108 = load i8*, i8** %13
%109 = load i32, i32* %6
%110 = load i32*, i32** %11
%111 = call i32 @fread(i8* %108, i32 %109, i32 1, i32* %110)
%112 = icmp ne i32 %111, 1
br i1 %112, label %113, label %123
113: ; preds = %107
%114 = load i32, i32* @stderr
%115 = load i8**, i8*** %5
%116 = getelementptr inbounds i8*, i8** %115, i64 1
%117 = load i8*, i8** %116
%118 = call i64 (i32, i8*, ...) @fprintf(i32 %114, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i8* %117)
%119 = load i32, i32* @stderr
%120 = load i32, i32* @errno
%121 = call i64 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %120)
%122 = call i32 @exit(i32 1)
unreachable
123: ; preds = %107
%124 = load i32*, i32** %11
%125 = call i64 @fclose(i32* %124)
%126 = load i8**, i8*** %5
%127 = getelementptr inbounds i8*, i8** %126, i64 4
%128 = load i8*, i8** %127
%129 = call i32* @fopen(i8* %128, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
store i32* %129, i32** %12
%130 = load i32*, i32** %12
%131 = icmp eq i32* %130, null
br i1 %131, label %132, label %142
132: ; preds = %123
%133 = load i32, i32* @stderr
%134 = load i8**, i8*** %5
%135 = getelementptr inbounds i8*, i8** %134, i64 4
%136 = load i8*, i8** %135
%137 = call i64 (i32, i8*, ...) @fprintf(i32 %133, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0), i8* %136)
%138 = load i32, i32* @stderr
%139 = load i32, i32* @errno
%140 = call i64 (i32, i8*, ...) @fprintf(i32 %138, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %139)
%141 = call i32 @exit(i32 1)
unreachable
142: ; preds = %123
%143 = load i32*, i32** %12
%144 = ptrtoint i32* %143 to i32
%145 = load i32, i32* %8
%146 = load i32, i32* %7
%147 = load i8**, i8*** %5
%148 = getelementptr inbounds i8*, i8** %147, i64 1
%149 = load i8*, i8** %148
%150 = call i64 (i32, i8*, ...) @fprintf(i32 %144, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.12, i64 0, i64 0), i32 %145, i32 %146, i8* %149)
%151 = icmp sle i64 %150, 0
br i1 %151, label %152, label %162
152: ; preds = %142
%153 = load i32, i32* @stderr
%154 = load i8**, i8*** %5
%155 = getelementptr inbounds i8*, i8** %154, i64 4
%156 = load i8*, i8** %155
%157 = call i64 (i32, i8*, ...) @fprintf(i32 %153, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0), i8* %156)
%158 = load i32, i32* @stderr
%159 = load i32, i32* @errno
%160 = call i64 (i32, i8*, ...) @fprintf(i32 %158, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %159)
%161 = call i32 @exit(i32 1)
unreachable
162: ; preds = %142
store i32 0, i32* %9
br label %163
163: ; preds = %193, %162
%164 = load i32, i32* %9
%165 = load i32, i32* %8
%166 = icmp slt i32 %164, %165
br i1 %166, label %167, label %196
167: ; preds = %163
%168 = load i32, i32* %6
%169 = load i32, i32* %7
%170 = sub nsw i32 %168, %169
%171 = add nsw i32 %170, 1
%172 = call i32 @aleatW(i32 %171)
store i32 %172, i32* %14
%173 = load i32*, i32** %12
%174 = ptrtoint i32* %173 to i32
%175 = load i32, i32* %14
%176 = load i32, i32* %14
%177 = load i32, i32* %7
%178 = add nsw i32 %176, %177
%179 = sub nsw i32 %178, 1
%180 = call i64 (i32, i8*, ...) @fprintf(i32 %174, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0), i32 %175, i32 %179)
%181 = icmp sle i64 %180, 0
br i1 %181, label %182, label %192
182: ; preds = %167
%183 = load i32, i32* @stderr
%184 = load i8**, i8*** %5
%185 = getelementptr inbounds i8*, i8** %184, i64 4
%186 = load i8*, i8** %185
%187 = call i64 (i32, i8*, ...) @fprintf(i32 %183, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0), i8* %186)
%188 = load i32, i32* @stderr
%189 = load i32, i32* @errno
%190 = call i64 (i32, i8*, ...) @fprintf(i32 %188, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %189)
%191 = call i32 @exit(i32 1)
unreachable
192: ; preds = %167
br label %193
193: ; preds = %192
%194 = load i32, i32* %9
%195 = add nsw i32 %194, 1
store i32 %195, i32* %9
br label %163
196: ; preds = %163
%197 = load i32*, i32** %12
%198 = call i64 @fclose(i32* %197)
%199 = icmp ne i64 %198, 0
br i1 %199, label %200, label %210
200: ; preds = %196
%201 = load i32, i32* @stderr
%202 = load i8**, i8*** %5
%203 = getelementptr inbounds i8*, i8** %202, i64 4
%204 = load i8*, i8** %203
%205 = call i64 (i32, i8*, ...) @fprintf(i32 %201, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0), i8* %204)
%206 = load i32, i32* @stderr
%207 = load i32, i32* @errno
%208 = call i64 (i32, i8*, ...) @fprintf(i32 %206, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %207)
%209 = call i32 @exit(i32 1)
unreachable
210: ; preds = %196
%211 = load i32, i32* @stderr
%212 = load i8**, i8*** %5
%213 = getelementptr inbounds i8*, i8** %212, i64 4
%214 = load i8*, i8** %213
%215 = call i64 (i32, i8*, ...) @fprintf(i32 %211, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.15, i64 0, i64 0), i8* %214)
%216 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [306 x i8] c"\0AUsage: %s <intsfile> <length> <number> <intervals file>\0A\0A randomly extracts <number> intervals of length <length> from <intsfile>.\0A The output file, <intervals file> has a first line of the form:\0A # number=<number> length=<length> file=<intsfile>\0A and then <number> lines of the form <from>,<to>.\0A\0A\00"
@.str.1 = [28 x i8] c"Error: cannot stat file %s\0A\00"
@.str.2 = [13 x i8] c" errno = %i\0A\00"
@errno = global i32 0
@.str.3 = [35 x i8] c"\0A max value to be generated is %i\0A\00"
@.str.4 = [52 x i8] c"Error: length must be >= 1 and <= file length (%i)\0A\00"
@.str.5 = [41 x i8] c"Error: number of intervals must be >= 1\0A\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [40 x i8] c"Error: cannot open file %s for reading\0A\00"
@.str.8 = [33 x i8] c"Error: cannot allocate %i bytes\0A\00"
@.str.9 = [28 x i8] c"Error: cannot read file %s\0A\00"
@.str.10 = [2 x i8] c"w\00"
@.str.11 = [40 x i8] c"Error: cannot open file %s for writing\0A\00"
@.str.12 = [34 x i8] c"# number=%lu numwords=%i file=%s\0A\00"
@.str.13 = [29 x i8] c"Error: cannot write file %s\0A\00"
@.str.14 = [7 x i8] c"%i,%i\0A\00"
@.str.15 = [32 x i8] c"File %s successfully generated\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp slt i32 %0, 5
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i64 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([306 x i8], [306 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @stat(i8* %13, %struct.stat* %3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %12
%19 = call i64 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @stderr
%21 = load i32, i32* @errno
%22 = call i64 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %11
%25 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%26 = load i32, i32* %25
%27 = ashr i32 %26, 2
%28 = load i32, i32* @stderr
%29 = call i64 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%30 = getelementptr inbounds i8*, i8** %1, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
%33 = icmp slt i32 %32, 1
%34 = icmp slt i32 %27, %32
%35 = or i1 %33, %34
br i1 %35, label %36, label %40
36: ; preds = %24
%37 = load i32, i32* @stderr
%38 = call i64 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %24
%41 = getelementptr inbounds i8*, i8** %1, i64 3
%42 = load i8*, i8** %41
%43 = call i32 @atoi(i8* %42)
%44 = icmp slt i32 %43, 1
br i1 %44, label %45, label %49
45: ; preds = %40
%46 = load i32, i32* @stderr
%47 = call i64 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %40
%50 = load i8*, i8** %12
%51 = call i32* @fopen(i8* %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%52 = icmp eq i32* %51, null
br i1 %52, label %53, label %61
53: ; preds = %49
%54 = load i32, i32* @stderr
%55 = load i8*, i8** %12
%56 = call i64 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i8* %55)
%57 = load i32, i32* @stderr
%58 = load i32, i32* @errno
%59 = call i64 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %58)
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %49
%62 = call i64 @malloc(i32 %27)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %71
64: ; preds = %61
%65 = load i32, i32* @stderr
%66 = call i64 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %27)
%67 = load i32, i32* @stderr
%68 = load i32, i32* @errno
%69 = call i64 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %68)
%70 = call i32 @exit(i32 1)
unreachable
71: ; preds = %61
%72 = inttoptr i64 %62 to i8*
%73 = call i32 @fread(i8* %72, i32 %27, i32 1, i32* %51)
%74 = icmp eq i32 %73, 1
br i1 %74, label %83, label %75
75: ; preds = %71
%76 = load i32, i32* @stderr
%77 = load i8*, i8** %12
%78 = call i64 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i8* %77)
%79 = load i32, i32* @stderr
%80 = load i32, i32* @errno
%81 = call i64 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %80)
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %71
%84 = call i64 @fclose(i32* %51)
%85 = getelementptr inbounds i8*, i8** %1, i64 4
%86 = load i8*, i8** %85
%87 = call i32* @fopen(i8* %86, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%88 = icmp eq i32* %87, null
br i1 %88, label %89, label %97
89: ; preds = %83
%90 = load i32, i32* @stderr
%91 = load i8*, i8** %85
%92 = call i64 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0), i8* %91)
%93 = load i32, i32* @stderr
%94 = load i32, i32* @errno
%95 = call i64 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %94)
%96 = call i32 @exit(i32 1)
unreachable
97: ; preds = %83
%98 = ptrtoint i32* %87 to i64
%99 = trunc i64 %98 to i32
%100 = load i8*, i8** %12
%101 = call i64 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.12, i64 0, i64 0), i32 %43, i32 %32, i8* %100)
%102 = icmp slt i64 %101, 1
br i1 %102, label %107, label %103
103: ; preds = %97
%104 = add nsw i32 %27, 1
%105 = sub i32 %104, %32
%106 = add nsw i32 %32, -1
br label %117
107: ; preds = %97
%108 = load i32, i32* @stderr
%109 = load i8*, i8** %85
%110 = call i64 (i32, i8*, ...) @fprintf(i32 %108, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0), i8* %109)
%111 = load i32, i32* @stderr
%112 = load i32, i32* @errno
%113 = call i64 (i32, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %112)
%114 = call i32 @exit(i32 1)
unreachable
115: ; preds = %117
%116 = icmp eq i32 %123, %43
br i1 %116, label %132, label %117
117: ; preds = %103, %115
%118 = phi i32 [ 0, %103 ], [ %123, %115 ]
%119 = call i32 @aleatW(i32 %105)
%120 = add i32 %106, %119
%121 = call i64 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0), i32 %119, i32 %120)
%122 = icmp slt i64 %121, 1
%123 = add nuw nsw i32 %118, 1
br i1 %122, label %124, label %115
124: ; preds = %117
%125 = load i32, i32* @stderr
%126 = load i8*, i8** %85
%127 = call i64 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0), i8* %126)
%128 = load i32, i32* @stderr
%129 = load i32, i32* @errno
%130 = call i64 (i32, i8*, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %129)
%131 = call i32 @exit(i32 1)
unreachable
132: ; preds = %115
%133 = call i64 @fclose(i32* %87)
%134 = icmp eq i64 %133, 0
%135 = load i32, i32* @stderr
%136 = load i8*, i8** %85
br i1 %134, label %143, label %137
137: ; preds = %132
%138 = call i64 (i32, i8*, ...) @fprintf(i32 %135, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0), i8* %136)
%139 = load i32, i32* @stderr
%140 = load i32, i32* @errno
%141 = call i64 (i32, i8*, ...) @fprintf(i32 %139, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %140)
%142 = call i32 @exit(i32 1)
unreachable
143: ; preds = %132
%144 = call i64 (i32, i8*, ...) @fprintf(i32 %135, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.15, i64 0, i64 0), i8* %136)
%145 = call i32 @exit(i32 1)
unreachable
}