int strlen_my(char *s) {
  int i = 0;
  for (i = 0; *s != '\0'; s++) {
    printf("in strlen_my s = %c in char; %d in digital;\n", s, s);
    printf("in strlen_my * s = %c in char; %d in digital;\n\n", *s, *s);
    i++;
  };
  return i;
}


x86 assembly (clang, -O0):
<strlen_my>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1186 <strlen_my+0x76>
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
mov    -0x8(%rbp),%rax
movsbl (%rax),%edx
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112a <strlen_my+0x1a>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strlen_my>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmpb   $0x0,(%rdi)
je     1163 <strlen_my+0x53>
mov    %rdi,%r12
lea    0xed9(%rip),%r14
lea    0xeff(%rip),%r15
xor    %eax,%eax
mov    %rax,%rbx
lea    (%r12,%rax,1),%rdx
mov    %r14,%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movsbl (%r12,%rbx,1),%edx
mov    %r15,%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x1(%rbx),%rax
cmpb   $0x0,0x1(%r12,%rbx,1)
jne    1130 <strlen_my+0x20>
jmp    1165 <strlen_my+0x55>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [45 x i8] c"in strlen_my s = %c in char; %d in digital;\0A\00"
@.str.1 = [48 x i8] c"in strlen_my * s = %c in char; %d in digital;\0A\0A\00"
define i32 @strlen_my(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %3
br label %4
4: ; preds = %22, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %4
%10 = load i8*, i8** %2
%11 = load i8*, i8** %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11)
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = load i8*, i8** %2
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %18)
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %22
22: ; preds = %9
%23 = load i8*, i8** %2
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %2
br label %4
25: ; preds = %4
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@.str = [45 x i8] c"in strlen_my s = %c in char; %d in digital;\0A\00"
@.str.1 = [48 x i8] c"in strlen_my * s = %c in char; %d in digital;\0A\0A\00"
define i32 @strlen_my(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %15, label %4
4: ; preds = %1, %4
%5 = phi i32 [ %11, %4 ], [ 0, %1 ]
%6 = phi i8* [ %12, %4 ], [ %0, %1 ]
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %6)
%8 = load i8, i8* %6
%9 = sext i8 %8 to i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %9)
%11 = add nuw nsw i32 %5, 1
%12 = getelementptr inbounds i8, i8* %6, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %4
15: ; preds = %4, %1
%16 = phi i32 [ 0, %1 ], [ %11, %4 ]
ret i32 %16
}