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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, long);
void output_input_bits(FILE *out, long *bits, int size) {
  int i, j;
  size /= sizeof(long);
  for (i = size - 1; i >= 0; i--)
    if (bits[i])
      break;
  if (i < 0)
    i = 0;
  fprintf(out, "%lx", bits[i]);
  for (j = i - 1; j >= 0; j--)
    fprintf(out, ":%lx", bits[j]);
}


x86 assembly (clang, -O0):
<output_input_bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shr    $0x3,%rax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     116c <output_input_bits+0x5c>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1159 <output_input_bits+0x49>
jmp    116c <output_input_bits+0x5c>
jmp    115e <output_input_bits+0x4e>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1137 <output_input_bits+0x27>
cmpl   $0x0,-0x18(%rbp)
jge    117d <output_input_bits+0x6d>
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe6d(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     11d6 <output_input_bits+0xc6>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe3d(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a2 <output_input_bits+0x92>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_input_bits>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %eax,%eax
sar    $0x3,%edx
mov    %edx,%r15d
cmovns %eax,%r15d
lea    -0x1(%r15),%eax
xchg   %ax,%ax
test   %edx,%edx
jle    1147 <output_input_bits+0x37>
add    $0xffffffffffffffff,%rdx
mov    %edx,%ecx
cmpq   $0x0,(%rbx,%rcx,8)
je     1130 <output_input_bits+0x20>
lea    0x1(%rdx),%r15d
mov    %edx,%eax
xor    %r12d,%r12d
cmp    $0x2,%r15d
cmovge %eax,%r12d
mov    (%rbx,%r12,8),%rdx
lea    0xea4(%rip),%rsi
mov    %r14,%rdi
call   1030 <fprintf@plt>
cmp    $0x2,%r15d
jl     119a <output_input_bits+0x8a>
lea    0x1(%r12),%ebp
add    $0xffffffff,%r12d
lea    (%rbx,%r12,8),%rbx
lea    0xe81(%rip),%r15
nop
mov    (%rbx),%rdx
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <fprintf@plt>
add    $0xffffffff,%ebp
add    $0xfffffffffffffff8,%rbx
cmp    $0x1,%ebp
jg     1180 <output_input_bits+0x70>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%lx\00"
@.str.1 = [5 x i8] c":%lx\00"
define void @output_input_bits(i32* nocapture %0, i64* nocapture %1, i32 %2) {
%4 = ashr i32 %2, 3
%5 = zext i32 %4 to i64
%6 = call i32 @llvm.smin.i32(i32 %4, i32 0)
%7 = add nsw i32 %6, -1
br label %8
8: ; preds = %13, %3
%9 = phi i64 [ %10, %13 ], [ %5, %3 ]
%10 = add nsw i64 %9, -1
%11 = trunc i64 %9 to i32
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = and i64 %10, 4294967295
%15 = getelementptr inbounds i64, i64* %1, i64 %14
%16 = load i64, i64* %15
%17 = icmp eq i64 %16, 0
br i1 %17, label %8, label %18
18: ; preds = %13
%19 = trunc i64 %9 to i32
%20 = trunc i64 %10 to i32
br label %21
21: ; preds = %8, %18
%22 = phi i32 [ %19, %18 ], [ %6, %8 ]
%23 = phi i32 [ %20, %18 ], [ %7, %8 ]
%24 = icmp sgt i32 %22, 1
%25 = select i1 %24, i32 %23, i32 0
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i64, i64* %1, i64 %26
%28 = load i64, i64* %27
%29 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %28)
br i1 %24, label %30, label %39
30: ; preds = %21, %30
%31 = phi i64 [ %32, %30 ], [ %26, %21 ]
%32 = add nsw i64 %31, -1
%33 = and i64 %32, 4294967295
%34 = getelementptr inbounds i64, i64* %1, i64 %33
%35 = load i64, i64* %34
%36 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %35)
%37 = trunc i64 %31 to i32
%38 = icmp sgt i32 %37, 1
br i1 %38, label %30, label %39
39: ; preds = %30, %21
ret void
}