#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 */
int /*<<< orphan*/ isdigit(char const);
int blkid_parse_version_string(const char *ver_string) {
  const char *cp;
  int version = 0;
  for (cp = ver_string; *cp; cp++) {
    if (*cp == '.')
      continue;
    if (!isdigit(*cp))
      break;
    version = (version * 10) + (*cp - '0');
  }
  return version;
}


x86 assembly (clang, -O0):
<blkid_parse_version_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     118b <blkid_parse_version_string+0x7b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    114d <blkid_parse_version_string+0x3d>
jmp    117a <blkid_parse_version_string+0x6a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1167 <blkid_parse_version_string+0x57>
jmp    118b <blkid_parse_version_string+0x7b>
imul   $0xa,-0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
movsbl (%rcx),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112b <blkid_parse_version_string+0x1b>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blkid_parse_version_string>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %r14d,%r14d
jmp    1133 <blkid_parse_version_string+0x23>
nopl   0x0(%rax)
lea    (%r14,%r14,4),%eax
movsbl (%rbx),%ecx
lea    (%rcx,%rax,2),%r14d
add    $0xffffffd0,%r14d
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x2e,%al
je     112f <blkid_parse_version_string+0x1f>
test   %al,%al
je     114a <blkid_parse_version_string+0x3a>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    1120 <blkid_parse_version_string+0x10>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @blkid_parse_version_string(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
%5 = load i8*, i8** %2
store i8* %5, i8** %3
br label %6
6: ; preds = %30, %1
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %33
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 %16
15: ; preds = %10
br label %30
16: ; preds = %10
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = call i32 @isdigit(i8 signext %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %16
br label %33
22: ; preds = %16
%23 = load i32, i32* %4
%24 = mul nsw i32 %23, 10
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = sub nsw i32 %27, 48
%29 = add nsw i32 %24, %28
store i32 %29, i32* %4
br label %30
30: ; preds = %22, %15
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %3
br label %6
33: ; preds = %21, %6
%34 = load i32, i32* %4
ret i32 %34
}

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