#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 *, int);
void print_binary(int num) {
  int i;
  for (i = 7; i >= 0; i--)
    printf("%d", (((num) >> (i)) & 1));
}


x86 assembly (clang, -O0):
<print_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x7,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1151 <print_binary+0x41>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%ecx
sar    %cl,%esi
and    $0x1,%esi
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <print_binary+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_binary>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %edi,%esi
shr    $0x7,%esi
and    $0x1,%esi
lea    0xedb(%rip),%r14
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %ebx,%esi
shr    $0x6,%esi
and    $0x1,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %ebx,%esi
shr    $0x5,%esi
and    $0x1,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %ebx,%esi
shr    $0x4,%esi
and    $0x1,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %ebx,%esi
shr    $0x3,%esi
and    $0x1,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %ebx,%esi
shr    $0x2,%esi
and    $0x1,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %ebx,%esi
shr    %esi
and    $0x1,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
and    $0x1,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @print_binary(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 7, i32* %3
br label %4
4: ; preds = %13, %1
%5 = load i32, i32* %3
%6 = icmp sge i32 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %4
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = ashr i32 %8, %9
%11 = and i32 %10, 1
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %7
%14 = load i32, i32* %3
%15 = add nsw i32 %14, -1
store i32 %15, i32* %3
br label %4
16: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @print_binary(i32 %0) {
%2 = lshr i32 %0, 7
%3 = and i32 %2, 1
%4 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = lshr i32 %0, 6
%6 = and i32 %5, 1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = lshr i32 %0, 5
%9 = and i32 %8, 1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = lshr i32 %0, 4
%12 = and i32 %11, 1
%13 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = lshr i32 %0, 3
%15 = and i32 %14, 1
%16 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = lshr i32 %0, 2
%18 = and i32 %17, 1
%19 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = lshr i32 %0, 1
%21 = and i32 %20, 1
%22 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = and i32 %0, 1
%24 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
ret void
}