#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);
int strlen(char *);
int is_positive_number(char *str) {
  int i;
  if (str == NULL)
    return 0;
  for (i = 0; i < strlen(str); i++) {
    if (isdigit((unsigned char)str[i]) == 0)
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<is_positive_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <is_positive_number+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11a7 <is_positive_number+0x87>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11a0 <is_positive_number+0x80>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    118d <is_positive_number+0x6d>
movl   $0x0,-0x4(%rbp)
jmp    11a7 <is_positive_number+0x87>
jmp    1192 <is_positive_number+0x72>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114a <is_positive_number+0x2a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_positive_number>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     1163 <is_positive_number+0x43>
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    $0x1,%r14d
test   %eax,%eax
jle    1166 <is_positive_number+0x46>
xor    %ebp,%ebp
nopl   (%rax)
movzbl (%rbx,%rbp,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1163 <is_positive_number+0x43>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1140 <is_positive_number+0x20>
jmp    1166 <is_positive_number+0x46>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @is_positive_number(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %17, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %10, label %17
6: ; preds = %10
%7 = tail call i32 @strlen(i8* %0)
%8 = sext i32 %7 to i64
%9 = icmp slt i64 %16, %8
br i1 %9, label %10, label %17
10: ; preds = %3, %6
%11 = phi i64 [ %16, %6 ], [ 0, %3 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = tail call i64 @isdigit(i8 zeroext %13)
%15 = icmp eq i64 %14, 0
%16 = add nuw nsw i64 %11, 1
br i1 %15, label %17, label %6
17: ; preds = %10, %6, %3, %1
%18 = phi i32 [ 0, %1 ], [ 1, %3 ], [ 0, %10 ], [ 1, %6 ]
ret i32 %18
}