#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 */
typedef size_t int32_t;

/* Variables and functions */
int /*<<< orphan*/ isdigit(char);
size_t strlen(char *);
int32_t dwgsim_opt_is_int(char *optarg) {
  int32_t i;
  for (i = 0; i < strlen(optarg); i++) {
    if (!isdigit(optarg[i]))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<dwgsim_opt_is_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jae    1192 <dwgsim_opt_is_int+0x72>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    117c <dwgsim_opt_is_int+0x5c>
movq   $0x0,-0x8(%rbp)
jmp    119a <dwgsim_opt_is_int+0x7a>
jmp    1181 <dwgsim_opt_is_int+0x61>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1134 <dwgsim_opt_is_int+0x14>
movq   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dwgsim_opt_is_int>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1174 <dwgsim_opt_is_int+0x54>
mov    %rdi,%r15
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     116f <dwgsim_opt_is_int+0x4f>
mov    $0x1,%r14d
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
call   1040 <strlen@plt>
cmp    %rax,%rbx
jae    117a <dwgsim_opt_is_int+0x5a>
movsbl (%r15,%rbx,1),%edi
call   1030 <isdigit@plt>
add    $0x1,%rbx
test   %eax,%eax
jne    1150 <dwgsim_opt_is_int+0x30>
xor    %r14d,%r14d
jmp    117a <dwgsim_opt_is_int+0x5a>
mov    $0x1,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @dwgsim_opt_is_int(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
store i64 0, i64* %4
br label %5
5: ; preds = %19, %1
%6 = load i64, i64* %4
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
%9 = icmp ult i64 %6, %8
br i1 %9, label %10, label %22
10: ; preds = %5
%11 = load i8*, i8** %3
%12 = load i64, i64* %4
%13 = getelementptr inbounds i8, i8* %11, i64 %12
%14 = load i8, i8* %13
%15 = call i32 @isdigit(i8 signext %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %10
store i64 0, i64* %2
br label %23
18: ; preds = %10
br label %19
19: ; preds = %18
%20 = load i64, i64* %4
%21 = add i64 %20, 1
store i64 %21, i64* %4
br label %5
22: ; preds = %5
store i64 1, i64* %2
br label %23
23: ; preds = %22, %17
%24 = load i64, i64* %2
ret i64 %24
}

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