#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(float *);
int /*<<< orphan*/ fwrite(float *, int, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scan_line(int /*<<< orphan*/ *, float *, int);
int main(int argc, char *argv[]) {
  FILE *ftext;
  FILE *ffloat;
  int st, en;
  float *buf;
  long lines;
  if (argc != 5) {
    printf("usage: %s TextFile FloatFile start(1 .. 10) end(1 .. 10)\n",
           argv[0]);
    exit(1);
  }
  ftext = fopen(argv[1], "rt");
  if (ftext == NULL) {
    printf("Error opening text file: %s\n", argv[1]);
    exit(1);
  }
  ffloat = fopen(argv[2], "wb");
  if (ffloat == NULL) {
    printf("Error opening float file: %s\n", argv[2]);
    exit(1);
  }
  st = atoi(argv[3]);
  en = atoi(argv[4]);
  buf = (float *)malloc(en * sizeof(float));
  if (buf == NULL) {
    printf("Error in malloc()\n");
    exit(1);
  }
  lines = 0;
  while (!feof(ftext)) {
    scan_line(ftext, buf, en);
    if (!feof(ftext)) {
      fwrite(&buf[st - 1], sizeof(float), en - st + 1, ffloat);
      printf("\r%ld lines", ++lines);
    }
  }
  printf("\n");
  free(buf);
  fclose(ftext);
  fclose(ffloat);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     11df <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4c(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1222 <main+0x82>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe29(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1265 <main+0xc5>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x28(%rbp)
movslq -0x28(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12bb <main+0x11b>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12e1 <main+0x141>
jmp    134c <main+0x1ac>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%edx
call   1040 <scan_line@plt>
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
jne    1347 <main+0x1a7>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x28(%rbp),%edx
sub    -0x24(%rbp),%edx
add    $0x1,%edx
mov    -0x20(%rbp),%rcx
mov    $0x4,%esi
call   10c0 <fwrite@plt>
mov    -0x38(%rbp),%rsi
add    $0x1,%rsi
mov    %rsi,-0x38(%rbp)
lea    0xd4e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12c3 <main+0x123>
lea    0xd39(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbp
cmp    $0x5,%edi
jne    12f0 <main+0x130>
mov    0x8(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12fd <main+0x13d>
mov    %rax,%rbx
mov    0x10(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     130a <main+0x14a>
mov    0x18(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,%r14d
mov    0x20(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,%r12d
lea    0x0(,%r12,4),%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     1326 <main+0x166>
mov    %rax,%r15
mov    %rbx,%rdi
call   1090 <feof@plt>
test   %eax,%eax
je     1281 <main+0xc1>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1070 <fclose@plt>
mov    (%rsp),%rdi
call   1070 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movslq %r14d,%rax
lea    (%r15,%rax,4),%r13
add    $0xfffffffffffffffc,%r13
mov    %r12d,%ebp
sub    %eax,%ebp
add    $0x1,%ebp
xor    %r14d,%r14d
jmp    12ac <main+0xec>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    124d <main+0x8d>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1060 <scan_line@plt>
mov    %rbx,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    12a0 <main+0xe0>
mov    %r13,%rdi
mov    $0x4,%esi
mov    %ebp,%edx
mov    (%rsp),%rcx
call   10e0 <fwrite@plt>
add    $0x1,%r14
lea    0xd97(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    12a0 <main+0xe0>
mov    0x0(%rbp),%rsi
lea    0xd05(%rip),%rdi
jmp    1315 <main+0x155>
mov    0x8(%rbp),%rsi
lea    0xd35(%rip),%rdi
jmp    1315 <main+0x155>
mov    0x10(%rbp),%rsi
lea    0xd48(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xd59(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [58 x i8] c"usage: %s TextFile FloatFile start(1 .. 10) end(1 .. 10)\0A\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [29 x i8] c"Error opening text file: %s\0A\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [30 x i8] c"Error opening float file: %s\0A\00"
@.str.5 = [19 x i8] c"Error in malloc()\0A\00"
@.str.6 = [11 x i8] c"\0D%ld lines\00"
@.str.7 = [2 x i8] c"\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 float*
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 5
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %6
%25 = load i32*, i32** %6
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %33
27: ; preds = %20
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %20
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %37, i32** %7
%38 = load i32*, i32** %7
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %46
40: ; preds = %33
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %43)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %33
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 3
%49 = load i8*, i8** %48
%50 = call i32 @atoi(i8* %49)
store i32 %50, i32* %8
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 4
%53 = load i8*, i8** %52
%54 = call i32 @atoi(i8* %53)
store i32 %54, i32* %9
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = mul i64 %56, 4
%58 = trunc i64 %57 to i32
%59 = call i64 @malloc(i32 %58)
%60 = inttoptr i64 %59 to float*
store float* %60, float** %10
%61 = load float*, float** %10
%62 = icmp eq float* %61, null
br i1 %62, label %63, label %66
63: ; preds = %46
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %46
store i64 0, i64* %11
br label %67
67: ; preds = %95, %66
%68 = load i32*, i32** %6
%69 = call i32 @feof(i32* %68)
%70 = icmp ne i32 %69, 0
%71 = xor i1 %70, true
br i1 %71, label %72, label %96
72: ; preds = %67
%73 = load i32*, i32** %6
%74 = load float*, float** %10
%75 = load i32, i32* %9
%76 = call i32 @scan_line(i32* %73, float* %74, i32 %75)
%77 = load i32*, i32** %6
%78 = call i32 @feof(i32* %77)
%79 = icmp ne i32 %78, 0
br i1 %79, label %95, label %80
80: ; preds = %72
%81 = load float*, float** %10
%82 = load i32, i32* %8
%83 = sub nsw i32 %82, 1
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds float, float* %81, i64 %84
%86 = load i32, i32* %9
%87 = load i32, i32* %8
%88 = sub nsw i32 %86, %87
%89 = add nsw i32 %88, 1
%90 = load i32*, i32** %7
%91 = call i32 @fwrite(float* %85, i32 4, i32 %89, i32* %90)
%92 = load i64, i64* %11
%93 = add nsw i64 %92, 1
store i64 %93, i64* %11
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i64 %93)
br label %95
95: ; preds = %80, %72
br label %67
96: ; preds = %67
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%98 = load float*, float** %10
%99 = call i32 @free(float* %98)
%100 = load i32*, i32** %6
%101 = call i32 @fclose(i32* %100)
%102 = load i32*, i32** %7
%103 = call i32 @fclose(i32* %102)
ret i32 0
}

LLVM IR (-O2):
@.str = [58 x i8] c"usage: %s TextFile FloatFile start(1 .. 10) end(1 .. 10)\0A\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [29 x i8] c"Error opening text file: %s\0A\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [30 x i8] c"Error opening float file: %s\0A\00"
@.str.6 = [11 x i8] c"\0D%ld lines\00"
@str = [18 x i8] c"Error in malloc()\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 5
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, 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 %13, label %17
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %8
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %26
22: ; preds = %17
%23 = load i8*, i8** %18
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %23)
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %17
%27 = getelementptr inbounds i8*, i8** %1, i64 3
%28 = load i8*, i8** %27
%29 = tail call i32 @atoi(i8* %28)
%30 = getelementptr inbounds i8*, i8** %1, i64 4
%31 = load i8*, i8** %30
%32 = tail call i32 @atoi(i8* %31)
%33 = shl i32 %32, 2
%34 = tail call i64 @malloc(i32 %33)
%35 = inttoptr i64 %34 to float*
%36 = icmp eq i64 %34, 0
br i1 %36, label %46, label %37
37: ; preds = %26
%38 = tail call i32 @feof(i32* %11)
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %62
40: ; preds = %37
%41 = add nsw i32 %29, -1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds float, float* %35, i64 %42
%44 = sub i32 1, %29
%45 = add i32 %44, %32
br label %49
46: ; preds = %26
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%48 = tail call i32 @exit(i32 1)
unreachable
49: ; preds = %40, %58
%50 = phi i64 [ 0, %40 ], [ %59, %58 ]
%51 = tail call i32 @scan_line(i32* %11, float* %35, i32 %32)
%52 = tail call i32 @feof(i32* %11)
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %49
%55 = tail call i32 @fwrite(float* %43, i32 4, i32 %45, i32* %20)
%56 = add nsw i64 %50, 1
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i64 %56)
br label %58
58: ; preds = %54, %49
%59 = phi i64 [ %50, %49 ], [ %56, %54 ]
%60 = tail call i32 @feof(i32* %11)
%61 = icmp eq i32 %60, 0
br i1 %61, label %49, label %62
62: ; preds = %58, %37
%63 = tail call i32 @putchar(i32 10)
%64 = tail call i32 @free(float* %35)
%65 = tail call i32 @fclose(i32* %11)
%66 = tail call i32 @fclose(i32* %20)
ret i32 0
}