#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 printbinary(int num) {
  int c;
  for (c = 5; c >= 0; c--)
    if (num & (1 << c))
      printf(" 1");
    else
      printf(" 0");
}


x86 assembly (clang, -O0):
<printbinary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1176 <printbinary+0x66>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1157 <printbinary+0x47>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
jmp    1163 <printbinary+0x53>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
jmp    1168 <printbinary+0x58>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <printbinary+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printbinary>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
test   $0x20,%bpl
lea    0xee2(%rip),%r14
lea    0xed8(%rip),%rbx
mov    %rbx,%rdi
cmove  %r14,%rdi
call   1030 <printf@plt>
test   $0x10,%bpl
mov    %rbx,%rdi
cmove  %r14,%rdi
call   1030 <printf@plt>
test   $0x8,%bpl
mov    %rbx,%rdi
cmove  %r14,%rdi
call   1030 <printf@plt>
test   $0x4,%bpl
mov    %rbx,%rdi
cmove  %r14,%rdi
call   1030 <printf@plt>
test   $0x2,%bpl
mov    %rbx,%rdi
cmove  %r14,%rdi
call   1030 <printf@plt>
test   $0x1,%bpl
cmove  %r14,%rbx
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

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

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