#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*/ memset(char *, int /*<<< orphan*/, int);
int get_binary(int d, char *bin) {
  memset(bin, 0, 255);
  int i;
  for (i = 0; i < 8; i++) {
    bin[i] = (d & 1) + 48;
    d = d >> 1;
  }
  bin[i] = '\0';
  return 0;
}


x86 assembly (clang, -O0):
<get_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1030 <memset@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    116d <get_binary+0x5d>
mov    -0x4(%rbp),%eax
and    $0x1,%eax
add    $0x30,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1136 <get_binary+0x26>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_binary>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1030 <memset@plt>
mov    %ebp,%eax
and    $0x1,%al
or     $0x30,%al
mov    %al,(%rbx)
mov    %ebp,%eax
shr    %al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x1(%rbx)
mov    %ebp,%eax
shr    $0x2,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x2(%rbx)
mov    %ebp,%eax
shr    $0x3,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x3(%rbx)
mov    %ebp,%eax
shr    $0x4,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x4(%rbx)
mov    %ebp,%eax
shr    $0x5,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x5(%rbx)
mov    %ebp,%eax
shr    $0x6,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x6(%rbx)
shr    $0x7,%bpl
or     $0x30,%bpl
mov    %bpl,0x7(%rbx)
movb   $0x0,0x8(%rbx)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_binary(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i32 @memset(i8* %6, i32 0, i32 255)
store i32 0, i32* %5
br label %8
8: ; preds = %22, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = load i32, i32* %3
%13 = and i32 %12, 1
%14 = add nsw i32 %13, 48
%15 = trunc i32 %14 to i8
%16 = load i8*, i8** %4
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 %15, i8* %19
%20 = load i32, i32* %3
%21 = ashr i32 %20, 1
store i32 %21, i32* %3
br label %22
22: ; preds = %11
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %8
25: ; preds = %8
%26 = load i8*, i8** %4
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 0, i8* %29
ret i32 0
}

LLVM IR (-O2):
define i32 @get_binary(i32 %0, i8* %1) {
%3 = tail call i32 @memset(i8* %1, i32 0, i32 255)
%4 = trunc i32 %0 to i8
%5 = and i8 %4, 1
%6 = or i8 %5, 48
store i8 %6, i8* %1
%7 = trunc i32 %0 to i8
%8 = lshr i8 %7, 1
%9 = and i8 %8, 1
%10 = or i8 %9, 48
%11 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %10, i8* %11
%12 = trunc i32 %0 to i8
%13 = lshr i8 %12, 2
%14 = and i8 %13, 1
%15 = or i8 %14, 48
%16 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %15, i8* %16
%17 = trunc i32 %0 to i8
%18 = lshr i8 %17, 3
%19 = and i8 %18, 1
%20 = or i8 %19, 48
%21 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %20, i8* %21
%22 = trunc i32 %0 to i8
%23 = lshr i8 %22, 4
%24 = and i8 %23, 1
%25 = or i8 %24, 48
%26 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %25, i8* %26
%27 = trunc i32 %0 to i8
%28 = lshr i8 %27, 5
%29 = and i8 %28, 1
%30 = or i8 %29, 48
%31 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %30, i8* %31
%32 = trunc i32 %0 to i8
%33 = lshr i8 %32, 6
%34 = and i8 %33, 1
%35 = or i8 %34, 48
%36 = getelementptr inbounds i8, i8* %1, i64 6
store i8 %35, i8* %36
%37 = trunc i32 %0 to i8
%38 = lshr i8 %37, 7
%39 = or i8 %38, 48
%40 = getelementptr inbounds i8, i8* %1, i64 7
store i8 %39, i8* %40
%41 = getelementptr inbounds i8, i8* %1, i64 8
store i8 0, i8* %41
ret i32 0
}