#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 uint8_t;

/* Variables and functions */
void binary_byte(uint8_t c, char *s) {
  int i;
  for (i = 7; i >= 0; i--) {
    s[i] = '0' + (c & 1);
    c >>= 1;
  }
}


x86 assembly (clang, -O0):
<binary_byte>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x7,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1149 <binary_byte+0x49>
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    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1112 <binary_byte+0x12>
pop    %rbp
ret

x86 assembly (clang, -O2):
<binary_byte>:
mov    %edi,%eax
and    $0x1,%al
or     $0x30,%al
mov    %al,0x7(%rsi)
mov    %edi,%eax
shr    %al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x6(%rsi)
mov    %edi,%eax
shr    $0x2,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x5(%rsi)
mov    %edi,%eax
shr    $0x3,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x4(%rsi)
mov    %edi,%eax
shr    $0x4,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x3(%rsi)
mov    %edi,%eax
shr    $0x5,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x2(%rsi)
mov    %edi,%eax
shr    $0x6,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x1(%rsi)
shr    $0x7,%dil
or     $0x30,%dil
mov    %dil,(%rsi)
ret

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

LLVM IR (-O2):
define void @binary_byte(i32 %0, i8* nocapture writeonly %1) {
%3 = trunc i32 %0 to i8
%4 = and i8 %3, 1
%5 = or i8 %4, 48
%6 = getelementptr inbounds i8, i8* %1, i64 7
store i8 %5, i8* %6
%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 6
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 5
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 4
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 3
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 2
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 1
store i8 %35, i8* %36
%37 = trunc i32 %0 to i8
%38 = lshr i8 %37, 7
%39 = or i8 %38, 48
store i8 %39, i8* %1
ret void
}