#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 */
scalar_t__ getbc(int);
int getbc0(int, int);
int getnum_df(unsigned int s) {
  int d = -1, t;
  for (;;) {
    do {
      d = getbc0(1, d);
      t = s & 1;
      s >>= 1;
    } while (t == 0);
    if (s == 0)
      break;
    if (getbc(1))
      break;
  }
  return d;
}


x86 assembly (clang, -O0):
<getnum_df>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
jmp    1137 <getnum_df+0x17>
mov    -0x8(%rbp),%esi
mov    $0x1,%edi
call   1030 <getbc0@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1137 <getnum_df+0x17>
cmpl   $0x0,-0x4(%rbp)
jne    1172 <getnum_df+0x52>
jmp    1190 <getnum_df+0x70>
mov    $0x1,%edi
call   1040 <getbc@plt>
cmp    $0x0,%rax
je     118b <getnum_df+0x6b>
jmp    1190 <getnum_df+0x70>
jmp    1132 <getnum_df+0x12>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getnum_df>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
mov    $0xffffffff,%r14d
nopl   0x0(%rax)
mov    %ebp,%ebx
mov    $0x1,%edi
mov    %r14d,%esi
call   1030 <getbc0@plt>
mov    %eax,%r14d
shr    %ebp
test   $0x1,%bl
je     1130 <getnum_df+0x10>
cmp    $0x2,%ebx
jb     115d <getnum_df+0x3d>
mov    $0x1,%edi
call   1040 <getbc@plt>
test   %rax,%rax
je     1130 <getnum_df+0x10>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getnum_df(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 -1, i32* %3
br label %5
5: ; preds = %24, %1
br label %6
6: ; preds = %13, %5
%7 = load i32, i32* %3
%8 = call i32 @getbc0(i32 1, i32 %7)
store i32 %8, i32* %3
%9 = load i32, i32* %2
%10 = and i32 %9, 1
store i32 %10, i32* %4
%11 = load i32, i32* %2
%12 = lshr i32 %11, 1
store i32 %12, i32* %2
br label %13
13: ; preds = %6
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 0
br i1 %15, label %6, label %16
16: ; preds = %13
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16
br label %25
20: ; preds = %16
%21 = call i64 @getbc(i32 1)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20
br label %25
24: ; preds = %20
br label %5
25: ; preds = %23, %19
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
define i32 @getnum_df(i32 %0) {
br label %2
2: ; preds = %9, %1
%3 = phi i32 [ -1, %1 ], [ %5, %9 ]
%4 = phi i32 [ %0, %1 ], [ %7, %9 ]
%5 = tail call i32 @getbc0(i32 1, i32 %3)
%6 = and i32 %4, 1
%7 = lshr i32 %4, 1
%8 = icmp eq i32 %6, 0
br i1 %8, label %9, label %10
9: ; preds = %2, %12
br label %2
10: ; preds = %2
%11 = icmp ult i32 %4, 2
br i1 %11, label %15, label %12
12: ; preds = %10
%13 = tail call i64 @getbc(i32 1)
%14 = icmp eq i64 %13, 0
br i1 %14, label %9, label %15
15: ; preds = %12, %10
ret i32 %5
}