#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*/ PrintBite(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
void PrintEncode(int wt[20000 + 1], int B, FILE *f) {
  int i = 0;
  for (i = 0; i < B; i++) {
    if (i != 0 && i % 80 == 0) {
      fprintf(f, "\n");
    }
    PrintBite(wt[i], f);
  }
}


x86 assembly (clang, -O0):
<PrintEncode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119d <PrintEncode+0x7d>
cmpl   $0x0,-0x1c(%rbp)
je     117b <PrintEncode+0x5b>
mov    -0x1c(%rbp),%eax
mov    $0x50,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    117b <PrintEncode+0x5b>
mov    -0x18(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x18(%rbp),%rsi
call   1040 <PrintBite@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1141 <PrintEncode+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintEncode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1198 <PrintEncode+0x78>
mov    %rdx,%r12
mov    %rdi,%r14
mov    %esi,%r15d
shl    $0x2,%r15
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r13d,%r13d
jmp    116b <PrintEncode+0x4b>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14,%r13,1),%edi
mov    %r12,%rsi
call   1040 <PrintBite@plt>
add    $0x4,%r13
add    $0xffffffff,%ebp
add    $0x1,%ebx
cmp    %r13,%r15
je     1198 <PrintEncode+0x78>
test   %r13,%r13
je     1150 <PrintEncode+0x30>
mov    %ebx,%eax
mov    $0xcccccccd,%ecx
imul   %rcx,%rax
shr    $0x26,%rax
lea    (%rax,%rax,4),%eax
shl    $0x4,%eax
add    %ebp,%eax
jne    1150 <PrintEncode+0x30>
mov    $0xa,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
jmp    1150 <PrintEncode+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define void @PrintEncode(i32* %0, i32 %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
store i32 0, i32* %7
store i32 0, i32* %7
br label %8
8: ; preds = %30, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %33
12: ; preds = %8
%13 = load i32, i32* %7
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %7
%17 = srem i32 %16, 80
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32*, i32** %6
%21 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %19, %15, %12
%23 = load i32*, i32** %4
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
%27 = load i32, i32* %26
%28 = load i32*, i32** %6
%29 = call i32 @PrintBite(i32 %27, i32* %28)
br label %30
30: ; preds = %22
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %8
33: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @PrintEncode(i32* nocapture %0, i32 %1, i32* %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %22
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %16
%8 = phi i64 [ 0, %5 ], [ %20, %16 ]
%9 = icmp ne i64 %8, 0
%10 = trunc i64 %8 to i32
%11 = urem i32 %10, 80
%12 = icmp eq i32 %11, 0
%13 = and i1 %9, %12
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = tail call i32 @fputc(i32 10, i32* %2)
br label %16
16: ; preds = %14, %7
%17 = getelementptr inbounds i32, i32* %0, i64 %8
%18 = load i32, i32* %17
%19 = tail call i32 @PrintBite(i32 %18, i32* %2)
%20 = add nuw nsw i64 %8, 1
%21 = icmp eq i64 %20, %6
br i1 %21, label %22, label %7
22: ; preds = %16, %3
ret void
}