#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 */
scalar_t__ notnum(char const *);
char *strchr(char const *, char);
int strlen(char const *);
int numdec(const char *string) {
  char *cdot;
  int lstr;
  if (notnum(string) && !strchr(string, ':')) {
    return (-1);
  } else {
    lstr = strlen(string);
    if ((cdot = strchr(string, '.')) == NULL) {
      return (0);
    } else {
      return (lstr - (cdot - string) - 1);
    }
  }
}


x86 assembly (clang, -O0):
<numdec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <notnum@plt>
cmp    $0x0,%rax
je     1173 <numdec+0x43>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    1173 <numdec+0x43>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c0 <numdec+0x90>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11a7 <numdec+0x77>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <numdec+0x90>
movslq -0x1c(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rdx
sub    %rdx,%rcx
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numdec>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <notnum@plt>
test   %rax,%rax
je     1153 <numdec+0x23>
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     117f <numdec+0x4f>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     117b <numdec+0x4b>
sub    %eax,%ebx
lea    (%r14,%rbx,1),%eax
add    $0xffffffff,%eax
jmp    1184 <numdec+0x54>
xor    %eax,%eax
jmp    1184 <numdec+0x54>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @numdec(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i64 @notnum(i8* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i8* @strchr(i8* %10, i8 signext 58)
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %9
store i32 -1, i32* %2
br label %32
14: ; preds = %9, %1
%15 = load i8*, i8** %3
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %5
%17 = load i8*, i8** %3
%18 = call i8* @strchr(i8* %17, i8 signext 46)
store i8* %18, i8** %4
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 0, i32* %2
br label %32
21: ; preds = %14
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = load i8*, i8** %4
%25 = load i8*, i8** %3
%26 = ptrtoint i8* %24 to i64
%27 = ptrtoint i8* %25 to i64
%28 = sub i64 %26, %27
%29 = sub nsw i64 %23, %28
%30 = sub nsw i64 %29, 1
%31 = trunc i64 %30 to i32
store i32 %31, i32* %2
br label %32
32: ; preds = %21, %20, %13
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
define i32 @numdec(i8* %0) {
%2 = tail call i64 @notnum(i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
%6 = icmp eq i8* %5, null
br i1 %6, label %18, label %7
7: ; preds = %4, %1
%8 = tail call i32 @strlen(i8* %0)
%9 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 46)
%10 = icmp eq i8* %9, null
br i1 %10, label %18, label %11
11: ; preds = %7
%12 = ptrtoint i8* %9 to i64
%13 = ptrtoint i8* %0 to i64
%14 = sub i64 %13, %12
%15 = trunc i64 %14 to i32
%16 = add i32 %8, -1
%17 = add i32 %16, %15
br label %18
18: ; preds = %7, %4, %11
%19 = phi i32 [ %17, %11 ], [ -1, %4 ], [ 0, %7 ]
ret i32 %19
}