#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 const *, ...);
void print_logs(const char *name, int logmod, unsigned int *logt,
                unsigned int *alog, int u16, int last) {
  int i;
  const char *type = u16 ? "short" : "char";
  const char *format = u16 ? " 0x%04X," : " 0x%02X,";
  printf("static const unsigned %s logt_%s[%d] = {", type, name, logmod + 1);
  for (i = 0; i < logmod + 1; i++) {
    if (i % 16 == 0)
      printf("\n   ");
    printf(format, i ? logt[i] : 0);
  }
  printf("\n};\n");
  printf("static const unsigned %s alog_%s[%d] = {", type, name, logmod * 2);
  for (i = 0; i < logmod; i++) {
    if (i % 16 == 0)
      printf("\n   ");
    printf(format, alog[i]);
  }
  for (i = 0; i < logmod; i++) {
    if (i % 16 == 0)
      printf("\n   ");
    printf(format, alog[i]);
  }
  printf("\n};\n");
  if (!last) {
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_logs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x24(%rbp),%edx
lea    0xecd(%rip),%rax
lea    0xec0(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%edx
lea    0xebf(%rip),%rax
lea    0xeaf(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1208 <print_logs+0xf8>
mov    -0x2c(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11bd <print_logs+0xad>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     11e2 <print_logs+0xd2>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4c(%rbp)
jmp    11ec <print_logs+0xdc>
xor    %eax,%eax
mov    %eax,-0x4c(%rbp)
jmp    11ec <print_logs+0xdc>
mov    -0x48(%rbp),%rdi
mov    -0x4c(%rbp),%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    118a <print_logs+0x7a>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    128b <print_logs+0x17b>
mov    -0x2c(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1267 <print_logs+0x157>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1239 <print_logs+0x129>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12e4 <print_logs+0x1d4>
mov    -0x2c(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12c0 <print_logs+0x1b0>
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1292 <print_logs+0x182>
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x28(%rbp)
jne    130a <print_logs+0x1fa>
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_logs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,0xc(%rsp)
mov    %rcx,%r15
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rdx
test   %r8d,%r8d
lea    0xeae(%rip),%rax
lea    0xea1(%rip),%rsi
cmove  %rax,%rsi
lea    0xeaa(%rip),%rax
lea    0xe9a(%rip),%r12
cmove  %rax,%r12
lea    0x1(%rbp),%ebx
lea    0xe9e(%rip),%rdi
mov    %rsi,0x18(%rsp)
mov    %rdx,0x20(%rsp)
mov    %ebx,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,0x10(%rsp)
test   %ebp,%ebp
js     11f9 <print_logs+0xc9>
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x10(%rsp)
je     11f9 <print_logs+0xc9>
mov    %ebx,%ebx
mov    $0x1,%r13d
lea    0xe7b(%rip),%rbp
jmp    11e7 <print_logs+0xb7>
nopl   (%rax)
mov    (%r14,%r13,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r13
cmp    %r13,%rbx
je     11f9 <print_logs+0xc9>
test   $0xf,%r13b
jne    11d0 <print_logs+0xa0>
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11d0 <print_logs+0xa0>
lea    0xe74(%rip),%rdi
call   1040 <puts@plt>
mov    0x10(%rsp),%r13
lea    0x0(%r13,%r13,1),%ecx
lea    0xe35(%rip),%rdi
mov    0x18(%rsp),%rsi
mov    0x20(%rsp),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
test   %r13d,%r13d
jle    12a9 <print_logs+0x179>
mov    %r13d,%ebx
lea    0xe10(%rip),%r14
xor    %ebp,%ebp
jmp    1257 <print_logs+0x127>
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbp,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
je     1269 <print_logs+0x139>
test   $0xf,%bpl
jne    1240 <print_logs+0x110>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1240 <print_logs+0x110>
test   %r13d,%r13d
jle    12a9 <print_logs+0x179>
lea    0xdd1(%rip),%r14
xor    %ebp,%ebp
jmp    1297 <print_logs+0x167>
nopl   0x0(%rax)
mov    (%r15,%rbp,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
je     12a9 <print_logs+0x179>
test   $0xf,%bpl
jne    1280 <print_logs+0x150>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1280 <print_logs+0x150>
lea    0xdc4(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
je     12cb <print_logs+0x19b>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xa,%edi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"short\00"
@.str.1 = [5 x i8] c"char\00"
@.str.2 = [9 x i8] c" 0x%04X,\00"
@.str.3 = [9 x i8] c" 0x%02X,\00"
@.str.4 = [41 x i8] c"static const unsigned %s logt_%s[%d] = {\00"
@.str.5 = [5 x i8] c"\0A \00"
@.str.6 = [5 x i8] c"\0A};\0A\00"
@.str.7 = [41 x i8] c"static const unsigned %s alog_%s[%d] = {\00"
@.str.8 = [2 x i8] c"\0A\00"
define void @print_logs(i8* %0, i32 %1, i32* %2, i32* %3, i32 %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i8*
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%16 = load i32, i32* %11
%17 = icmp ne i32 %16, 0
%18 = zext i1 %17 to i64
%19 = select i1 %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
store i8* %19, i8** %14
%20 = load i32, i32* %11
%21 = icmp ne i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0)
store i8* %23, i8** %15
%24 = load i8*, i8** %14
%25 = load i8*, i8** %7
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i8* %24, i8* %25, i32 %27)
store i32 0, i32* %13
br label %29
29: ; preds = %54, %6
%30 = load i32, i32* %13
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
%33 = icmp slt i32 %30, %32
br i1 %33, label %34, label %57
34: ; preds = %29
%35 = load i32, i32* %13
%36 = srem i32 %35, 16
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
%41 = load i8*, i8** %15
%42 = load i32, i32* %13
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %40
%45 = load i32*, i32** %9
%46 = load i32, i32* %13
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
%49 = load i32, i32* %48
br label %51
50: ; preds = %40
br label %51
51: ; preds = %50, %44
%52 = phi i32 [ %49, %44 ], [ 0, %50 ]
%53 = call i32 (i8*, ...) @printf(i8* %41, i32 %52)
br label %54
54: ; preds = %51
%55 = load i32, i32* %13
%56 = add nsw i32 %55, 1
store i32 %56, i32* %13
br label %29
57: ; preds = %29
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%59 = load i8*, i8** %14
%60 = load i8*, i8** %7
%61 = load i32, i32* %8
%62 = mul nsw i32 %61, 2
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* %59, i8* %60, i32 %62)
store i32 0, i32* %13
br label %64
64: ; preds = %82, %57
%65 = load i32, i32* %13
%66 = load i32, i32* %8
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %85
68: ; preds = %64
%69 = load i32, i32* %13
%70 = srem i32 %69, 16
%71 = icmp eq i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %68
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %74
74: ; preds = %72, %68
%75 = load i8*, i8** %15
%76 = load i32*, i32** %10
%77 = load i32, i32* %13
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i32, i32* %76, i64 %78
%80 = load i32, i32* %79
%81 = call i32 (i8*, ...) @printf(i8* %75, i32 %80)
br label %82
82: ; preds = %74
%83 = load i32, i32* %13
%84 = add nsw i32 %83, 1
store i32 %84, i32* %13
br label %64
85: ; preds = %64
store i32 0, i32* %13
br label %86
86: ; preds = %104, %85
%87 = load i32, i32* %13
%88 = load i32, i32* %8
%89 = icmp slt i32 %87, %88
br i1 %89, label %90, label %107
90: ; preds = %86
%91 = load i32, i32* %13
%92 = srem i32 %91, 16
%93 = icmp eq i32 %92, 0
br i1 %93, label %94, label %96
94: ; preds = %90
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %96
96: ; preds = %94, %90
%97 = load i8*, i8** %15
%98 = load i32*, i32** %10
%99 = load i32, i32* %13
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i32, i32* %98, i64 %100
%102 = load i32, i32* %101
%103 = call i32 (i8*, ...) @printf(i8* %97, i32 %102)
br label %104
104: ; preds = %96
%105 = load i32, i32* %13
%106 = add nsw i32 %105, 1
store i32 %106, i32* %13
br label %86
107: ; preds = %86
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%109 = load i32, i32* %12
%110 = icmp ne i32 %109, 0
br i1 %110, label %113, label %111
111: ; preds = %107
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %113
113: ; preds = %111, %107
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"short\00"
@.str.1 = [5 x i8] c"char\00"
@.str.2 = [9 x i8] c" 0x%04X,\00"
@.str.3 = [9 x i8] c" 0x%02X,\00"
@.str.4 = [41 x i8] c"static const unsigned %s logt_%s[%d] = {\00"
@.str.5 = [5 x i8] c"\0A \00"
@.str.7 = [41 x i8] c"static const unsigned %s alog_%s[%d] = {\00"
@str.9 = [4 x i8] c"\0A};\00"
define void @print_logs(i8* %0, i32 %1, i32* nocapture %2, i32* nocapture %3, i32 %4, i32 %5) {
%7 = icmp eq i32 %4, 0
%8 = select i1 %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0)
%9 = select i1 %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0)
%10 = add i32 %1, 1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i8* %8, i8* %0, i32 %10)
%12 = icmp slt i32 %1, 0
br i1 %12, label %30, label %13
13: ; preds = %6
%14 = zext i32 %10 to i64
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %9, i32 0)
%17 = icmp eq i32 %1, 0
br i1 %17, label %30, label %18
18: ; preds = %13, %24
%19 = phi i64 [ %28, %24 ], [ 1, %13 ]
%20 = and i64 %19, 15
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %24
24: ; preds = %18, %22
%25 = getelementptr inbounds i32, i32* %2, i64 %19
%26 = load i32, i32* %25
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %9, i32 %26)
%28 = add nuw nsw i64 %19, 1
%29 = icmp eq i64 %28, %14
br i1 %29, label %30, label %18
30: ; preds = %24, %13, %6
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.9, i64 0, i64 0))
%32 = shl nsw i32 %1, 1
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* %8, i8* %0, i32 %32)
%34 = icmp sgt i32 %1, 0
br i1 %34, label %35, label %64
35: ; preds = %30
%36 = zext i32 %1 to i64
br label %40
37: ; preds = %46
br i1 %34, label %38, label %64
38: ; preds = %37
%39 = zext i32 %1 to i64
br label %52
40: ; preds = %35, %46
%41 = phi i64 [ 0, %35 ], [ %50, %46 ]
%42 = and i64 %41, 15
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %46
46: ; preds = %44, %40
%47 = getelementptr inbounds i32, i32* %3, i64 %41
%48 = load i32, i32* %47
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %9, i32 %48)
%50 = add nuw nsw i64 %41, 1
%51 = icmp eq i64 %50, %36
br i1 %51, label %37, label %40
52: ; preds = %38, %58
%53 = phi i64 [ 0, %38 ], [ %62, %58 ]
%54 = and i64 %53, 15
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %52
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %58
58: ; preds = %56, %52
%59 = getelementptr inbounds i32, i32* %3, i64 %53
%60 = load i32, i32* %59
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %9, i32 %60)
%62 = add nuw nsw i64 %53, 1
%63 = icmp eq i64 %62, %39
br i1 %63, label %64, label %52
64: ; preds = %58, %30, %37
%65 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.9, i64 0, i64 0))
%66 = icmp eq i32 %5, 0
br i1 %66, label %67, label %69
67: ; preds = %64
%68 = tail call i32 @putchar(i32 10)
br label %69
69: ; preds = %67, %64
ret void
}