#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_fast32_t;
typedef int int_fast32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int CHAR_BIT;
int /*<<< orphan*/ putc_unlocked(int, int /*<<< orphan*/ *);
void writeInBytes(uint_fast32_t Number, uint_fast32_t BitsCount,
                  FILE *OutputFile) {
  int_fast32_t OutputByte = 0;
  for (uint_fast32_t i = (BitsCount - CHAR_BIT); i >= CHAR_BIT; i -= CHAR_BIT) {
    OutputByte = Number >> i;
    putc_unlocked(OutputByte, OutputFile);
    Number -= (OutputByte << i);
  }
  putc_unlocked(Number, OutputFile);
}


x86 assembly (clang, -O0):
<writeInBytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2ead(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e9e(%rip),%rcx
cmp    (%rcx),%eax
jl     1189 <writeInBytes+0x79>
mov    -0x4(%rbp),%eax
mov    -0x18(%rbp),%ecx
sar    %cl,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc_unlocked@plt>
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
shl    %cl,%eax
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    0x2e66(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
jmp    1138 <writeInBytes+0x28>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc_unlocked@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeInBytes>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebx
mov    %edi,%r15d
mov    0x2eb9(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    (%r12),%eax
sub    %eax,%ebx
cmp    %eax,%ebx
jl     1154 <writeInBytes+0x44>
mov    %r15d,%ebp
mov    %ebx,%ecx
sar    %cl,%ebp
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <putc_unlocked@plt>
mov    %ebx,%ecx
shl    %cl,%ebp
sub    %ebp,%r15d
jmp    1130 <writeInBytes+0x20>
mov    %r15d,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putc_unlocked@plt>

LLVM IR (-O0):
@CHAR_BIT = global i32 0
define void @writeInBytes(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
store i32 0, i32* %7
%9 = load i32, i32* %5
%10 = load i32, i32* @CHAR_BIT
%11 = sub nsw i32 %9, %10
store i32 %11, i32* %8
br label %12
12: ; preds = %28, %3
%13 = load i32, i32* %8
%14 = load i32, i32* @CHAR_BIT
%15 = icmp sge i32 %13, %14
br i1 %15, label %16, label %32
16: ; preds = %12
%17 = load i32, i32* %4
%18 = load i32, i32* %8
%19 = ashr i32 %17, %18
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = load i32*, i32** %6
%22 = call i32 @putc_unlocked(i32 %20, i32* %21)
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = shl i32 %23, %24
%26 = load i32, i32* %4
%27 = sub nsw i32 %26, %25
store i32 %27, i32* %4
br label %28
28: ; preds = %16
%29 = load i32, i32* @CHAR_BIT
%30 = load i32, i32* %8
%31 = sub nsw i32 %30, %29
store i32 %31, i32* %8
br label %12
32: ; preds = %12
%33 = load i32, i32* %4
%34 = load i32*, i32** %6
%35 = call i32 @putc_unlocked(i32 %33, i32* %34)
ret void
}

LLVM IR (-O2):
@CHAR_BIT = global i32 0
define void @writeInBytes(i32 %0, i32 %1, i32* nocapture %2) {
%4 = load i32, i32* @CHAR_BIT
%5 = sub nsw i32 %1, %4
%6 = icmp slt i32 %5, %4
br i1 %6, label %7, label %10
7: ; preds = %10, %3
%8 = phi i32 [ %0, %3 ], [ %16, %10 ]
%9 = tail call i32 @putc_unlocked(i32 %8, i32* %2)
ret void
10: ; preds = %3, %10
%11 = phi i32 [ %18, %10 ], [ %5, %3 ]
%12 = phi i32 [ %16, %10 ], [ %0, %3 ]
%13 = ashr i32 %12, %11
%14 = tail call i32 @putc_unlocked(i32 %13, i32* %2)
%15 = shl i32 %13, %11
%16 = sub nsw i32 %12, %15
%17 = load i32, i32* @CHAR_BIT
%18 = sub nsw i32 %11, %17
%19 = icmp slt i32 %18, %17
br i1 %19, label %7, label %10
}