#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, double);
char fscanf(int /*<<< orphan*/ *, char *, int *, double *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  int new_line_counter;
  FILE *input_ptr, *output_ptr;
  char c;
  int loop_number;
  double value;
  if (argc != 3) {
    printf("Usage %s: <input file name> <output file name>\n", argv[0]);
    return 1;
  }
  input_ptr = fopen(argv[1], "r");
  if (!input_ptr) {
    printf("ERROR: could not open %s for reading\n", argv[1]);
    return 2;
  }
  output_ptr = fopen(argv[2], "w");
  if (!output_ptr) {
    printf("ERROR: could not open %s for writing\n", argv[2]);
    return 3;
  }
  new_line_counter = 0;
  while ((c = fgetc(input_ptr)) != EOF && new_line_counter < 2) {
    if (c == '\n') {
      new_line_counter++;
    }
  }
  while (fscanf(input_ptr, "%d | %lf", &loop_number, &value) != EOF) {
    fprintf(output_ptr, "%d, %lf\n", loop_number, value);
  }
  fclose(output_ptr);
  fclose(input_ptr);
  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   $0x3,-0x8(%rbp)
je     119f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ef <main+0x18f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe82(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e2 <main+0x82>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    12ef <main+0x18f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe67(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1225 <main+0xc5>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe46(%rip),%rdi
call   1040 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    12ef <main+0x18f>
movl   $0x0,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x29(%rbp)
movsbl %al,%ecx
mov    0x2da6(%rip),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x39(%rbp)
je     125c <main+0xfc>
cmpl   $0x2,-0x14(%rbp)
setl   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    126c <main+0x10c>
jmp    1287 <main+0x127>
movsbl -0x29(%rbp),%eax
cmp    $0xa,%eax
jne    1282 <main+0x122>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    122c <main+0xcc>
jmp    128c <main+0x12c>
mov    -0x20(%rbp),%rdi
lea    0xde9(%rip),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   1050 <fscanf@plt>
movsbl %al,%eax
mov    0x2d3a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12d6 <main+0x176>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%edx
movsd  -0x38(%rbp),%xmm0
lea    0xdbd(%rip),%rsi
call   1070 <fprintf@plt>
jmp    128c <main+0x12c>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
cmp    $0x3,%edi
jne    1263 <main+0x103>
mov    0x8(%r15),%rdi
lea    0xeab(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1279 <main+0x119>
mov    %rax,%r12
mov    0x10(%r15),%rdi
lea    0xeb7(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1290 <main+0x130>
mov    %rax,%r14
mov    %r12,%rdi
call   1060 <fgetc@plt>
mov    0x2e27(%rip),%r15
cmp    (%r15),%al
je     11ef <main+0x8f>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
xor    %ebx,%ebx
cmp    $0xa,%al
sete   %r13b
mov    %r12,%rdi
call   1060 <fgetc@plt>
cmp    (%r15),%al
je     11ef <main+0x8f>
mov    %r13b,%bl
add    %ebx,%ebp
cmp    $0x2,%ebp
jb     11d0 <main+0x70>
lea    0xe8a(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %r12,%rdi
call   1050 <fscanf@plt>
cmp    (%r15),%al
je     124f <main+0xef>
lea    0xe6c(%rip),%rbx
lea    0xc(%rsp),%r13
lea    0x10(%rsp),%rbp
xchg   %ax,%ax
mov    0xc(%rsp),%edx
movsd  0x10(%rsp),%xmm0
mov    %r14,%rdi
lea    0xe55(%rip),%rsi
call   1070 <fprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
call   1050 <fscanf@plt>
cmp    (%r15),%al
jne    1220 <main+0xc0>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    12a5 <main+0x145>
mov    (%r15),%rsi
lea    0xd93(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
jmp    12a5 <main+0x145>
mov    0x8(%r15),%rsi
lea    0xdae(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%eax
jmp    12a5 <main+0x145>
mov    0x10(%r15),%rsi
lea    0xdbf(%rip),%rdi
call   1040 <printf@plt>
mov    $0x3,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"Usage %s: <input file name> <output file name>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [38 x i8] c"ERROR: could not open %s for reading\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [38 x i8] c"ERROR: could not open %s for writing\0A\00"
@EOF = global i8 0
@.str.5 = [9 x i8] c"%d | %lf\00"
@.str.6 = [9 x i8] c"%d, %lf\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 i8
%10 = alloca i32
%11 = alloca double
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, 3
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %17)
store i32 1, i32* %3
br label %82
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %7
%24 = load i32*, i32** %7
%25 = icmp ne i32* %24, null
br i1 %25, label %31, label %26
26: ; preds = %19
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %29)
store i32 2, i32* %3
br label %82
31: ; preds = %19
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %35, i32** %8
%36 = load i32*, i32** %8
%37 = icmp ne i32* %36, null
br i1 %37, label %43, label %38
38: ; preds = %31
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 2
%41 = load i8*, i8** %40
%42 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i8* %41)
store i32 3, i32* %3
br label %82
43: ; preds = %31
store i32 0, i32* %6
br label %44
44: ; preds = %63, %43
%45 = load i32*, i32** %7
%46 = call signext i8 @fgetc(i32* %45)
store i8 %46, i8* %9
%47 = sext i8 %46 to i32
%48 = load i8, i8* @EOF
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %47, %49
br i1 %50, label %51, label %54
51: ; preds = %44
%52 = load i32, i32* %6
%53 = icmp slt i32 %52, 2
br label %54
54: ; preds = %51, %44
%55 = phi i1 [ false, %44 ], [ %53, %51 ]
br i1 %55, label %56, label %64
56: ; preds = %54
%57 = load i8, i8* %9
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 10
br i1 %59, label %60, label %63
60: ; preds = %56
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 1
store i32 %62, i32* %6
br label %63
63: ; preds = %60, %56
br label %44
64: ; preds = %54
br label %65
65: ; preds = %72, %64
%66 = load i32*, i32** %7
%67 = call signext i8 @fscanf(i32* %66, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32* %10, double* %11)
%68 = sext i8 %67 to i32
%69 = load i8, i8* @EOF
%70 = sext i8 %69 to i32
%71 = icmp ne i32 %68, %70
br i1 %71, label %72, label %77
72: ; preds = %65
%73 = load i32*, i32** %8
%74 = load i32, i32* %10
%75 = load double, double* %11
%76 = call i32 @fprintf(i32* %73, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %74, double %75)
br label %65
77: ; preds = %65
%78 = load i32*, i32** %8
%79 = call i32 @fclose(i32* %78)
%80 = load i32*, i32** %7
%81 = call i32 @fclose(i32* %80)
store i32 0, i32* %3
br label %82
82: ; preds = %77, %38, %26, %14
%83 = load i32, i32* %3
ret i32 %83
}

LLVM IR (-O2):
@.str = [48 x i8] c"Usage %s: <input file name> <output file name>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [38 x i8] c"ERROR: could not open %s for reading\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [38 x i8] c"ERROR: could not open %s for writing\0A\00"
@EOF = global i8 0
@.str.5 = [9 x i8] c"%d | %lf\00"
@.str.6 = [9 x i8] c"%d, %lf\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca double
%5 = bitcast i32* %3 to i8*
%6 = bitcast double* %4 to i8*
%7 = icmp eq i32 %0, 3
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %56
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i8*, i8** %12
%18 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %56
19: ; preds = %11
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %28, label %24
24: ; preds = %19
%25 = tail call signext i8 @fgetc(i32* %14)
%26 = load i8, i8* @EOF
%27 = icmp eq i8 %25, %26
br i1 %27, label %31, label %35
28: ; preds = %19
%29 = load i8*, i8** %20
%30 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i8* %29)
br label %56
31: ; preds = %35, %24
%32 = call signext i8 @fscanf(i32* %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32* %3, double* %4)
%33 = load i8, i8* @EOF
%34 = icmp eq i8 %32, %33
br i1 %34, label %53, label %46
35: ; preds = %24, %35
%36 = phi i8 [ %41, %35 ], [ %25, %24 ]
%37 = phi i32 [ %40, %35 ], [ 0, %24 ]
%38 = icmp eq i8 %36, 10
%39 = zext i1 %38 to i32
%40 = add nuw nsw i32 %37, %39
%41 = tail call signext i8 @fgetc(i32* %14)
%42 = load i8, i8* @EOF
%43 = icmp ne i8 %41, %42
%44 = icmp ult i32 %40, 2
%45 = select i1 %43, i1 %44, i1 false
br i1 %45, label %35, label %31
46: ; preds = %31, %46
%47 = load i32, i32* %3
%48 = load double, double* %4
%49 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %47, double %48)
%50 = call signext i8 @fscanf(i32* %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32* %3, double* %4)
%51 = load i8, i8* @EOF
%52 = icmp eq i8 %50, %51
br i1 %52, label %53, label %46
53: ; preds = %46, %31
%54 = call i32 @fclose(i32* %22)
%55 = call i32 @fclose(i32* %14)
br label %56
56: ; preds = %53, %28, %16, %8
%57 = phi i32 [ 1, %8 ], [ 0, %53 ], [ 3, %28 ], [ 2, %16 ]
ret i32 %57
}