#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 atoi(char *);
char *index(char *, char);
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ strcpy(char *, char *);
int get_number(char **name) {
  int i;
  char *ppos;
  char number[80] = "";
  if (ppos = index(*name, '.')) {
    *ppos++ = '\0';
    strcpy(number, *name);
    strcpy(*name, ppos);
    for (i = 0; *(number + i); i++)
      if (!isdigit(*(number + i)))
        return (0);
    return (atoi(number));
  }
  return (1);
}


x86 assembly (clang, -O0):
<get_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2e,%esi
call   1060 <index@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     121a <get_number+0xca>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmpb   $0x0,-0x70(%rbp,%rax,1)
je     1209 <get_number+0xb9>
movslq -0x14(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11f6 <get_number+0xa6>
movl   $0x0,-0x4(%rbp)
jmp    1221 <get_number+0xd1>
jmp    11fb <get_number+0xab>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c4 <get_number+0x74>
lea    -0x70(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x4(%rbp)
jmp    1221 <get_number+0xd1>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_number>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    (%rdi),%rdi
mov    $0x2e,%esi
call   1050 <index@plt>
test   %rax,%rax
je     11d1 <get_number+0x91>
mov    %rax,%rbx
add    $0x1,%rbx
movb   $0x0,(%rax)
mov    (%r14),%rsi
mov    %rsp,%rdi
call   1040 <strcpy@plt>
mov    (%r14),%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    (%rsp),%al
test   %al,%al
je     11c7 <get_number+0x87>
lea    0x1(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     11d8 <get_number+0x98>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    11b0 <get_number+0x70>
mov    %rsp,%rdi
call   1060 <atoi@plt>
jmp    11da <get_number+0x9a>
mov    $0x1,%eax
jmp    11da <get_number+0x9a>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @get_number(i8** nocapture %0) {
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%4 = load i8*, i8** %0
%5 = tail call i8* @index(i8* %4, i8 signext 46)
%6 = icmp eq i8* %5, null
br i1 %6, label %27, label %7
7: ; preds = %1
%8 = getelementptr inbounds i8, i8* %5, i64 1
store i8 0, i8* %5
%9 = load i8*, i8** %0
%10 = call i32 @strcpy(i8* %3, i8* %9)
%11 = load i8*, i8** %0
%12 = call i32 @strcpy(i8* %11, i8* %8)
%13 = load i8, i8* %3
%14 = icmp eq i8 %13, 0
br i1 %14, label %25, label %19
15: ; preds = %19
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %24
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %25, label %19
19: ; preds = %7, %15
%20 = phi i64 [ %24, %15 ], [ 0, %7 ]
%21 = phi i8 [ %17, %15 ], [ %13, %7 ]
%22 = call i32 @isdigit(i8 signext %21)
%23 = icmp eq i32 %22, 0
%24 = add nuw i64 %20, 1
br i1 %23, label %27, label %15
25: ; preds = %15, %7
%26 = call i32 @atoi(i8* %3)
br label %27
27: ; preds = %19, %1, %25
%28 = phi i32 [ %26, %25 ], [ 1, %1 ], [ 0, %19 ]
ret i32 %28
}