#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*/ fprintf(int /*<<< orphan*/, char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
void print_bit(int bit, int count) {
  fprintf(stderr, "Printing bit %d. Count = %d.\n", bit, count);
  if (bit == 1)
    printf("0 ");
  else
    printf("00 ");
  for (int i = 0; i < count; i++) {
    printf("0");
  }
}


x86 assembly (clang, -O0):
<print_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0x2eab(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xebc(%rip),%rsi
call   1040 <fprintf@plt>
cmpl   $0x1,-0x4(%rbp)
jne    1164 <print_bit+0x44>
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
jmp    1170 <print_bit+0x50>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    119d <print_bit+0x7d>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1177 <print_bit+0x57>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bit>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    0xeb9(%rip),%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1050 <fprintf@plt>
cmp    $0x1,%ebp
lea    0xec5(%rip),%rax
lea    0xebd(%rip),%rdi
cmove  %rax,%rdi
call   1040 <printf@plt>
test   %ebx,%ebx
jle    117f <print_bit+0x4f>
xchg   %ax,%ax
mov    $0x30,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1170 <print_bit+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Printing bit %d. Count = %d.\0A\00"
@.str.1 = [3 x i8] c"0 \00"
@.str.2 = [4 x i8] c"00 \00"
@.str.3 = [2 x i8] c"0\00"
define void @print_bit(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* @stderr
%7 = load i32, i32* %3
%8 = load i32, i32* %4
%9 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8)
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %16
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
store i32 0, i32* %5
br label %17
17: ; preds = %23, %16
%18 = load i32, i32* %5
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %17
26: ; preds = %17
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Printing bit %d. Count = %d.\0A\00"
@.str.1 = [3 x i8] c"0 \00"
@.str.2 = [4 x i8] c"00 \00"
define void @print_bit(i32 %0, i32 %1) {
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%5 = icmp eq i32 %0, 1
%6 = select i1 %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%7 = tail call i32 @printf(i8* dereferenceable(1) %6)
%8 = icmp sgt i32 %1, 0
br i1 %8, label %10, label %9
9: ; preds = %10, %2
ret void
10: ; preds = %2, %10
%11 = phi i32 [ %13, %10 ], [ 0, %2 ]
%12 = tail call i32 @putchar(i32 48)
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, %1
br i1 %14, label %9, label %10
}