#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 */
typedef int uint;
typedef int /*<<< orphan*/ n;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void printb(uint n) {
  int i, b, c;
  b = sizeof(n);
  for (i = (b * 8) - 1; i >= 0; i--) {
    c = (1 << i);
    if (n & c)
      printf("1");
    else
      printf("0");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x4,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x3,%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1184 <printb+0x74>
mov    -0x8(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    -0x10(%rbp),%eax
cmp    $0x0,%eax
je     1165 <printb+0x55>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
jmp    1171 <printb+0x61>
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
jmp    1176 <printb+0x66>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    112e <printb+0x1e>
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printb>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0x1f,%ebp
nopw   0x0(%rax,%rax,1)
bt     %ebp,%ebx
mov    $0x31,%edi
adc    $0xffffffff,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jb     1120 <printb+0x10>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
define void @printb(i32 %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 31, %1 ], [ %9, %2 ]
%4 = shl nuw i32 1, %3
%5 = and i32 %4, %0
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, i32 48, i32 49
%8 = tail call i32 @putchar(i32 %7)
%9 = add nsw i32 %3, -1
%10 = icmp eq i32 %3, 0
br i1 %10, label %11, label %2
11: ; preds = %2
%12 = tail call i32 @putchar(i32 10)
ret void
}