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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
void fprint_bit_array(FILE *f, int len, uint64_t *array, int number) {
  int loop = 64;
  for (int i = 0; i < len && number > 0; i++) {
    if (number < 64) {
      loop = number;
    }
    for (int j = 0; j < loop; j++) {
      if (1 & (array[i] >> (63 - j))) {
        fprintf(f, " 1");
      } else {
        fprintf(f, " 0");
      }
    }
    number -= 64;
  }
}


x86 assembly (clang, -O0):
<fprint_bit_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x40,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x29(%rbp)
jge    114f <fprint_bit_array+0x3f>
cmpl   $0x0,-0x1c(%rbp)
setg   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    115f <fprint_bit_array+0x4f>
jmp    11f2 <fprint_bit_array+0xe2>
cmpl   $0x40,-0x1c(%rbp)
jge    116f <fprint_bit_array+0x5f>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11db <fprint_bit_array+0xcb>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0x3f,%ecx
sub    -0x28(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11b8 <fprint_bit_array+0xa8>
mov    -0x8(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11c8 <fprint_bit_array+0xb8>
mov    -0x8(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11cd <fprint_bit_array+0xbd>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1176 <fprint_bit_array+0x66>
mov    -0x1c(%rbp),%eax
sub    $0x40,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1134 <fprint_bit_array+0x24>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprint_bit_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
jle    11ca <fprint_bit_array+0xba>
test   %ecx,%ecx
jle    11ca <fprint_bit_array+0xba>
mov    %rdx,%r14
mov    %rdi,%r13
mov    %esi,%eax
mov    %rax,0x10(%rsp)
mov    $0x40,%ebp
xor    %ebx,%ebx
lea    0xeba(%rip),%r15
mov    %ecx,%edx
nopl   0x0(%rax,%rax,1)
sub    $0x40,%edx
mov    %edx,0x8(%rsp)
mov    %ecx,0xc(%rsp)
cmovb  %ecx,%ebp
test   %ebp,%ebp
jle    11b0 <fprint_bit_array+0xa0>
mov    $0x3f,%r12d
jmp    1197 <fprint_bit_array+0x87>
nopw   0x0(%rax,%rax,1)
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1030 <fwrite@plt>
lea    (%r12,%rbp,1),%eax
add    $0xffffffff,%eax
mov    %r12d,%ecx
add    $0xffffffff,%ecx
mov    %ecx,%r12d
cmp    $0x3f,%eax
je     11b0 <fprint_bit_array+0xa0>
mov    (%r14,%rbx,4),%eax
bt     %r12d,%eax
mov    %r15,%rdi
jae    1170 <fprint_bit_array+0x60>
lea    0xe55(%rip),%rdi
jmp    1170 <fprint_bit_array+0x60>
nopl   (%rax)
add    $0x1,%rbx
cmp    0x10(%rsp),%rbx
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%edx
jae    11ca <fprint_bit_array+0xba>
cmp    $0x40,%eax
mov    %edx,%ecx
jg     1150 <fprint_bit_array+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c" 1\00"
@.str.1 = [3 x i8] c" 0\00"
define void @fprint_bit_array(i32* %0, i32 %1, i32* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32 %3, i32* %8
store i32 64, i32* %9
store i32 0, i32* %10
br label %12
12: ; preds = %55, %4
%13 = load i32, i32* %10
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i32, i32* %8
%18 = icmp sgt i32 %17, 0
br label %19
19: ; preds = %16, %12
%20 = phi i1 [ false, %12 ], [ %18, %16 ]
br i1 %20, label %21, label %58
21: ; preds = %19
%22 = load i32, i32* %8
%23 = icmp slt i32 %22, 64
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = load i32, i32* %8
store i32 %25, i32* %9
br label %26
26: ; preds = %24, %21
store i32 0, i32* %11
br label %27
27: ; preds = %49, %26
%28 = load i32, i32* %11
%29 = load i32, i32* %9
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %52
31: ; preds = %27
%32 = load i32*, i32** %7
%33 = load i32, i32* %10
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = load i32, i32* %35
%37 = load i32, i32* %11
%38 = sub nsw i32 63, %37
%39 = ashr i32 %36, %38
%40 = and i32 1, %39
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %31
%43 = load i32*, i32** %5
%44 = call i32 @fprintf(i32* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %48
45: ; preds = %31
%46 = load i32*, i32** %5
%47 = call i32 @fprintf(i32* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %48
48: ; preds = %45, %42
br label %49
49: ; preds = %48
%50 = load i32, i32* %11
%51 = add nsw i32 %50, 1
store i32 %51, i32* %11
br label %27
52: ; preds = %27
%53 = load i32, i32* %8
%54 = sub nsw i32 %53, 64
store i32 %54, i32* %8
br label %55
55: ; preds = %52
%56 = load i32, i32* %10
%57 = add nsw i32 %56, 1
store i32 %57, i32* %10
br label %12
58: ; preds = %19
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c" 1\00"
@.str.1 = [3 x i8] c" 0\00"
define void @fprint_bit_array(i32* nocapture %0, i32 %1, i32* nocapture %2, i32 %3) {
%5 = icmp sgt i32 %1, 0
%6 = icmp sgt i32 %3, 0
%7 = and i1 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = zext i32 %1 to i64
br label %11
10: ; preds = %20, %4
ret void
11: ; preds = %8, %20
%12 = phi i64 [ 0, %8 ], [ %22, %20 ]
%13 = phi i32 [ 64, %8 ], [ %16, %20 ]
%14 = phi i32 [ %3, %8 ], [ %21, %20 ]
%15 = icmp ult i32 %14, 64
%16 = select i1 %15, i32 %14, i32 %13
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %11
%19 = getelementptr inbounds i32, i32* %2, i64 %12
br label %26
20: ; preds = %26, %11
%21 = add nsw i32 %14, -64
%22 = add nuw nsw i64 %12, 1
%23 = icmp ult i64 %22, %9
%24 = icmp sgt i32 %14, 64
%25 = select i1 %23, i1 %24, i1 false
br i1 %25, label %11, label %10
26: ; preds = %18, %26
%27 = phi i32 [ 0, %18 ], [ %35, %26 ]
%28 = load i32, i32* %19
%29 = sub nsw i32 63, %27
%30 = shl nuw i32 1, %29
%31 = and i32 %28, %30
%32 = icmp eq i32 %31, 0
%33 = select i1 %32, 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)
%34 = tail call i64 @fwrite(i8* %33, i64 2, i64 1, i32* %0)
%35 = add nuw nsw i32 %27, 1
%36 = icmp eq i32 %35, %16
br i1 %36, label %20, label %26
}