#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 _numDecodings(char *);
int helper(char *s) {
  int a = _numDecodings(s + 1);
  int b = _numDecodings(s + 2);
  if (a == -1 && b == -1)
    return -1;
  if (a == -1)
    return b == 0 ? 1 : b;
  if (b == -1)
    return a;
  if (b == 0)
    return a + 1;
  else
    return a + b;
}


x86 assembly (clang, -O0):
<helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1030 <_numDecodings@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
call   1030 <_numDecodings@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    115c <helper+0x4c>
cmpl   $0xffffffff,-0x18(%rbp)
jne    115c <helper+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c4 <helper+0xb4>
cmpl   $0xffffffff,-0x14(%rbp)
jne    118e <helper+0x7e>
cmpl   $0x0,-0x18(%rbp)
jne    117d <helper+0x6d>
mov    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1183 <helper+0x73>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c4 <helper+0xb4>
cmpl   $0xffffffff,-0x18(%rbp)
jne    11a3 <helper+0x93>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c4 <helper+0xb4>
cmpl   $0x0,-0x18(%rbp)
jne    11bb <helper+0xab>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c4 <helper+0xb4>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<helper>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
add    $0x1,%rdi
call   1030 <_numDecodings@plt>
mov    %eax,%ebp
add    $0x2,%rbx
mov    %rbx,%rdi
call   1030 <_numDecodings@plt>
cmp    $0xffffffff,%ebp
jne    113c <helper+0x2c>
mov    $0xffffffff,%ecx
cmp    $0xffffffff,%eax
je     1161 <helper+0x51>
cmp    $0xffffffff,%ebp
je     1150 <helper+0x40>
cmp    $0xffffffff,%eax
je     115f <helper+0x4f>
test   %eax,%eax
je     115c <helper+0x4c>
add    %ebp,%eax
mov    %eax,%ecx
jmp    1161 <helper+0x51>
test   %eax,%eax
mov    $0x1,%ecx
cmovne %eax,%ecx
jmp    1161 <helper+0x51>
add    $0x1,%ebp
mov    %ebp,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @helper(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = call i32 @_numDecodings(i8* %7)
store i32 %8, i32* %4
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 2
%11 = call i32 @_numDecodings(i8* %10)
store i32 %11, i32* %5
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %18
14: ; preds = %1
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 -1, i32* %2
br label %44
18: ; preds = %14, %1
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %29
21: ; preds = %18
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21
br label %27
25: ; preds = %21
%26 = load i32, i32* %5
br label %27
27: ; preds = %25, %24
%28 = phi i32 [ 1, %24 ], [ %26, %25 ]
store i32 %28, i32* %2
br label %44
29: ; preds = %18
%30 = load i32, i32* %5
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = load i32, i32* %4
store i32 %33, i32* %2
br label %44
34: ; preds = %29
%35 = load i32, i32* %5
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %2
br label %44
40: ; preds = %34
%41 = load i32, i32* %4
%42 = load i32, i32* %5
%43 = add nsw i32 %41, %42
store i32 %43, i32* %2
br label %44
44: ; preds = %40, %37, %32, %27, %17
%45 = load i32, i32* %2
ret i32 %45
}

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