#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*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ sscanf(char *, char *, float *, float *, float *);
void getlens(FILE *fp, char *s, float *len, float *g0, float *g1, float *dg,
             int *n) {
  int i = 0;
  fgets(s, 512, fp);
  sscanf(s, "%f %f %f", &g0[0], &g1[0], &dg[0]);
  g0[0] = 0.0;
  while (g1[i] < (*len)) {
    i++;
    fgets(s, 512, fp);
    sscanf(s, "%f %f %f", &g0[i], &g1[i], &dg[i]);
  }
  *n = i + 1;
  g1[i] = (*len);
}


x86 assembly (clang, -O0):
<getlens>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x200,%esi
call   1030 <fgets@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
lea    0xe8c(%rip),%rsi
call   1040 <sscanf@plt>
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
ucomiss %xmm1,%xmm0
jbe    11ff <getlens+0xdf>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x200,%esi
call   1030 <fgets@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
movslq -0x34(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x28(%rbp),%rcx
movslq -0x34(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rcx
mov    -0x30(%rbp),%r8
movslq -0x34(%rbp),%rax
shl    $0x2,%rax
add    %rax,%r8
lea    0xe0b(%rip),%rsi
call   1040 <sscanf@plt>
jmp    1184 <getlens+0x64>
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getlens>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r15
mov    %r8,%r14
mov    %rcx,%rbx
mov    %rdx,%rbp
mov    %rsi,%r13
mov    %rdi,%rdx
mov    %rsi,%rdi
mov    $0x200,%esi
mov    %rdx,0x10(%rsp)
call   1030 <fgets@plt>
lea    0xea7(%rip),%rsi
mov    %r13,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    %r15,%r8
call   1040 <sscanf@plt>
movl   $0x0,(%rbx)
movss  0x0(%rbp),%xmm0
xor    %r12d,%r12d
mov    %r14,0x8(%rsp)
ucomiss (%r14),%xmm0
jbe    11e5 <getlens+0xc5>
add    $0x4,%r15
mov    0x8(%rsp),%rax
lea    0x4(%rax),%r14
add    $0x4,%rbx
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0x200,%esi
mov    0x10(%rsp),%rdx
call   1030 <fgets@plt>
mov    %r13,%rdi
lea    0xe44(%rip),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    %r15,%r8
call   1040 <sscanf@plt>
movss  0x0(%rbp),%xmm0
add    $0x1,%r12d
add    $0x4,%r15
add    $0x4,%rbx
ucomiss (%r14),%xmm0
lea    0x4(%r14),%r14
ja     11a0 <getlens+0x80>
mov    %r12d,%eax
add    $0x1,%r12d
mov    0x50(%rsp),%rcx
mov    %r12d,(%rcx)
mov    0x8(%rsp),%rcx
movss  %xmm0,(%rcx,%rax,4)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%f %f %f\00"
define void @getlens(i32* %0, i8* %1, float* %2, float* %3, float* %4, float* %5, i32* %6) {
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca float*
%11 = alloca float*
%12 = alloca float*
%13 = alloca float*
%14 = alloca i32*
%15 = alloca i32
store i32* %0, i32** %8
store i8* %1, i8** %9
store float* %2, float** %10
store float* %3, float** %11
store float* %4, float** %12
store float* %5, float** %13
store i32* %6, i32** %14
store i32 0, i32* %15
%16 = load i8*, i8** %9
%17 = load i32*, i32** %8
%18 = call i32 @fgets(i8* %16, i32 512, i32* %17)
%19 = load i8*, i8** %9
%20 = load float*, float** %11
%21 = getelementptr inbounds float, float* %20, i64 0
%22 = load float*, float** %12
%23 = getelementptr inbounds float, float* %22, i64 0
%24 = load float*, float** %13
%25 = getelementptr inbounds float, float* %24, i64 0
%26 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), float* %21, float* %23, float* %25)
%27 = load float*, float** %11
%28 = getelementptr inbounds float, float* %27, i64 0
store float 0.000000e+00, float* %28
br label %29
29: ; preds = %38, %7
%30 = load float*, float** %12
%31 = load i32, i32* %15
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds float, float* %30, i64 %32
%34 = load float, float* %33
%35 = load float*, float** %10
%36 = load float, float* %35
%37 = fcmp olt float %34, %36
br i1 %37, label %38, label %58
38: ; preds = %29
%39 = load i32, i32* %15
%40 = add nsw i32 %39, 1
store i32 %40, i32* %15
%41 = load i8*, i8** %9
%42 = load i32*, i32** %8
%43 = call i32 @fgets(i8* %41, i32 512, i32* %42)
%44 = load i8*, i8** %9
%45 = load float*, float** %11
%46 = load i32, i32* %15
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds float, float* %45, i64 %47
%49 = load float*, float** %12
%50 = load i32, i32* %15
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds float, float* %49, i64 %51
%53 = load float*, float** %13
%54 = load i32, i32* %15
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds float, float* %53, i64 %55
%57 = call i32 @sscanf(i8* %44, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), float* %48, float* %52, float* %56)
br label %29
58: ; preds = %29
%59 = load i32, i32* %15
%60 = add nsw i32 %59, 1
%61 = load i32*, i32** %14
store i32 %60, i32* %61
%62 = load float*, float** %10
%63 = load float, float* %62
%64 = load float*, float** %12
%65 = load i32, i32* %15
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds float, float* %64, i64 %66
store float %63, float* %67
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%f %f %f\00"
define void @getlens(i32* nocapture %0, i8* %1, float* nocapture %2, float* %3, float* %4, float* %5, i32* nocapture writeonly %6) {
%8 = tail call i32 @fgets(i8* %1, i32 512, i32* %0)
%9 = tail call i32 @sscanf(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), float* %3, float* %4, float* %5)
store float 0.000000e+00, float* %3
%10 = load float, float* %4
%11 = load float, float* %2
%12 = fcmp olt float %10, %11
br i1 %12, label %13, label %26
13: ; preds = %7, %13
%14 = phi i64 [ %15, %13 ], [ 0, %7 ]
%15 = add nuw i64 %14, 1
%16 = tail call i32 @fgets(i8* %1, i32 512, i32* %0)
%17 = getelementptr inbounds float, float* %3, i64 %15
%18 = getelementptr inbounds float, float* %4, i64 %15
%19 = getelementptr inbounds float, float* %5, i64 %15
%20 = tail call i32 @sscanf(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), float* %17, float* %18, float* %19)
%21 = load float, float* %18
%22 = load float, float* %2
%23 = fcmp olt float %21, %22
br i1 %23, label %13, label %24
24: ; preds = %13
%25 = trunc i64 %15 to i32
br label %26
26: ; preds = %24, %7
%27 = phi i32 [ 0, %7 ], [ %25, %24 ]
%28 = phi float [ %11, %7 ], [ %22, %24 ]
%29 = zext i32 %27 to i64
%30 = getelementptr inbounds float, float* %4, i64 %29
%31 = add nuw nsw i32 %27, 1
store i32 %31, i32* %6
store float %28, float* %30
ret void
}