#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 form_field_validate_number(const char *str, int *pos, void *arg) {
  const char *s;
  for (s = str; *s; *s++)
    if (!isdigit(*s) && *s != '-') {
      *pos = s - str;
      return -1;
    }
  return 0;
}


x86 assembly (clang, -O0):
<form_field_validate_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     1193 <form_field_validate_number+0x83>
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    117d <form_field_validate_number+0x6d>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     117d <form_field_validate_number+0x6d>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    119a <form_field_validate_number+0x8a>
jmp    1182 <form_field_validate_number+0x72>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    112c <form_field_validate_number+0x1c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<form_field_validate_number>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     115b <form_field_validate_number+0x4b>
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
jmp    113e <form_field_validate_number+0x2e>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x1(%r15,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
je     115b <form_field_validate_number+0x4b>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    1130 <form_field_validate_number+0x20>
cmpb   $0x2d,(%r15,%rbx,1)
je     1130 <form_field_validate_number+0x20>
mov    %ebx,(%r14)
mov    $0xffffffff,%eax
jmp    115d <form_field_validate_number+0x4d>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @form_field_validate_number(i8* %0, i32* nocapture writeonly %1, i8* nocapture readnone %2) {
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %23, label %6
6: ; preds = %3, %19
%7 = phi i8 [ %21, %19 ], [ %4, %3 ]
%8 = phi i8* [ %20, %19 ], [ %0, %3 ]
%9 = tail call i32 @isdigit(i8 signext %7)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %6
%12 = load i8, i8* %8
%13 = icmp eq i8 %12, 45
br i1 %13, label %19, label %14
14: ; preds = %11
%15 = ptrtoint i8* %8 to i64
%16 = ptrtoint i8* %0 to i64
%17 = sub i64 %15, %16
%18 = trunc i64 %17 to i32
store i32 %18, i32* %1
br label %23
19: ; preds = %6, %11
%20 = getelementptr inbounds i8, i8* %8, i64 1
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %6
23: ; preds = %19, %3, %14
%24 = phi i32 [ -1, %14 ], [ 0, %3 ], [ 0, %19 ]
ret i32 %24
}