int get_steps_recursive(int s, int is_first_call) {
  static int count = 0;
  if (is_first_call) {
    count = 0;
  }
  if (s < 0) {
    return -1;
  }
  if (s == 0) {
    count++;
  }
  if (s > 1) {
    get_steps_recursive(s - 2, 0);
  }
  get_steps_recursive(s - 1, 0);
  return count;
}


x86 assembly (clang, -O0):
<get_steps_recursive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1132 <get_steps_recursive+0x22>
movl   $0x0,0x2efa(%rip)
cmpl   $0x0,-0x8(%rbp)
jge    1148 <get_steps_recursive+0x38>
movl   $0xffffffff,-0x4(%rbp)
jmp    118e <get_steps_recursive+0x7e>
cmpl   $0x0,-0x8(%rbp)
jne    1161 <get_steps_recursive+0x51>
mov    0x2ed4(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ecb(%rip)
cmpl   $0x1,-0x8(%rbp)
jle    1178 <get_steps_recursive+0x68>
mov    -0x8(%rbp),%edi
sub    $0x2,%edi
xor    %esi,%esi
call   1030 <get_steps_recursive@plt>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
xor    %esi,%esi
call   1030 <get_steps_recursive@plt>
mov    0x2ea1(%rip),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_steps_recursive>:
push   %rbx
mov    %edi,%ebx
test   %esi,%esi
je     1121 <get_steps_recursive+0x11>
movl   $0x0,0x2f0b(%rip)
test   %ebx,%ebx
js     1137 <get_steps_recursive+0x27>
cmp    $0x1,%ebx
je     1148 <get_steps_recursive+0x38>
test   %ebx,%ebx
jne    113e <get_steps_recursive+0x2e>
addl   $0x1,0x2ef7(%rip)
jmp    1148 <get_steps_recursive+0x38>
mov    $0xffffffff,%eax
pop    %rbx
ret
lea    -0x2(%rbx),%edi
xor    %esi,%esi
call   1030 <get_steps_recursive@plt>
add    $0xffffffff,%ebx
mov    %ebx,%edi
xor    %esi,%esi
call   1030 <get_steps_recursive@plt>
mov    0x2ed2(%rip),%eax
pop    %rbx
ret

LLVM IR (-O0):
@get_steps_recursive.count = internal global i32 0
define i32 @get_steps_recursive(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 0, i32* @get_steps_recursive.count
br label %9
9: ; preds = %8, %2
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 -1, i32* %3
br label %31
13: ; preds = %9
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* @get_steps_recursive.count
%18 = add nsw i32 %17, 1
store i32 %18, i32* @get_steps_recursive.count
br label %19
19: ; preds = %16, %13
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 1
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i32, i32* %4
%24 = sub nsw i32 %23, 2
%25 = call i32 @get_steps_recursive(i32 %24, i32 0)
br label %26
26: ; preds = %22, %19
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 1
%29 = call i32 @get_steps_recursive(i32 %28, i32 0)
%30 = load i32, i32* @get_steps_recursive.count
store i32 %30, i32* %3
br label %31
31: ; preds = %26, %12
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@get_steps_recursive.count = internal unnamed_addr global i32 0
define i32 @get_steps_recursive(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %5, label %4
4: ; preds = %2
store i32 0, i32* @get_steps_recursive.count
br label %5
5: ; preds = %4, %2
%6 = icmp slt i32 %0, 0
br i1 %6, label %14, label %7
7: ; preds = %5
switch i32 %0, label %11 [
i32 0, label %8
i32 1, label %16
]
8: ; preds = %7
%9 = load i32, i32* @get_steps_recursive.count
%10 = add nsw i32 %9, 1
store i32 %10, i32* @get_steps_recursive.count
br label %16
11: ; preds = %7
%12 = add nsw i32 %0, -2
%13 = tail call i32 @get_steps_recursive(i32 %12, i32 0)
br label %16
14: ; preds = %5, %16
%15 = phi i32 [ %19, %16 ], [ -1, %5 ]
ret i32 %15
16: ; preds = %7, %8, %11
%17 = add nsw i32 %0, -1
%18 = tail call i32 @get_steps_recursive(i32 %17, i32 0)
%19 = load i32, i32* @get_steps_recursive.count
br label %14
}