#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 */
char EOF;
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char **, int *, int *,
                          char **, char **);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
void ptoo(char *f1, char *f2, char *f3, char *f4) {
  struct peak {
    char chr[50];
    int start;
    int end;
  };
  struct peak peak;
  FILE *p1;
  FILE *p2;
  char c[50];
  int filenum;
  int fnum1;
  int num;
  int i;
  char ch1;
  filenum = atoi(f3);
  fnum1 = atoi(f4);
  if ((p1 = fopen(f1, "r")) == NULL) {
    printf("\nerror occurred when opening the input file to combine peaks!");
    getchar();
    exit(1);
  }
  if ((p2 = fopen(f2, "wb")) == NULL) {
    printf("\ncreate output file error\n");
    getchar();
    exit(1);
  }
  num = 1;
  ch1 = fgetc(p1);
  rewind(p1);
  if (ch1 != EOF)
    while (!feof(p1)) {
      fscanf(p1, "%s\t%d\t%d\t%s\t%s\n", &peak.chr, &peak.start, &peak.end, &c,
             &c);
      fprintf(p2, "%s\t%d\t%d\tMACS_peak_order_%d\t", peak.chr, peak.start,
              peak.end, num);
      num++;
      for (i = 0; i <= (filenum * filenum - 1); i++)
        if (i == fnum1)
          fprintf(p2, "1");
        else
          fprintf(p2, "0");
      fprintf(p2, "\n");
    }
}


x86 assembly (clang, -O0):
<ptoo>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0xb4(%rbp)
mov    -0x20(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0xb8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe1c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x68(%rbp)
cmp    $0x0,%rax
jne    1214 <ptoo+0x74>
lea    0xe04(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rdi
lea    0xe21(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x70(%rbp)
cmp    $0x0,%rax
jne    124f <ptoo+0xaf>
lea    0xe0a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x1,-0xbc(%rbp)
mov    -0x68(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0xc1(%rbp)
mov    -0x68(%rbp),%rdi
call   1040 <rewind@plt>
movsbl -0xc1(%rbp),%eax
mov    0x2d69(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     13ae <ptoo+0x20e>
jmp    128f <ptoo+0xef>
mov    -0x68(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12ad <ptoo+0x10d>
jmp    13a9 <ptoo+0x209>
mov    -0x68(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    -0x60(%rbp),%rcx
add    $0x34,%rcx
lea    -0x60(%rbp),%r8
add    $0x38,%r8
lea    -0xb0(%rbp),%r9
lea    -0xb0(%rbp),%rax
lea    0xd84(%rip),%rsi
mov    %rax,(%rsp)
call   1050 <fscanf@plt>
mov    -0x70(%rbp),%rdi
lea    -0x60(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0xbc(%rbp),%r9d
lea    0xd6e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
movl   $0x0,-0xc0(%rbp)
mov    -0xc0(%rbp),%eax
mov    -0xb4(%rbp),%ecx
imul   -0xb4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1392 <ptoo+0x1f2>
mov    -0xc0(%rbp),%eax
cmp    -0xb8(%rbp),%eax
jne    1367 <ptoo+0x1c7>
mov    -0x70(%rbp),%rdi
lea    0xd30(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1379 <ptoo+0x1d9>
mov    -0x70(%rbp),%rdi
lea    0xd1b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    137e <ptoo+0x1de>
mov    -0xc0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc0(%rbp)
jmp    1320 <ptoo+0x180>
mov    -0x70(%rbp),%rdi
lea    0xcbf(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    128f <ptoo+0xef>
jmp    13ae <ptoo+0x20e>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptoo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rcx,%rbp
mov    %rsi,%r12
mov    %rdi,%r14
mov    %rdx,%rdi
call   10d0 <atoi@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   10d0 <atoi@plt>
mov    %eax,%r15d
lea    0xe90(%rip),%rsi
mov    %r14,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1302 <ptoo+0x142>
mov    %rax,%r14
lea    0xe2d(%rip),%rsi
mov    %r12,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1310 <ptoo+0x150>
mov    %rax,%rbp
mov    %r14,%rdi
call   1070 <fgetc@plt>
mov    %eax,%r12d
mov    %r14,%rdi
call   1050 <rewind@plt>
mov    0x2da9(%rip),%rax
cmp    (%rax),%r12b
je     1250 <ptoo+0x90>
mov    %r14,%rdi
call   10b0 <feof@plt>
test   %eax,%eax
je     1262 <ptoo+0xa2>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
imul   %ebx,%ebx
mov    $0x1,%r12d
jmp    128d <ptoo+0xcd>
nopl   (%rax)
add    $0x1,%r12d
mov    $0xa,%edi
mov    %rbp,%rsi
call   1080 <fputc@plt>
mov    %r14,%rdi
call   10b0 <feof@plt>
test   %eax,%eax
jne    1250 <ptoo+0x90>
lea    0x50(%rsp),%r9
mov    %r9,(%rsp)
mov    %r14,%rdi
lea    0xda1(%rip),%rsi
lea    0x10(%rsp),%r13
mov    %r13,%rdx
lea    0x44(%rsp),%rcx
lea    0x48(%rsp),%r8
call   1060 <fscanf@plt>
mov    0x44(%rsp),%ecx
mov    0x48(%rsp),%r8d
mov    %rbp,%rdi
lea    0xd87(%rip),%rsi
mov    %r13,%rdx
mov    %r12d,%r9d
xor    %eax,%eax
call   10a0 <fprintf@plt>
test   %ebx,%ebx
je     1270 <ptoo+0xb0>
xor    %r13d,%r13d
xchg   %ax,%ax
xor    %edi,%edi
cmp    %r13d,%r15d
sete   %dil
or     $0x30,%edi
mov    %rbp,%rsi
call   1080 <fputc@plt>
add    $0x1,%r13d
cmp    %r13d,%ebx
jne    12e0 <ptoo+0x120>
jmp    1270 <ptoo+0xb0>
lea    0xcf7(%rip),%rdi
call   1040 <printf@plt>
jmp    131c <ptoo+0x15c>
lea    0xd57(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.peak = type { [50 x i8], i32, i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [62 x i8] c"\0Aerror occurred when opening the input file to combine peaks!\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [27 x i8] c"\0Acreate output file error\0A\00"
@EOF = global i8 0
@.str.4 = [16 x i8] c"%s\09%d\09%d\09%s\09%s\0A\00"
@.str.5 = [29 x i8] c"%s\09%d\09%d\09MACS_peak_order_%d\09\00"
@.str.6 = [2 x i8] c"1\00"
@.str.7 = [2 x i8] c"0\00"
@.str.8 = [2 x i8] c"\0A\00"
define void @ptoo(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.peak
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca [50 x i8]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i8
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%18 = load i8*, i8** %7
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %13
%20 = load i8*, i8** %8
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %14
%22 = load i8*, i8** %5
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %23, i32** %10
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %29
25: ; preds = %4
%26 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 (...) @getchar()
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %4
%30 = load i8*, i8** %6
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %31, i32** %11
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%35 = call i32 (...) @getchar()
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %29
store i32 1, i32* %15
%38 = load i32*, i32** %10
%39 = call signext i8 @fgetc(i32* %38)
store i8 %39, i8* %17
%40 = load i32*, i32** %10
%41 = call i32 @rewind(i32* %40)
%42 = load i8, i8* %17
%43 = sext i8 %42 to i32
%44 = load i8, i8* @EOF
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %43, %45
br i1 %46, label %47, label %98
47: ; preds = %37
br label %48
48: ; preds = %94, %47
%49 = load i32*, i32** %10
%50 = call i32 @feof(i32* %49)
%51 = icmp ne i32 %50, 0
%52 = xor i1 %51, true
br i1 %52, label %53, label %97
53: ; preds = %48
%54 = load i32*, i32** %10
%55 = getelementptr inbounds %struct.peak, %struct.peak* %9, i32 0, i32 0
%56 = bitcast [50 x i8]* %55 to i8**
%57 = getelementptr inbounds %struct.peak, %struct.peak* %9, i32 0, i32 1
%58 = getelementptr inbounds %struct.peak, %struct.peak* %9, i32 0, i32 2
%59 = bitcast [50 x i8]* %12 to i8**
%60 = bitcast [50 x i8]* %12 to i8**
%61 = call i32 @fscanf(i32* %54, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8** %56, i32* %57, i32* %58, i8** %59, i8** %60)
%62 = load i32*, i32** %11
%63 = getelementptr inbounds %struct.peak, %struct.peak* %9, i32 0, i32 0
%64 = getelementptr inbounds [50 x i8], [50 x i8]* %63, i64 0, i64 0
%65 = getelementptr inbounds %struct.peak, %struct.peak* %9, i32 0, i32 1
%66 = load i32, i32* %65
%67 = getelementptr inbounds %struct.peak, %struct.peak* %9, i32 0, i32 2
%68 = load i32, i32* %67
%69 = load i32, i32* %15
%70 = call i32 (i32*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %64, i32 %66, i32 %68, i32 %69)
%71 = load i32, i32* %15
%72 = add nsw i32 %71, 1
store i32 %72, i32* %15
store i32 0, i32* %16
br label %73
73: ; preds = %91, %53
%74 = load i32, i32* %16
%75 = load i32, i32* %13
%76 = load i32, i32* %13
%77 = mul nsw i32 %75, %76
%78 = sub nsw i32 %77, 1
%79 = icmp sle i32 %74, %78
br i1 %79, label %80, label %94
80: ; preds = %73
%81 = load i32, i32* %16
%82 = load i32, i32* %14
%83 = icmp eq i32 %81, %82
br i1 %83, label %84, label %87
84: ; preds = %80
%85 = load i32*, i32** %11
%86 = call i32 (i32*, i8*, ...) @fprintf(i32* %85, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %90
87: ; preds = %80
%88 = load i32*, i32** %11
%89 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %90
90: ; preds = %87, %84
br label %91
91: ; preds = %90
%92 = load i32, i32* %16
%93 = add nsw i32 %92, 1
store i32 %93, i32* %16
br label %73
94: ; preds = %73
%95 = load i32*, i32** %11
%96 = call i32 (i32*, i8*, ...) @fprintf(i32* %95, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %48
97: ; preds = %48
br label %98
98: ; preds = %97, %37
ret void
}

LLVM IR (-O2):
%struct.peak = type { [50 x i8], i32, i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [62 x i8] c"\0Aerror occurred when opening the input file to combine peaks!\00"
@.str.2 = [3 x i8] c"wb\00"
@EOF = global i8 0
@.str.4 = [16 x i8] c"%s\09%d\09%d\09%s\09%s\0A\00"
@.str.5 = [29 x i8] c"%s\09%d\09%d\09MACS_peak_order_%d\09\00"
@str = [26 x i8] c"\0Acreate output file error\00"
define void @ptoo(i8* nocapture %0, i8* nocapture %1, i8* nocapture %2, i8* nocapture %3) {
%5 = alloca %struct.peak
%6 = alloca [50 x i8]
%7 = getelementptr inbounds %struct.peak, %struct.peak* %5, i64 0, i32 0, i64 0
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%9 = tail call i32 @atoi(i8* %2)
%10 = tail call i32 @atoi(i8* %3)
%11 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %4
%14 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 (...) @getchar()
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %4
%18 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%22 = tail call i32 (...) @getchar()
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %17
%25 = tail call signext i8 @fgetc(i32* %11)
%26 = tail call i32 @rewind(i32* %11)
%27 = load i8, i8* @EOF
%28 = icmp eq i8 %25, %27
br i1 %28, label %57, label %29
29: ; preds = %24
%30 = call i32 @feof(i32* %11)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %57
32: ; preds = %29
%33 = bitcast %struct.peak* %5 to i8**
%34 = getelementptr inbounds %struct.peak, %struct.peak* %5, i64 0, i32 1
%35 = getelementptr inbounds %struct.peak, %struct.peak* %5, i64 0, i32 2
%36 = bitcast [50 x i8]* %6 to i8**
%37 = mul i32 %9, %9
%38 = icmp eq i32 %37, 0
br label %39
39: ; preds = %32, %53
%40 = phi i32 [ 1, %32 ], [ %45, %53 ]
%41 = call i32 @fscanf(i32* %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8** %33, i32* %34, i32* %35, i8** %36, i8** %36)
%42 = load i32, i32* %34
%43 = load i32, i32* %35
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %7, i32 %42, i32 %43, i32 %40)
%45 = add nuw nsw i32 %40, 1
br i1 %38, label %53, label %46
46: ; preds = %39, %46
%47 = phi i32 [ %51, %46 ], [ 0, %39 ]
%48 = icmp eq i32 %47, %10
%49 = select i1 %48, i32 49, i32 48
%50 = call i32 @fputc(i32 %49, i32* %18)
%51 = add nuw i32 %47, 1
%52 = icmp eq i32 %51, %37
br i1 %52, label %53, label %46
53: ; preds = %46, %39
%54 = call i32 @fputc(i32 10, i32* %18)
%55 = call i32 @feof(i32* %11)
%56 = icmp eq i32 %55, 0
br i1 %56, label %39, label %57
57: ; preds = %53, %29, %24
ret void
}