#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(char);
int /*<<< orphan*/ printf(char *, short, char);
short strlen(char *);
void is_digit_print(char s[]) {
  short int i = 0;
  for (i = 0; i < (strlen(s)); ++i) {
    if (isdigit(s[i]))
      printf("s [ %d ] = \'%c\' is digit;\n", i, s[i]);
    else
      printf("s [%d ] = \'%c\' is NOT digit;\n", i, s[i]);
  };
}


x86 assembly (clang, -O0):
<is_digit_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movw   $0x0,-0xa(%rbp)
movw   $0x0,-0xa(%rbp)
movswl -0xa(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %ax,%cx
mov    -0x10(%rbp),%eax
movswl %cx,%ecx
cmp    %ecx,%eax
jge    11e0 <is_digit_print+0xb0>
mov    -0x8(%rbp),%rax
movswq -0xa(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11aa <is_digit_print+0x7a>
mov    -0xa(%rbp),%dx
mov    -0x8(%rbp),%rax
movswq -0xa(%rbp),%rcx
lea    0xe67(%rip),%rdi
movswl %dx,%esi
movsbl (%rax,%rcx,1),%edx
call   1050 <printf@plt>
jmp    11ca <is_digit_print+0x9a>
mov    -0xa(%rbp),%dx
mov    -0x8(%rbp),%rax
movswq -0xa(%rbp),%rcx
lea    0xe5d(%rip),%rdi
movswl %dx,%esi
movsbl (%rax,%rcx,1),%edx
call   1050 <printf@plt>
jmp    11cf <is_digit_print+0x9f>
mov    -0xa(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xa(%rbp)
jmp    1148 <is_digit_print+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_digit_print>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
test   %ax,%ax
jle    1196 <is_digit_print+0x66>
xor    %ebx,%ebx
lea    0xecd(%rip),%r15
lea    0xeab(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%r14,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
movsbl (%r14,%rbx,1),%edx
mov    %r12,%rdi
cmove  %r15,%rdi
movswl %bx,%esi
call   1050 <printf@plt>
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
movswq %ax,%rax
cmp    %rax,%rbx
jl     1160 <is_digit_print+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"s [ %d ] = '%c' is digit;\0A\00"
@.str.1 = [30 x i8] c"s [%d ] = '%c' is NOT digit;\0A\00"
define void @is_digit_print(i8* %0) {
%2 = alloca i8*
%3 = alloca i16
store i8* %0, i8** %2
store i16 0, i16* %3
store i16 0, i16* %3
br label %4
4: ; preds = %36, %1
%5 = load i16, i16* %3
%6 = sext i16 %5 to i32
%7 = load i8*, i8** %2
%8 = call signext i16 @strlen(i8* %7)
%9 = sext i16 %8 to i32
%10 = icmp slt i32 %6, %9
br i1 %10, label %11, label %39
11: ; preds = %4
%12 = load i8*, i8** %2
%13 = load i16, i16* %3
%14 = sext i16 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = call i64 @isdigit(i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %27
19: ; preds = %11
%20 = load i16, i16* %3
%21 = load i8*, i8** %2
%22 = load i16, i16* %3
%23 = sext i16 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i16 signext %20, i8 signext %25)
br label %35
27: ; preds = %11
%28 = load i16, i16* %3
%29 = load i8*, i8** %2
%30 = load i16, i16* %3
%31 = sext i16 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i16 signext %28, i8 signext %33)
br label %35
35: ; preds = %27, %19
br label %36
36: ; preds = %35
%37 = load i16, i16* %3
%38 = add i16 %37, 1
store i16 %38, i16* %3
br label %4
39: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"s [ %d ] = '%c' is digit;\0A\00"
@.str.1 = [30 x i8] c"s [%d ] = '%c' is NOT digit;\0A\00"
define void @is_digit_print(i8* %0) {
%2 = tail call signext i16 @strlen(i8* %0)
%3 = icmp sgt i16 %2, 0
br i1 %3, label %4, label %18
4: ; preds = %1, %4
%5 = phi i64 [ %14, %4 ], [ 0, %1 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = tail call i64 @isdigit(i8 signext %7)
%9 = icmp eq i64 %8, 0
%10 = load i8, i8* %6
%11 = trunc i64 %5 to i16
%12 = select i1 %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0)
%13 = tail call i32 @printf(i8* %12, i16 signext %11, i8 signext %10)
%14 = add nuw nsw i64 %5, 1
%15 = tail call signext i16 @strlen(i8* %0)
%16 = sext i16 %15 to i64
%17 = icmp slt i64 %14, %16
br i1 %17, label %4, label %18
18: ; preds = %4, %1
ret void
}