#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*/ assert(int /*<<< orphan*/);
size_t str_get_length(char const *);
bool str_ipa_natural(const char *s) {
  assert(s != NULL);
  const size_t length = str_get_length(s);
  if (length == 0)
    return false;
  for (size_t n = 0; n < length; n++) {
    const int value = s[n] - '0';
    if (value < 0 || 9 < value)
      return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<str_ipa_natural>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <str_get_length@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1162 <str_ipa_natural+0x42>
movl   $0x0,-0x4(%rbp)
jmp    11cb <str_ipa_natural+0xab>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11c4 <str_ipa_natural+0xa4>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     11a2 <str_ipa_natural+0x82>
mov    $0x9,%eax
cmp    -0x24(%rbp),%eax
jge    11ae <str_ipa_natural+0x8e>
movl   $0x0,-0x4(%rbp)
jmp    11cb <str_ipa_natural+0xab>
jmp    11b3 <str_ipa_natural+0x93>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    116a <str_ipa_natural+0x4a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_ipa_natural>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1040 <assert@plt>
mov    %r14,%rdi
call   1030 <str_get_length@plt>
xor    %ecx,%ecx
test   %rax,%rax
je     1181 <str_ipa_natural+0x61>
mov    (%r14),%dl
add    $0xc6,%dl
cmp    $0xf6,%dl
jb     1181 <str_ipa_natural+0x61>
mov    $0x1,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rcx,%rdx
cmp    %rcx,%rax
je     1179 <str_ipa_natural+0x59>
movzbl (%r14,%rdx,1),%ebx
add    $0xc6,%bl
lea    0x1(%rdx),%rcx
cmp    $0xf5,%bl
ja     1160 <str_ipa_natural+0x40>
xor    %ecx,%ecx
cmp    %rax,%rdx
setae  %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @str_ipa_natural(i8* %0) {
%2 = icmp ne i8* %0, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i64 @str_get_length(i8* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %23, label %7
7: ; preds = %1
%8 = load i8, i8* %0
%9 = add i8 %8, -58
%10 = icmp ult i8 %9, -10
br i1 %10, label %23, label %11
11: ; preds = %7, %14
%12 = phi i64 [ %19, %14 ], [ 1, %7 ]
%13 = icmp eq i64 %12, %5
br i1 %13, label %20, label %14
14: ; preds = %11
%15 = getelementptr inbounds i8, i8* %0, i64 %12
%16 = load i8, i8* %15
%17 = add i8 %16, -58
%18 = icmp ult i8 %17, -10
%19 = add nuw i64 %12, 1
br i1 %18, label %20, label %11
20: ; preds = %14, %11
%21 = icmp uge i64 %12, %5
%22 = zext i1 %21 to i32
br label %23
23: ; preds = %7, %20, %1
%24 = phi i32 [ 0, %1 ], [ 0, %7 ], [ %22, %20 ]
ret i32 %24
}