#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(unsigned char const);
int valid_exp(const unsigned char *s) {
  return isdigit(*s) || ((s[0] == '+' || s[0] == '-') && isdigit(s[1]));
}


x86 assembly (clang, -O0):
<valid_exp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isdigit@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x9(%rbp)
jne    117c <valid_exp+0x6c>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x2b,%eax
je     115f <valid_exp+0x4f>
mov    -0x8(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2d,%ecx
mov    %al,-0xa(%rbp)
jne    1176 <valid_exp+0x66>
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_exp>:
push   %rbx
mov    %rdi,%rbx
movzbl (%rdi),%edi
call   1030 <isdigit@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     112b <valid_exp+0x1b>
pop    %rbx
ret
mov    (%rbx),%cl
cmp    $0x2d,%cl
je     1139 <valid_exp+0x29>
xor    %eax,%eax
cmp    $0x2b,%cl
jne    1129 <valid_exp+0x19>
movzbl 0x1(%rbx),%edi
call   1030 <isdigit@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
pop    %rbx
ret

LLVM IR (-O0):
define i32 @valid_exp(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i8, i8* %3
%5 = call i64 @isdigit(i8 zeroext %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %27, label %7
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = icmp eq i32 %11, 43
br i1 %12, label %19, label %13
13: ; preds = %7
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = icmp eq i32 %17, 45
br i1 %18, label %19, label %25
19: ; preds = %13, %7
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %21
%23 = call i64 @isdigit(i8 zeroext %22)
%24 = icmp ne i64 %23, 0
br label %25
25: ; preds = %19, %13
%26 = phi i1 [ false, %13 ], [ %24, %19 ]
br label %27
27: ; preds = %25, %1
%28 = phi i1 [ true, %1 ], [ %26, %25 ]
%29 = zext i1 %28 to i32
ret i32 %29
}

LLVM IR (-O2):
define i32 @valid_exp(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i64 @isdigit(i8 zeroext %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %13
5: ; preds = %1
%6 = load i8, i8* %0
switch i8 %6, label %13 [
i8 43, label %7
i8 45, label %7
]
7: ; preds = %5, %5
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = tail call i64 @isdigit(i8 zeroext %9)
%11 = icmp ne i64 %10, 0
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %5, %7, %1
%14 = phi i32 [ 1, %1 ], [ %12, %7 ], [ 0, %5 ]
ret i32 %14
}