#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 strlen(char *);
int isANumber(char *num) {
  int i = 0;
  int check = 0;
  for (i = 0; i < strlen(num); ++i) {
    if (isdigit(num[i])) {
      continue;
    } else if (num[i] == '.' && check == 0) {
      check = 1;
    } else {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<isANumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11cc <isANumber+0xac>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     117d <isANumber+0x5d>
jmp    11be <isANumber+0x9e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    11a8 <isANumber+0x88>
cmpl   $0x0,-0x18(%rbp)
jne    11a8 <isANumber+0x88>
movl   $0x1,-0x18(%rbp)
jmp    11b4 <isANumber+0x94>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <isANumber+0xb3>
jmp    11b9 <isANumber+0x99>
jmp    11be <isANumber+0x9e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <isANumber+0x21>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isANumber>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1040 <strlen@plt>
test   %eax,%eax
jle    1176 <isANumber+0x56>
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    1153 <isANumber+0x33>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1176 <isANumber+0x56>
movsbl (%r14,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1140 <isANumber+0x20>
xor    %eax,%eax
cmpb   $0x2e,(%r14,%rbx,1)
jne    117b <isANumber+0x5b>
test   %ebp,%ebp
mov    $0x1,%ebp
je     1140 <isANumber+0x20>
jmp    117b <isANumber+0x5b>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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