#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 */
typedef int /*<<< orphan*/ int32_t;

/* Variables and functions */
int /*<<< orphan*/ strtol(char *, char **, int);
int /*<<< orphan*/ strtoul(char *, char **, int);
int isanumber(char *name, int32_t *value, int base, int sign) {
  char *err;
  if (sign)
    *value = strtol(name, &err, base);
  else
    *value = strtoul(name, &err, base);
  if (*err != '\0')
    return 0;
  else
    return 1;
}


x86 assembly (clang, -O0):
<isanumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     115d <isanumber+0x3d>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    -0x28(%rbp),%rsi
call   1030 <strtol@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1175 <isanumber+0x55>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    -0x28(%rbp),%rsi
call   1040 <strtoul@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1191 <isanumber+0x71>
movl   $0x0,-0x4(%rbp)
jmp    1198 <isanumber+0x78>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isanumber>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0x8(%rsp),%rsi
test   %ecx,%ecx
je     1138 <isanumber+0x18>
call   1030 <strtol@plt>
jmp    113d <isanumber+0x1d>
call   1040 <strtoul@plt>
mov    %eax,(%rbx)
mov    0x8(%rsp),%rcx
xor    %eax,%eax
cmpb   $0x0,(%rcx)
sete   %al
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @isanumber(i8* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%11 = load i32, i32* %9
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %4
%14 = load i8*, i8** %6
%15 = load i32, i32* %8
%16 = call i32 @strtol(i8* %14, i8** %10, i32 %15)
%17 = load i32*, i32** %7
store i32 %16, i32* %17
br label %23
18: ; preds = %4
%19 = load i8*, i8** %6
%20 = load i32, i32* %8
%21 = call i32 @strtoul(i8* %19, i8** %10, i32 %20)
%22 = load i32*, i32** %7
store i32 %21, i32* %22
br label %23
23: ; preds = %18, %13
%24 = load i8*, i8** %10
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 0, i32* %5
br label %30
29: ; preds = %23
store i32 1, i32* %5
br label %30
30: ; preds = %29, %28
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
define i32 @isanumber(i8* %0, i32* nocapture writeonly %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
%7 = icmp eq i32 %3, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = call i32 @strtol(i8* %0, i8** %5, i32 %2)
br label %12
10: ; preds = %4
%11 = call i32 @strtoul(i8* %0, i8** %5, i32 %2)
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ %11, %10 ], [ %9, %8 ]
store i32 %13, i32* %1
%14 = load i8*, i8** %5
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
%17 = zext i1 %16 to i32
ret i32 %17
}