#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 recursive_count_decoding(char *str, size_t n) {
  int count = 0;
  if (n == 0 || n == 1) {
    return 1;
  }
  if (str[n - 1] > '0') {
    count = recursive_count_decoding(str, n - 1);
  }
  if (str[n - 2] == '1' || (str[n - 2] == '2' && str[n - 1] < '7')) {
    count += recursive_count_decoding(str, n - 2);
  }
  return count;
}


x86 assembly (clang, -O0):
<recursive_count_decoding>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     113d <recursive_count_decoding+0x2d>
cmpq   $0x1,-0x18(%rbp)
jne    1149 <recursive_count_decoding+0x39>
movl   $0x1,-0x4(%rbp)
jmp    11de <recursive_count_decoding+0xce>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jle    1176 <recursive_count_decoding+0x66>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
sub    $0x1,%rsi
call   1030 <recursive_count_decoding@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x2,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x31,%eax
je     11c1 <recursive_count_decoding+0xb1>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x2,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x32,%eax
jne    11d8 <recursive_count_decoding+0xc8>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x37,%eax
jge    11d8 <recursive_count_decoding+0xc8>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
sub    $0x2,%rsi
call   1030 <recursive_count_decoding@plt>
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recursive_count_decoding>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%ebp
cmp    $0x2,%rsi
jb     117d <recursive_count_decoding+0x6d>
mov    %rsi,%rbx
mov    %rdi,%r14
add    $0xffffffffffffffff,%rbx
xor    %ebp,%ebp
jmp    1143 <recursive_count_decoding+0x33>
add    %eax,%ebp
lea    -0x2(%rbx),%rax
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
mov    %rax,%rbx
jbe    1176 <recursive_count_decoding+0x66>
movzbl (%r14,%rbx,1),%r15d
mov    $0x0,%eax
cmp    $0x31,%r15b
jl     115e <recursive_count_decoding+0x4e>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <recursive_count_decoding@plt>
movzbl -0x1(%r14,%rbx,1),%ecx
cmp    $0x31,%cl
je     1130 <recursive_count_decoding+0x20>
cmp    $0x32,%cl
jne    117b <recursive_count_decoding+0x6b>
cmp    $0x36,%r15b
jle    1130 <recursive_count_decoding+0x20>
jmp    117b <recursive_count_decoding+0x6b>
mov    $0x1,%eax
add    %eax,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @recursive_count_decoding(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i8* %0, i8** %4
store i64 %1, i64* %5
store i32 0, i32* %6
%7 = load i64, i64* %5
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i64, i64* %5
%11 = icmp eq i64 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %9, %2
store i32 1, i32* %3
br label %59
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = load i64, i64* %5
%16 = sub i64 %15, 1
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp sgt i32 %19, 48
br i1 %20, label %21, label %26
21: ; preds = %13
%22 = load i8*, i8** %4
%23 = load i64, i64* %5
%24 = sub i64 %23, 1
%25 = call i32 @recursive_count_decoding(i8* %22, i64 %24)
store i32 %25, i32* %6
br label %26
26: ; preds = %21, %13
%27 = load i8*, i8** %4
%28 = load i64, i64* %5
%29 = sub i64 %28, 2
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 49
br i1 %33, label %50, label %34
34: ; preds = %26
%35 = load i8*, i8** %4
%36 = load i64, i64* %5
%37 = sub i64 %36, 2
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 50
br i1 %41, label %42, label %57
42: ; preds = %34
%43 = load i8*, i8** %4
%44 = load i64, i64* %5
%45 = sub i64 %44, 1
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp slt i32 %48, 55
br i1 %49, label %50, label %57
50: ; preds = %42, %26
%51 = load i8*, i8** %4
%52 = load i64, i64* %5
%53 = sub i64 %52, 2
%54 = call i32 @recursive_count_decoding(i8* %51, i64 %53)
%55 = load i32, i32* %6
%56 = add nsw i32 %55, %54
store i32 %56, i32* %6
br label %57
57: ; preds = %50, %42, %34
%58 = load i32, i32* %6
store i32 %58, i32* %3
br label %59
59: ; preds = %57, %12
%60 = load i32, i32* %3
ret i32 %60
}

LLVM IR (-O2):
define i32 @recursive_count_decoding(i8* %0, i64 %1) {
%3 = icmp ult i64 %1, 2
br i1 %3, label %27, label %4
4: ; preds = %2, %20
%5 = phi i64 [ %15, %20 ], [ %1, %2 ]
%6 = phi i32 [ %21, %20 ], [ 0, %2 ]
%7 = add i64 %5, -1
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp sgt i8 %9, 48
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = tail call i32 @recursive_count_decoding(i8* %0, i64 %7)
br label %13
13: ; preds = %11, %4
%14 = phi i32 [ %12, %11 ], [ 0, %4 ]
%15 = add i64 %5, -2
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
switch i8 %17, label %23 [
i8 49, label %20
i8 50, label %18
]
18: ; preds = %13
%19 = icmp slt i8 %9, 55
br i1 %19, label %20, label %23
20: ; preds = %13, %18
%21 = add nsw i32 %14, %6
%22 = icmp ult i64 %15, 2
br i1 %22, label %23, label %4
23: ; preds = %18, %13, %20
%24 = phi i32 [ %21, %20 ], [ %6, %13 ], [ %6, %18 ]
%25 = phi i32 [ 1, %20 ], [ %14, %13 ], [ %14, %18 ]
%26 = add nsw i32 %25, %24
br label %27
27: ; preds = %23, %2
%28 = phi i32 [ %26, %23 ], [ 1, %2 ]
ret i32 %28
}