#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*/ check_digit(char);
bool strisnum(char *str) {
  int cnt = 0;
  if (str[0] == 0)
    return false;
  while (str[cnt])
    if (!check_digit(*str + cnt++))
      return false;
  return true;
}


x86 assembly (clang, -O0):
<strisnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    113f <strisnum+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    1193 <strisnum+0x83>
jmp    1144 <strisnum+0x34>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     118c <strisnum+0x7c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
add    %ecx,%eax
movsbl %al,%edi
call   1030 <check_digit@plt>
cmp    $0x0,%eax
jne    1187 <strisnum+0x77>
movl   $0x0,-0x4(%rbp)
jmp    1193 <strisnum+0x83>
jmp    1144 <strisnum+0x34>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strisnum>:
push   %r15
push   %r14
push   %rbx
cmpb   $0x0,(%rdi)
je     1156 <strisnum+0x46>
mov    %rdi,%r15
xor    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%r15),%eax
add    %ebx,%eax
movsbl %al,%edi
call   1030 <check_digit@plt>
test   %eax,%eax
je     1159 <strisnum+0x49>
cmpb   $0x0,0x1(%r15,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1130 <strisnum+0x20>
mov    $0x1,%r14d
jmp    1159 <strisnum+0x49>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @strisnum(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %16, label %4
4: ; preds = %1, %12
%5 = phi i64 [ %7, %12 ], [ 0, %1 ]
%6 = load i8, i8* %0
%7 = add nuw i64 %5, 1
%8 = trunc i64 %5 to i8
%9 = add i8 %6, %8
%10 = tail call i32 @check_digit(i8 signext %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %4
%13 = getelementptr inbounds i8, i8* %0, i64 %7
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %4
16: ; preds = %12, %4, %1
%17 = phi i32 [ 0, %1 ], [ 1, %12 ], [ 0, %4 ]
ret i32 %17
}