#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void printtable(const short *table, int limit) {
  int i;
  printf(
      "# This is the distribution table for the experimental distribution.\n");
  for (i = 0; i < limit; ++i) {
    printf("%d%c", table[i], (i % 8) == 7 ? '\n' : ' ');
  }
}


x86 assembly (clang, -O0):
<printtable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1185 <printtable+0x75>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movswl (%rax,%rcx,2),%esi
mov    -0x10(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    $0x20,%edx
mov    $0xa,%eax
cmp    $0x7,%ecx
cmove  %eax,%edx
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <printtable+0x24>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printtable>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r12
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
test   %ebp,%ebp
jle    1177 <printtable+0x57>
mov    %ebp,%ebp
mov    $0xa,%r15d
lea    0xeb4(%rip),%r14
xor    %ebx,%ebx
xchg   %ax,%ax
movswl (%r12,%rbx,2),%esi
mov    %ebx,%eax
not    %eax
test   $0x7,%al
mov    $0x20,%edx
cmove  %r15d,%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <printtable+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [69 x i8] c"# This is the distribution table for the experimental distribution.\0A\00"
@.str.1 = [5 x i8] c"%d%c\00"
define void @printtable(i16* %0, i32 %1) {
%3 = alloca i16*
%4 = alloca i32
%5 = alloca i32
store i16* %0, i16** %3
store i32 %1, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %7
7: ; preds = %24, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %27
11: ; preds = %7
%12 = load i16*, i16** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i16, i16* %12, i64 %14
%16 = load i16, i16* %15
%17 = sext i16 %16 to i32
%18 = load i32, i32* %5
%19 = srem i32 %18, 8
%20 = icmp eq i32 %19, 7
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 10, i32 32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %22)
br label %24
24: ; preds = %11
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %7
27: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%d%c\00"
@str = [68 x i8] c"# This is the distribution table for the experimental distribution.\00"
define void @printtable(i16* nocapture %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str, i64 0, i64 0))
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %18
5: ; preds = %2
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %16, %7 ]
%9 = getelementptr inbounds i16, i16* %0, i64 %8
%10 = load i16, i16* %9
%11 = sext i16 %10 to i32
%12 = and i64 %8, 7
%13 = icmp eq i64 %12, 7
%14 = select i1 %13, i32 10, i32 32
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %14)
%16 = add nuw nsw i64 %8, 1
%17 = icmp eq i64 %16, %6
br i1 %17, label %18, label %7
18: ; preds = %7, %2
ret void
}