#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__ jam_isdigit(char);
int jam_constant_is_ok(char *string) {
  int ok = 1;
  if ((string[0] == '-') && (jam_isdigit(string[1]))) {
    ++string;
  }
  while (ok && (*string != '\0')) {
    if (!jam_isdigit(*string))
      ok = 0;
    ++string;
  }
  return (ok);
}


x86 assembly (clang, -O0):
<jam_constant_is_ok>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1156 <jam_constant_is_ok+0x46>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <jam_isdigit@plt>
cmp    $0x0,%rax
je     1156 <jam_constant_is_ok+0x46>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    115b <jam_constant_is_ok+0x4b>
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
je     117a <jam_constant_is_ok+0x6a>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    118a <jam_constant_is_ok+0x7a>
jmp    11b8 <jam_constant_is_ok+0xa8>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <jam_isdigit@plt>
cmp    $0x0,%rax
jne    11a7 <jam_constant_is_ok+0x97>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    115b <jam_constant_is_ok+0x4b>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jam_constant_is_ok>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
cmpb   $0x2d,(%rdi)
jne    1130 <jam_constant_is_ok+0x20>
lea    0x1(%rbx),%r14
movsbl 0x1(%rbx),%edi
call   1030 <jam_isdigit@plt>
test   %rax,%rax
cmovne %r14,%rbx
movzbl (%rbx),%eax
test   %al,%al
je     114c <jam_constant_is_ok+0x3c>
movsbl %al,%edi
call   1030 <jam_isdigit@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1130 <jam_constant_is_ok+0x20>
xor    %eax,%eax
jmp    1151 <jam_constant_is_ok+0x41>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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