#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*/ fprintf(int /*<<< orphan*/, char *, char);
int /*<<< orphan*/ stdout;
void item_print(const void *k, void *p) {
  int *lnpos = p != NULL ? (int *)p : NULL;
  fprintf(stdout, "%4d", *((int *)k));
  if (p && ++*lnpos == 20) {
    *lnpos = 0;
    fprintf(stdout, "%c", '\n');
  }
}


x86 assembly (clang, -O0):
<item_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1138 <item_print+0x28>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1143 <item_print+0x33>
xor    %eax,%eax
mov    %rax,-0x20(%rbp)
jmp    1143 <item_print+0x33>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
lea    0xe9f(%rip),%rsi
movsbl %al,%edx
call   1030 <fprintf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11ac <item_print+0x9c>
mov    -0x18(%rbp),%rcx
mov    (%rcx),%eax
add    $0x1,%eax
mov    %eax,(%rcx)
cmp    $0x14,%eax
jne    11ac <item_print+0x9c>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0xe62(%rip),%rsi
mov    $0xa,%edx
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<item_print>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x2ec2(%rip),%r14
mov    (%r14),%eax
movsbl (%rdi),%edx
lea    0xed5(%rip),%rsi
mov    %eax,%edi
call   1030 <fprintf@plt>
test   %rbx,%rbx
je     1164 <item_print+0x54>
mov    (%rbx),%eax
add    $0x1,%eax
mov    %eax,(%rbx)
cmp    $0x14,%eax
jne    1164 <item_print+0x54>
movl   $0x0,(%rbx)
mov    (%r14),%edi
lea    0xeb1(%rip),%rsi
mov    $0xa,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@stdout = global i32 0
@.str = [4 x i8] c"%4d\00"
@.str.1 = [3 x i8] c"%c\00"
define void @item_print(i8* nocapture %0, i8* %1) {
%3 = icmp eq i8* %1, null
%4 = bitcast i8* %1 to i32*
%5 = load i32, i32* @stdout
%6 = bitcast i8* %0 to i32*
%7 = load i32, i32* %6
%8 = trunc i32 %7 to i8
%9 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %8)
br i1 %3, label %17, label %10
10: ; preds = %2
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 1
store i32 %12, i32* %4
%13 = icmp eq i32 %12, 20
br i1 %13, label %14, label %17
14: ; preds = %10
store i32 0, i32* %4
%15 = load i32, i32* @stdout
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext 10)
br label %17
17: ; preds = %14, %10, %2
ret void
}