#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 */
int strlen(char const *);
int nDNARates(const char *code) {
  int max = 0;
  for (int i = 0; i < strlen(code); i++) {
    if (code[i] >= 48) {
      max = code[i] - 48;
    }
  }
  return max + 1;
}


x86 assembly (clang, -O0):
<nDNARates>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    1180 <nDNARates+0x70>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     116d <nDNARates+0x5d>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0xc(%rbp)
jmp    1172 <nDNARates+0x62>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112a <nDNARates+0x1a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nDNARates>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %eax,%eax
jle    1156 <nDNARates+0x46>
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r14,%rbx,1),%eax
lea    -0x30(%rax),%ecx
cmp    $0x30,%eax
cmovge %ecx,%ebp
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1130 <nDNARates+0x20>
add    $0x1,%ebp
jmp    115b <nDNARates+0x4b>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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