#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, int *, double *, double *);
void readtsp(char *filename, double **points) {
  int id, i;
  double x, y;
  char line[80];
  FILE *fr;
  fr = fopen(filename, "rt");
  i = 0;
  while (fgets(line, 80, fr) != NULL) {
    if (line[0] > 57 || line[0] < 48)
      continue;
    sscanf(line, "%d %lf %lf", &id, &x, &y);
    points[i][0] = x;
    points[i][1] = y;
    i++;
  }
  fclose(fr);
}


x86 assembly (clang, -O0):
<readtsp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x88(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rdx
mov    $0x50,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1204 <readtsp+0xc4>
movsbl -0x80(%rbp),%eax
cmp    $0x39,%eax
jg     11aa <readtsp+0x6a>
movsbl -0x80(%rbp),%eax
cmp    $0x30,%eax
jge    11af <readtsp+0x6f>
jmp    1171 <readtsp+0x31>
lea    -0x80(%rbp),%rdi
lea    0xe49(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
call   1050 <sscanf@plt>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1171 <readtsp+0x31>
mov    -0x88(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readtsp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%r14
lea    0xea8(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
xor    %r13d,%r13d
lea    0x20(%rsp),%r15
lea    0x10(%rsp),%rbp
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11d9 <readtsp+0x99>
movzbl 0x20(%rsp),%eax
add    $0xc6,%al
cmp    $0xf6,%al
jb     1180 <readtsp+0x40>
mov    %r15,%rdi
lea    0xe59(%rip),%rsi
lea    0x1c(%rsp),%rdx
mov    %rbp,%rcx
mov    %r12,%r8
call   1050 <sscanf@plt>
movsd  0x10(%rsp),%xmm0
mov    (%r14,%r13,8),%rax
movsd  %xmm0,(%rax)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rax)
add    $0x1,%r13
jmp    1180 <readtsp+0x40>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rt\00"
@.str.1 = [11 x i8] c"%d %lf %lf\00"
define void @readtsp(i8* %0, double** %1) {
%3 = alloca i8*
%4 = alloca double**
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca [80 x i8]
%10 = alloca i32*
store i8* %0, i8** %3
store double** %1, double*** %4
%11 = load i8*, i8** %3
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %10
store i32 0, i32* %6
br label %13
13: ; preds = %29, %28, %2
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%15 = load i32*, i32** %10
%16 = call i32* @fgets(i8* %14, i32 80, i32* %15)
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %48
18: ; preds = %13
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp sgt i32 %21, 57
br i1 %22, label %28, label %23
23: ; preds = %18
%24 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp slt i32 %26, 48
br i1 %27, label %28, label %29
28: ; preds = %23, %18
br label %13
29: ; preds = %23
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%31 = call i32 @sscanf(i8* %30, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32* %5, double* %7, double* %8)
%32 = load double, double* %7
%33 = load double**, double*** %4
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double*, double** %33, i64 %35
%37 = load double*, double** %36
%38 = getelementptr inbounds double, double* %37, i64 0
store double %32, double* %38
%39 = load double, double* %8
%40 = load double**, double*** %4
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double*, double** %40, i64 %42
%44 = load double*, double** %43
%45 = getelementptr inbounds double, double* %44, i64 1
store double %39, double* %45
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
br label %13
48: ; preds = %13
%49 = load i32*, i32** %10
%50 = call i32 @fclose(i32* %49)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rt\00"
@.str.1 = [11 x i8] c"%d %lf %lf\00"
define void @readtsp(i8* nocapture %0, double** nocapture %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca [80 x i8]
%7 = bitcast i32* %3 to i8*
%8 = bitcast double* %4 to i8*
%9 = bitcast double* %5 to i8*
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%11 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %21, %2
%13 = phi i64 [ %28, %21 ], [ 0, %2 ]
br label %14
14: ; preds = %12, %17
%15 = call i32* @fgets(i8* %10, i32 80, i32* %11)
%16 = icmp eq i32* %15, null
br i1 %16, label %29, label %17
17: ; preds = %14
%18 = load i8, i8* %10
%19 = add i8 %18, -58
%20 = icmp ult i8 %19, -10
br i1 %20, label %14, label %21
21: ; preds = %17
%22 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32* %3, double* %4, double* %5)
%23 = load double, double* %4
%24 = getelementptr inbounds double*, double** %1, i64 %13
%25 = load double*, double** %24
store double %23, double* %25
%26 = load double, double* %5
%27 = getelementptr inbounds double, double* %25, i64 1
store double %26, double* %27
%28 = add nuw i64 %13, 1
br label %12
29: ; preds = %14
%30 = call i32 @fclose(i32* %11)
ret void
}