#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 */
unsigned int atoi(char *);
int /*<<< orphan*/ errorHandler(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  FILE *fIn, *fOut, *fTmp;
  char cBuffer[32];
  unsigned int count, i, j, k, N, nrows, ncols;
  double data;
  if (argc == 2 && strcmp(argv[1], "-h") == 0) {
    printf("\n\nCall as:\n\n\t./gplotForm filename N nrows ncols.\n");
    printf("\nInserts a blank row every nrows for all ncols in filename");
    printf(" for all N rows in\nthe file. Input file is not altered in ");
    printf("any way. Output file is by default\ncalled 'temp.gnu'.\n\n");
    exit(0);
  } else if (argc != 5) {
    printf("\n\nCorrect syntax is:\n\n\t./gplotForm filename N nrows ncols.\n");
    errorHandler("Type './sep -h' for help.\n");
  }
  fIn = fopen(argv[1], "r");
  N = atoi(argv[2]);
  nrows = atoi(argv[3]);
  ncols = atoi(argv[4]);
  for (i = 0; i < ncols; i++)
    fscanf(fIn, "%s", cBuffer);
  fOut = fopen("temp.gnu", "w");
  count = 0;
  for (j = 0; j < N; j++) {
    for (k = 0; k < ncols; k++) {
      fscanf(fIn, "%le", &data);
      fprintf(fOut, "%le\t", data);
    }
    fprintf(fOut, "\n");
    count++;
    if (count == nrows) {
      count = 0;
      fprintf(fOut, "\n");
    }
  }
  fclose(fOut);
  fclose(fIn);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1208 <main+0x78>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3e(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1208 <main+0x78>
lea    0xe2b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe51(%rip),%rdi
call   1040 <printf@plt>
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
lea    0xeaf(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
cmpl   $0x5,-0x8(%rbp)
je     122a <main+0x9a>
lea    0xeca(%rip),%rdi
call   1040 <printf@plt>
lea    0xefa(%rip),%rdi
call   10b0 <errorHandler@plt>
jmp    122f <main+0x9f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xefc(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x64(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x6c(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x6c(%rbp),%eax
jae    12ae <main+0x11e>
mov    -0x18(%rbp),%rdi
lea    -0x50(%rbp),%rdx
lea    0xea3(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    127e <main+0xee>
lea    0xe8a(%rip),%rdi
lea    0xe8c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x64(%rbp),%eax
jae    1380 <main+0x1f0>
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x6c(%rbp),%eax
jae    132d <main+0x19d>
mov    -0x18(%rbp),%rdi
lea    0xe4d(%rip),%rsi
lea    -0x78(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%rdi
movsd  -0x78(%rbp),%xmm0
lea    0xe36(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    12e6 <main+0x156>
mov    -0x20(%rbp),%rdi
lea    0xda9(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x68(%rbp),%eax
jne    136d <main+0x1dd>
movl   $0x0,-0x54(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xd7b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1372 <main+0x1e2>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    12d3 <main+0x143>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbp
cmp    $0x5,%edi
je     11fc <main+0x4c>
cmp    $0x2,%edi
jne    11e4 <main+0x34>
mov    0x8(%rbp),%rdi
lea    0xe2a(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1348 <main+0x198>
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe82(%rip),%rdi
call   10d0 <errorHandler@plt>
mov    0x8(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
mov    0x10(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,0x8(%rsp)
mov    0x18(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,0xc(%rsp)
mov    0x20(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
je     1265 <main+0xb5>
lea    0xe55(%rip),%r14
lea    0x20(%rsp),%r15
mov    0x4(%rsp),%ebp
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
add    $0xffffffff,%ebp
jne    1250 <main+0xa0>
lea    0xe2d(%rip),%rdi
lea    0xe2f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbp
cmpl   $0x0,0x8(%rsp)
je     1327 <main+0x177>
lea    0xe17(%rip),%r13
lea    0x18(%rsp),%r14
lea    0xe0f(%rip),%r15
xor    %ecx,%ecx
xor    %eax,%eax
jmp    12ad <main+0xfd>
nop
mov    0x14(%rsp),%eax
add    $0x1,%eax
cmp    0x8(%rsp),%eax
je     1327 <main+0x177>
mov    %ecx,0x10(%rsp)
mov    %eax,0x14(%rsp)
cmpl   $0x0,0x4(%rsp)
je     12f9 <main+0x149>
mov    0x4(%rsp),%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
movsd  0x18(%rsp),%xmm0
mov    %rbp,%rdi
mov    %r15,%rsi
mov    $0x1,%al
call   1090 <fprintf@plt>
add    $0xffffffff,%r12d
jne    12d0 <main+0x120>
mov    $0xa,%edi
mov    %rbp,%rsi
call   1070 <fputc@plt>
mov    0x10(%rsp),%ecx
add    $0x1,%ecx
cmp    0xc(%rsp),%ecx
jne    12a0 <main+0xf0>
mov    $0xa,%edi
mov    %rbp,%rsi
call   1070 <fputc@plt>
xor    %ecx,%ecx
jmp    12a0 <main+0xf0>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd99(%rip),%rdi
call   1030 <puts@plt>
lea    0xca8(%rip),%rdi
call   1050 <printf@plt>
lea    0xcd7(%rip),%rdi
call   1050 <printf@plt>
lea    0xda6(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [50 x i8] c"\0A\0ACall as:\0A\0A\09./gplotForm filename N nrows ncols.\0A\00"
@.str.2 = [59 x i8] c"\0AInserts a blank row every nrows for all ncols in filename\00"
@.str.3 = [59 x i8] c" for all N rows in\0Athe file. Input file is not altered in \00"
@.str.4 = [56 x i8] c"any way. Output file is by default\0Acalled 'temp.gnu'.\0A\0A\00"
@.str.5 = [60 x i8] c"\0A\0ACorrect syntax is:\0A\0A\09./gplotForm filename N nrows ncols.\0A\00"
@.str.6 = [27 x i8] c"Type './sep -h' for help.\0A\00"
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [9 x i8] c"temp.gnu\00"
@.str.10 = [2 x i8] c"w\00"
@.str.11 = [4 x i8] c"%le\00"
@.str.12 = [5 x i8] c"%le\09\00"
@.str.13 = [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 [32 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %32
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %20
%27 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 @exit(i32 0)
unreachable
32: ; preds = %20, %2
%33 = load i32, i32* %4
%34 = icmp ne i32 %33, 5
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.5, i64 0, i64 0))
%37 = call i32 @errorHandler(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
br label %38
38: ; preds = %35, %32
br label %39
39: ; preds = %38
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32* @fopen(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %43, i32** %6
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 2
%46 = load i8*, i8** %45
%47 = call i32 @atoi(i8* %46)
store i32 %47, i32* %14
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 3
%50 = load i8*, i8** %49
%51 = call i32 @atoi(i8* %50)
store i32 %51, i32* %15
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 4
%54 = load i8*, i8** %53
%55 = call i32 @atoi(i8* %54)
store i32 %55, i32* %16
store i32 0, i32* %11
br label %56
56: ; preds = %64, %39
%57 = load i32, i32* %11
%58 = load i32, i32* %16
%59 = icmp ult i32 %57, %58
br i1 %59, label %60, label %67
60: ; preds = %56
%61 = load i32*, i32** %6
%62 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%63 = call i32 (i32*, i8*, ...) @fscanf(i32* %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %62)
br label %64
64: ; preds = %60
%65 = load i32, i32* %11
%66 = add i32 %65, 1
store i32 %66, i32* %11
br label %56
67: ; preds = %56
%68 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
store i32* %68, i32** %7
store i32 0, i32* %10
store i32 0, i32* %12
br label %69
69: ; preds = %99, %67
%70 = load i32, i32* %12
%71 = load i32, i32* %14
%72 = icmp ult i32 %70, %71
br i1 %72, label %73, label %102
73: ; preds = %69
store i32 0, i32* %13
br label %74
74: ; preds = %84, %73
%75 = load i32, i32* %13
%76 = load i32, i32* %16
%77 = icmp ult i32 %75, %76
br i1 %77, label %78, label %87
78: ; preds = %74
%79 = load i32*, i32** %6
%80 = call i32 (i32*, i8*, ...) @fscanf(i32* %79, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), double* %17)
%81 = load i32*, i32** %7
%82 = load double, double* %17
%83 = call i32 (i32*, i8*, ...) @fprintf(i32* %81, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), double %82)
br label %84
84: ; preds = %78
%85 = load i32, i32* %13
%86 = add i32 %85, 1
store i32 %86, i32* %13
br label %74
87: ; preds = %74
%88 = load i32*, i32** %7
%89 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%90 = load i32, i32* %10
%91 = add i32 %90, 1
store i32 %91, i32* %10
%92 = load i32, i32* %10
%93 = load i32, i32* %15
%94 = icmp eq i32 %92, %93
br i1 %94, label %95, label %98
95: ; preds = %87
store i32 0, i32* %10
%96 = load i32*, i32** %7
%97 = call i32 (i32*, i8*, ...) @fprintf(i32* %96, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
br label %98
98: ; preds = %95, %87
br label %99
99: ; preds = %98
%100 = load i32, i32* %12
%101 = add i32 %100, 1
store i32 %101, i32* %12
br label %69
102: ; preds = %69
%103 = load i32*, i32** %7
%104 = call i32 @fclose(i32* %103)
%105 = load i32*, i32** %6
%106 = call i32 @fclose(i32* %105)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.2 = [59 x i8] c"\0AInserts a blank row every nrows for all ncols in filename\00"
@.str.3 = [59 x i8] c" for all N rows in\0Athe file. Input file is not altered in \00"
@.str.6 = [27 x i8] c"Type './sep -h' for help.\0A\00"
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [9 x i8] c"temp.gnu\00"
@.str.10 = [2 x i8] c"w\00"
@.str.11 = [4 x i8] c"%le\00"
@.str.12 = [5 x i8] c"%le\09\00"
@str = [59 x i8] c"\0A\0ACorrect syntax is:\0A\0A\09./gplotForm filename N nrows ncols.\00"
@str.14 = [49 x i8] c"\0A\0ACall as:\0A\0A\09./gplotForm filename N nrows ncols.\00"
@str.15 = [55 x i8] c"any way. Output file is by default\0Acalled 'temp.gnu'.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32 x i8]
%4 = alloca double
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%6 = bitcast double* %4 to i8*
switch i32 %0, label %18 [
i32 2, label %7
i32 5, label %21
]
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %7
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.14, i64 0, i64 0))
%14 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.15, i64 0, i64 0))
%17 = tail call i32 @exit(i32 0)
unreachable
18: ; preds = %7, %2
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
%20 = tail call i32 @errorHandler(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
br label %21
21: ; preds = %2, %18
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = tail call i32 @atoi(i8* %26)
%28 = getelementptr inbounds i8*, i8** %1, i64 3
%29 = load i8*, i8** %28
%30 = tail call i32 @atoi(i8* %29)
%31 = getelementptr inbounds i8*, i8** %1, i64 4
%32 = load i8*, i8** %31
%33 = tail call i32 @atoi(i8* %32)
%34 = icmp eq i32 %33, 0
br i1 %34, label %40, label %35
35: ; preds = %21, %35
%36 = phi i32 [ %38, %35 ], [ 0, %21 ]
%37 = call i32 (i32*, i8*, ...) @fscanf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %5)
%38 = add nuw i32 %36, 1
%39 = icmp eq i32 %38, %33
br i1 %39, label %40, label %35
40: ; preds = %35, %21
%41 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%42 = icmp eq i32 %27, 0
br i1 %42, label %63, label %43
43: ; preds = %40, %59
%44 = phi i32 [ %60, %59 ], [ 0, %40 ]
%45 = phi i32 [ %61, %59 ], [ 0, %40 ]
br i1 %34, label %53, label %46
46: ; preds = %43, %46
%47 = phi i32 [ %51, %46 ], [ 0, %43 ]
%48 = call i32 (i32*, i8*, ...) @fscanf(i32* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), double* %4)
%49 = load double, double* %4
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), double %49)
%51 = add nuw i32 %47, 1
%52 = icmp eq i32 %51, %33
br i1 %52, label %53, label %46
53: ; preds = %46, %43
%54 = call i32 @fputc(i32 10, i32* %41)
%55 = add i32 %44, 1
%56 = icmp eq i32 %55, %30
br i1 %56, label %57, label %59
57: ; preds = %53
%58 = call i32 @fputc(i32 10, i32* %41)
br label %59
59: ; preds = %53, %57
%60 = phi i32 [ 0, %57 ], [ %55, %53 ]
%61 = add nuw i32 %45, 1
%62 = icmp eq i32 %61, %27
br i1 %62, label %63, label %43
63: ; preds = %59, %40
%64 = call i32 @fclose(i32* %41)
%65 = call i32 @fclose(i32* %24)
ret i32 0
}