#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__ isalpha(char);
scalar_t__ isdigit(char);
int strlen(char *);
bool isValidArg(char string[]) {
  bool isValid = false;
  int length = strlen(string);
  for (int index = 0; index < length; index++) {
    if (isalpha(string[index])) {
      isValid = false;
    } else {
      if (isdigit(string[index])) {
        isValid = true;
      }
    }
  }
  return isValid;
}


x86 assembly (clang, -O0):
<isValidArg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11c3 <isValidArg+0x93>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%rax
je     1189 <isValidArg+0x59>
movl   $0x0,-0xc(%rbp)
jmp    11b0 <isValidArg+0x80>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11ab <isValidArg+0x7b>
movl   $0x1,-0xc(%rbp)
jmp    11b0 <isValidArg+0x80>
jmp    11b5 <isValidArg+0x85>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <isValidArg+0x26>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isValidArg>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
call   1040 <strlen@plt>
test   %eax,%eax
jle    1197 <isValidArg+0x67>
mov    %eax,%r14d
xor    %ebx,%ebx
mov    $0x1,%r12d
xor    %ebp,%ebp
jmp    116b <isValidArg+0x3b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
mov    %eax,%ebp
cmp    %rbx,%r14
je     1199 <isValidArg+0x69>
movsbl (%r15,%rbx,1),%edi
call   1050 <isalpha@plt>
mov    %rax,%rcx
mov    $0x0,%eax
test   %rcx,%rcx
jne    1160 <isValidArg+0x30>
movsbl (%r15,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
cmovne %r12d,%ebp
mov    %ebp,%eax
jmp    1160 <isValidArg+0x30>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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