#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 /*<<< orphan*/ printf(char *);
void recursedigit(int n) {
  int on;
  if (0 == n) {
    return;
  }
  on = 0;
  if (0 != (n - ((n / 2) * 2))) {
    on = 1;
  }
  recursedigit(n / 2);
  if (0 == on) {
    printf("0");
  }
  if (1 == on) {
    printf("1");
  }
}


x86 assembly (clang, -O0):
<recursedigit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
xor    %eax,%eax
cmp    -0x4(%rbp),%eax
jne    113b <recursedigit+0x1b>
jmp    11a9 <recursedigit+0x89>
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
shl    $0x1,%eax
sub    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     1166 <recursedigit+0x46>
movl   $0x1,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <recursedigit@plt>
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jne    118f <recursedigit+0x6f>
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
jne    11a9 <recursedigit+0x89>
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recursedigit>:
test   %edi,%edi
je     114c <recursedigit+0x2c>
push   %rbx
mov    %edi,%ecx
shr    $0x1f,%ecx
add    %edi,%ecx
mov    %ecx,%eax
sar    %eax
and    $0xfffffffe,%ecx
xor    %ebx,%ebx
cmp    %edi,%ecx
sete   %bl
mov    %eax,%edi
call   1040 <recursedigit@plt>
xor    $0x31,%ebx
mov    %ebx,%edi
pop    %rbx
jmp    1030 <putchar@plt>
ret

LLVM IR (-O0):
@.str = [2 x i8] c"0\00"
@.str.1 = [2 x i8] c"1\00"
define void @recursedigit(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 0, %4
br i1 %5, label %6, label %7
6: ; preds = %1
br label %27
7: ; preds = %1
store i32 0, i32* %3
%8 = load i32, i32* %2
%9 = load i32, i32* %2
%10 = sdiv i32 %9, 2
%11 = mul nsw i32 %10, 2
%12 = sub nsw i32 %8, %11
%13 = icmp ne i32 0, %12
br i1 %13, label %14, label %15
14: ; preds = %7
store i32 1, i32* %3
br label %15
15: ; preds = %14, %7
%16 = load i32, i32* %2
%17 = sdiv i32 %16, 2
%18 = load i32, i32* %3
%19 = icmp eq i32 0, %18
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %15
%23 = load i32, i32* %3
%24 = icmp eq i32 1, %23
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %6, %25, %22
ret void
}

LLVM IR (-O2):
define void @recursedigit(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %10, label %3
3: ; preds = %1
%4 = sdiv i32 %0, 2
%5 = mul i32 %4, -2
%6 = sub i32 0, %0
%7 = icmp eq i32 %5, %6
tail call void @recursedigit(i32 %4)
%8 = select i1 %7, i32 48, i32 49
%9 = tail call i32 @putchar(i32 %8)
br label %10
10: ; preds = %3, %1
ret void
}