#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 */

/* Variables and functions */
char *strchr(char const *, char);
float strtof(char const *, char **);
int get_trs_from_line(const char *line) {
  int trs = 0;
  char *next;
  const char *remaining = line;
  const char *pos = strchr(remaining, '.');
  char c;
  while (pos > line) {
    c = *pos;
    if (c == ' ' || c == '\t')
      break;
    --pos;
  }
  remaining = pos;
  float val = strtof(remaining, &next);
  while (val || (remaining != next)) {
    ++trs;
    remaining = next;
    val = strtof(remaining, &next);
  }
  return trs;
}


x86 assembly (clang, -O0):
<get_trs_from_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x8(%rbp),%rax
jbe    1194 <get_trs_from_line+0x74>
mov    -0x28(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x29(%rbp)
movsbl -0x29(%rbp),%eax
cmp    $0x20,%eax
je     117e <get_trs_from_line+0x5e>
movsbl -0x29(%rbp),%eax
cmp    $0x9,%eax
jne    1183 <get_trs_from_line+0x63>
jmp    1194 <get_trs_from_line+0x74>
mov    -0x28(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
jmp    114d <get_trs_from_line+0x2d>
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <strtof@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
mov    $0x1,%al
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
mov    %al,-0x31(%rbp)
jne    11d8 <get_trs_from_line+0xb8>
jp     11d8 <get_trs_from_line+0xb8>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11e8 <get_trs_from_line+0xc8>
jmp    1210 <get_trs_from_line+0xf0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <strtof@plt>
movss  %xmm0,-0x30(%rbp)
jmp    11ae <get_trs_from_line+0x8e>
mov    -0xc(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_trs_from_line>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbp
mov    $0x2e,%esi
call   1030 <strchr@plt>
mov    %rax,%rbx
cmp    %rbp,%rax
jbe    1157 <get_trs_from_line+0x37>
nopl   (%rax)
movzbl (%rbx),%eax
cmp    $0x9,%al
je     1157 <get_trs_from_line+0x37>
cmp    $0x20,%al
je     1157 <get_trs_from_line+0x37>
add    $0xffffffffffffffff,%rbx
cmp    %rbp,%rbx
ja     1140 <get_trs_from_line+0x20>
mov    %rbp,%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <strtof@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
mov    0x8(%rsp),%rax
jne    117a <get_trs_from_line+0x5a>
jp     117a <get_trs_from_line+0x5a>
xor    %ebp,%ebp
cmp    %rax,%rbx
je     11b6 <get_trs_from_line+0x96>
xor    %ebp,%ebp
lea    0x8(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rax,%rbx
add    $0x1,%ebp
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strtof@plt>
ucomiss 0xe58(%rip),%xmm0
mov    0x8(%rsp),%rax
jne    1190 <get_trs_from_line+0x70>
jp     1190 <get_trs_from_line+0x70>
cmp    %rax,%rbx
jne    1190 <get_trs_from_line+0x70>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_trs_from_line(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8
%8 = alloca float
store i8* %0, i8** %2
store i32 0, i32* %3
%9 = load i8*, i8** %2
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = call i8* @strchr(i8* %10, i8 signext 46)
store i8* %11, i8** %6
br label %12
12: ; preds = %27, %1
%13 = load i8*, i8** %6
%14 = load i8*, i8** %2
%15 = icmp ugt i8* %13, %14
br i1 %15, label %16, label %30
16: ; preds = %12
%17 = load i8*, i8** %6
%18 = load i8, i8* %17
store i8 %18, i8* %7
%19 = load i8, i8* %7
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 32
br i1 %21, label %26, label %22
22: ; preds = %16
%23 = load i8, i8* %7
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 9
br i1 %25, label %26, label %27
26: ; preds = %22, %16
br label %30
27: ; preds = %22
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i32 -1
store i8* %29, i8** %6
br label %12
30: ; preds = %26, %12
%31 = load i8*, i8** %6
store i8* %31, i8** %5
%32 = load i8*, i8** %5
%33 = call float @strtof(i8* %32, i8** %4)
store float %33, float* %8
br label %34
34: ; preds = %43, %30
%35 = load float, float* %8
%36 = fcmp une float %35, 0.000000e+00
br i1 %36, label %41, label %37
37: ; preds = %34
%38 = load i8*, i8** %5
%39 = load i8*, i8** %4
%40 = icmp ne i8* %38, %39
br label %41
41: ; preds = %37, %34
%42 = phi i1 [ true, %34 ], [ %40, %37 ]
br i1 %42, label %43, label %49
43: ; preds = %41
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
%46 = load i8*, i8** %4
store i8* %46, i8** %5
%47 = load i8*, i8** %5
%48 = call float @strtof(i8* %47, i8** %4)
store float %48, float* %8
br label %34
49: ; preds = %41
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
define i32 @get_trs_from_line(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 46)
%5 = icmp ugt i8* %4, %0
br i1 %5, label %6, label %17
6: ; preds = %1
%7 = ptrtoint i8* %4 to i64
%8 = ptrtoint i8* %0 to i64
%9 = sub i64 %8, %7
%10 = getelementptr i8, i8* %4, i64 %9
br label %11
11: ; preds = %6, %14
%12 = phi i8* [ %15, %14 ], [ %4, %6 ]
%13 = load i8, i8* %12
switch i8 %13, label %14 [
i8 32, label %17
i8 9, label %17
]
14: ; preds = %11
%15 = getelementptr inbounds i8, i8* %12, i64 -1
%16 = icmp ugt i8* %15, %0
br i1 %16, label %11, label %17
17: ; preds = %14, %11, %11, %1
%18 = phi i8* [ %4, %1 ], [ %12, %11 ], [ %12, %11 ], [ %10, %14 ]
%19 = call float @strtof(i8* %18, i8** %2)
%20 = fcmp une float %19, 0.000000e+00
%21 = load i8*, i8** %2
%22 = icmp ne i8* %18, %21
%23 = select i1 %20, i1 true, i1 %22
br i1 %23, label %24, label %33
24: ; preds = %17, %24
%25 = phi i8* [ %30, %24 ], [ %21, %17 ]
%26 = phi i32 [ %27, %24 ], [ 0, %17 ]
%27 = add nuw nsw i32 %26, 1
%28 = call float @strtof(i8* %25, i8** %2)
%29 = fcmp une float %28, 0.000000e+00
%30 = load i8*, i8** %2
%31 = icmp ne i8* %25, %30
%32 = select i1 %29, i1 true, i1 %31
br i1 %32, label %24, label %33
33: ; preds = %24, %17
%34 = phi i32 [ 0, %17 ], [ %27, %24 ]
ret i32 %34
}