#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 print_char(char);
int print_str(char *);
int print_binary(int i) {
  char char_map[] = "01";
  if (!i) {
    return print_str("0b0");
  }
  return print_binary(i >> 1) + print_char((char)char_map[i & 2]);
}


x86 assembly (clang, -O0):
<print_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    0xebe(%rip),%ax
mov    %ax,-0xb(%rbp)
mov    0xeb6(%rip),%al
mov    %al,-0x9(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    116d <print_binary+0x3d>
lea    0xea3(%rip),%rdi
call   1030 <print_str@plt>
mov    %eax,-0x4(%rbp)
jmp    1197 <print_binary+0x67>
mov    -0x8(%rbp),%edi
sar    $0x1,%edi
call   1040 <print_binary@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
and    $0x2,%eax
cltq
movsbl -0xb(%rbp,%rax,1),%edi
call   1050 <print_char@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_binary>:
test   %edi,%edi
je     115e <print_binary+0x2e>
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
sar    %edi
call   1040 <print_binary@plt>
mov    %eax,%ebp
and    $0x2,%ebx
lea    0xeb4(%rip),%rax
movsbl (%rbx,%rax,1),%edi
call   1050 <print_char@plt>
add    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe9e(%rip),%rdi
jmp    1030 <print_str@plt>

LLVM IR (-O0):
@__const.print_binary.char_map = [3 x i8] c"01\00"
@.str = [4 x i8] c"0b0\00"
define i32 @print_binary(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [3 x i8]
store i32 %0, i32* %3
%5 = bitcast [3 x i8]* %4 to i8*
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i32 @print_str(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %9, i32* %2
br label %21
10: ; preds = %1
%11 = load i32, i32* %3
%12 = ashr i32 %11, 1
%13 = call i32 @print_binary(i32 %12)
%14 = load i32, i32* %3
%15 = and i32 %14, 2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = call i32 @print_char(i8 signext %18)
%20 = add nsw i32 %13, %19
store i32 %20, i32* %2
br label %21
21: ; preds = %10, %8
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@__const.print_binary.char_map = [3 x i8] c"01\00"
@.str = [4 x i8] c"0b0\00"
define i32 @print_binary(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = tail call i32 @print_str(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %3, %7
%6 = phi i32 [ %15, %7 ], [ %4, %3 ]
ret i32 %6
7: ; preds = %1
%8 = ashr i32 %0, 1
%9 = tail call i32 @print_binary(i32 %8)
%10 = and i32 %0, 2
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds [3 x i8], [3 x i8]* @__const.print_binary.char_map, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = tail call i32 @print_char(i8 signext %13)
%15 = add nsw i32 %14, %9
br label %5
}