#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__ isdigit(char);
int isdigitaddr(char *name) {
  int ndigits = 0;
  int isdot = 1;
  while (*name) {
    if (*name == '.') {
      if (isdot)
        return 0;
      isdot = 1;
    } else if (isdigit(*name)) {
      if (isdot)
        ndigits++;
      isdot = 0;
    } else {
      return 0;
    }
    name++;
  }
  return ndigits;
}


x86 assembly (clang, -O0):
<isdigitaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c0 <isdigitaddr+0xb0>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1169 <isdigitaddr+0x59>
cmpl   $0x0,-0x18(%rbp)
je     115d <isdigitaddr+0x4d>
movl   $0x0,-0x4(%rbp)
jmp    11c6 <isdigitaddr+0xb6>
movl   $0x1,-0x18(%rbp)
jmp    11af <isdigitaddr+0x9f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     119e <isdigitaddr+0x8e>
cmpl   $0x0,-0x18(%rbp)
je     1192 <isdigitaddr+0x82>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    11aa <isdigitaddr+0x9a>
movl   $0x0,-0x4(%rbp)
jmp    11c6 <isdigitaddr+0xb6>
jmp    11af <isdigitaddr+0x9f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112a <isdigitaddr+0x1a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isdigitaddr>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    $0x1,%ebp
xor    %r14d,%r14d
jmp    113f <isdigitaddr+0x2f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x1,%eax
test   %ebp,%ebp
jne    1162 <isdigitaddr+0x52>
add    $0x1,%rbx
mov    %eax,%ebp
movzbl (%rbx),%eax
cmp    $0x2e,%al
je     1130 <isdigitaddr+0x20>
test   %al,%al
je     1165 <isdigitaddr+0x55>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1162 <isdigitaddr+0x52>
cmp    $0x1,%ebp
sbb    $0xffffffff,%r14d
xor    %eax,%eax
jmp    1139 <isdigitaddr+0x29>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @isdigitaddr(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 1, i32* %5
br label %6
6: ; preds = %34, %1
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %37
10: ; preds = %6
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 46
br i1 %14, label %15, label %20
15: ; preds = %10
%16 = load i32, i32* %5
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 0, i32* %2
br label %39
19: ; preds = %15
store i32 1, i32* %5
br label %34
20: ; preds = %10
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = call i64 @isdigit(i8 signext %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %20
%26 = load i32, i32* %5
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %31
31: ; preds = %28, %25
store i32 0, i32* %5
br label %33
32: ; preds = %20
store i32 0, i32* %2
br label %39
33: ; preds = %31
br label %34
34: ; preds = %33, %19
%35 = load i8*, i8** %3
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %3
br label %6
37: ; preds = %6
%38 = load i32, i32* %4
store i32 %38, i32* %2
br label %39
39: ; preds = %37, %32, %18
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
define i32 @isdigitaddr(i8* nocapture %0) {
br label %2
2: ; preds = %16, %1
%3 = phi i8* [ %0, %1 ], [ %19, %16 ]
%4 = phi i32 [ 0, %1 ], [ %17, %16 ]
%5 = phi i32 [ 1, %1 ], [ %18, %16 ]
%6 = load i8, i8* %3
switch i8 %6, label %9 [
i8 0, label %20
i8 46, label %7
]
7: ; preds = %2
%8 = icmp eq i32 %5, 0
br i1 %8, label %16, label %20
9: ; preds = %2
%10 = tail call i64 @isdigit(i8 signext %6)
%11 = icmp eq i64 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %9
%13 = icmp ne i32 %5, 0
%14 = zext i1 %13 to i32
%15 = add nsw i32 %4, %14
br label %16
16: ; preds = %7, %12
%17 = phi i32 [ %15, %12 ], [ %4, %7 ]
%18 = phi i32 [ 0, %12 ], [ 1, %7 ]
%19 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
20: ; preds = %2, %9, %7
%21 = phi i32 [ 0, %7 ], [ 0, %9 ], [ %4, %2 ]
ret i32 %21
}