#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 isdecint(char *s) {
  int badch = 0;
  char *c = s;
  if (!(isdigit(*c) || *c == '+' || *c == '-'))
    badch = 1;
  else
    for (c++; *c; c++)
      if (!isdigit(*c))
        badch = 1;
  return (!badch);
}


x86 assembly (clang, -O0):
<isdecint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    116d <isdecint+0x5d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
je     116d <isdecint+0x5d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     116d <isdecint+0x5d>
movl   $0x1,-0xc(%rbp)
jmp    11be <isdecint+0xae>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11b9 <isdecint+0xa9>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    11a3 <isdecint+0x93>
movl   $0x1,-0xc(%rbp)
jmp    11a8 <isdecint+0x98>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1179 <isdecint+0x69>
jmp    11be <isdecint+0xae>
cmpl   $0x0,-0xc(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isdecint>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1163 <isdecint+0x53>
mov    0x1(%rbx),%al
test   %al,%al
je     1173 <isdecint+0x63>
add    $0x2,%rbx
xor    %ebp,%ebp
mov    $0x1,%r14d
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
cmove  %r14d,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <isdecint+0x30>
xor    %eax,%eax
test   %ebp,%ebp
sete   %al
jmp    1178 <isdecint+0x68>
mov    (%rbx),%cl
cmp    $0x2d,%cl
je     1124 <isdecint+0x14>
xor    %eax,%eax
cmp    $0x2b,%cl
je     1124 <isdecint+0x14>
jmp    1178 <isdecint+0x68>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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