#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 */
struct dfont {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ dfont_dump(struct dfont *);
int /*<<< orphan*/ dfont_flush(struct dfont *);
int /*<<< orphan*/ dfont_insert(struct dfont *, int, int, int, int);
void test(struct dfont *df) {
  int i, j;
  for (i = 0; i < 20; i++) {
    for (j = 0; j < 4; j++) {
      dfont_insert(df, i, j, 12 + i / 2 + j, 16 + j);
    }
  }
  dfont_dump(df);
  dfont_flush(df);
  for (i = 0; i < 10; i++) {
    dfont_insert(df, 100 + i, i % 4, 12 + i + j, 16 + i % 4);
  }
  dfont_dump(df);
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x14,-0xc(%rbp)
jge    11af <test+0x7f>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    119c <test+0x6c>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x14(%rbp),%edx
mov    %eax,%ecx
add    $0xc,%ecx
add    -0x10(%rbp),%ecx
mov    -0x10(%rbp),%r8d
add    $0x10,%r8d
call   1050 <dfont_insert@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1154 <test+0x24>
jmp    11a1 <test+0x71>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <test+0x13>
mov    -0x8(%rbp),%rdi
call   1030 <dfont_dump@plt>
mov    -0x8(%rbp),%rdi
call   1040 <dfont_flush@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    121d <test+0xed>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x64,%esi
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0xc(%rbp),%ecx
add    $0xc,%ecx
add    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%eax
mov    $0x4,%r8d
cltd
idiv   %r8d
mov    %edx,%r8d
mov    -0x18(%rbp),%edx
add    $0x10,%r8d
call   1050 <dfont_insert@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c8 <test+0x98>
mov    -0x8(%rbp),%rdi
call   1030 <dfont_dump@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %ebp,%ebx
shr    %ebx
lea    0xc(%rbx),%ecx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %edx,%edx
mov    $0x10,%r8d
call   1050 <dfont_insert@plt>
lea    0xd(%rbx),%ecx
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
mov    $0x11,%r8d
call   1050 <dfont_insert@plt>
lea    0xe(%rbx),%ecx
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x2,%edx
mov    $0x12,%r8d
call   1050 <dfont_insert@plt>
add    $0xf,%ebx
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x3,%edx
mov    %ebx,%ecx
mov    $0x13,%r8d
call   1050 <dfont_insert@plt>
add    $0x1,%ebp
cmp    $0x14,%ebp
jne    1140 <test+0x10>
mov    %r14,%rdi
call   1030 <dfont_dump@plt>
mov    %r14,%rdi
call   1040 <dfont_flush@plt>
mov    %r14,%rdi
mov    $0x64,%esi
xor    %edx,%edx
mov    $0x10,%ecx
mov    $0x10,%r8d
call   1050 <dfont_insert@plt>
mov    %r14,%rdi
mov    $0x65,%esi
mov    $0x1,%edx
mov    $0x11,%ecx
mov    $0x11,%r8d
call   1050 <dfont_insert@plt>
mov    %r14,%rdi
mov    $0x66,%esi
mov    $0x2,%edx
mov    $0x12,%ecx
mov    $0x12,%r8d
call   1050 <dfont_insert@plt>
mov    %r14,%rdi
mov    $0x67,%esi
mov    $0x3,%edx
mov    $0x13,%ecx
mov    $0x13,%r8d
call   1050 <dfont_insert@plt>
mov    %r14,%rdi
mov    $0x68,%esi
xor    %edx,%edx
mov    $0x14,%ecx
mov    $0x10,%r8d
call   1050 <dfont_insert@plt>
mov    %r14,%rdi
mov    $0x69,%esi
mov    $0x1,%edx
mov    $0x15,%ecx
mov    $0x11,%r8d
call   1050 <dfont_insert@plt>
mov    %r14,%rdi
mov    $0x6a,%esi
mov    $0x2,%edx
mov    $0x16,%ecx
mov    $0x12,%r8d
call   1050 <dfont_insert@plt>
mov    %r14,%rdi
mov    $0x6b,%esi
mov    $0x3,%edx
mov    $0x17,%ecx
mov    $0x13,%r8d
call   1050 <dfont_insert@plt>
mov    %r14,%rdi
mov    $0x6c,%esi
xor    %edx,%edx
mov    $0x18,%ecx
mov    $0x10,%r8d
call   1050 <dfont_insert@plt>
mov    %r14,%rdi
mov    $0x6d,%esi
mov    $0x1,%edx
mov    $0x19,%ecx
mov    $0x11,%r8d
call   1050 <dfont_insert@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <dfont_dump@plt>

LLVM IR (-O0):
%struct.dfont = type { i32 }
define void @test(%struct.dfont* %0) {
%2 = alloca %struct.dfont*
%3 = alloca i32
%4 = alloca i32
store %struct.dfont* %0, %struct.dfont** %2
store i32 0, i32* %3
br label %5
5: ; preds = %28, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 20
br i1 %7, label %8, label %31
8: ; preds = %5
store i32 0, i32* %4
br label %9
9: ; preds = %24, %8
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %27
12: ; preds = %9
%13 = load %struct.dfont*, %struct.dfont** %2
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = sdiv i32 %16, 2
%18 = add nsw i32 12, %17
%19 = load i32, i32* %4
%20 = add nsw i32 %18, %19
%21 = load i32, i32* %4
%22 = add nsw i32 16, %21
%23 = call i32 @dfont_insert(%struct.dfont* %13, i32 %14, i32 %15, i32 %20, i32 %22)
br label %24
24: ; preds = %12
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %9
27: ; preds = %9
br label %28
28: ; preds = %27
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %5
31: ; preds = %5
%32 = load %struct.dfont*, %struct.dfont** %2
%33 = call i32 @dfont_dump(%struct.dfont* %32)
%34 = load %struct.dfont*, %struct.dfont** %2
%35 = call i32 @dfont_flush(%struct.dfont* %34)
store i32 0, i32* %3
br label %36
36: ; preds = %53, %31
%37 = load i32, i32* %3
%38 = icmp slt i32 %37, 10
br i1 %38, label %39, label %56
39: ; preds = %36
%40 = load %struct.dfont*, %struct.dfont** %2
%41 = load i32, i32* %3
%42 = add nsw i32 100, %41
%43 = load i32, i32* %3
%44 = srem i32 %43, 4
%45 = load i32, i32* %3
%46 = add nsw i32 12, %45
%47 = load i32, i32* %4
%48 = add nsw i32 %46, %47
%49 = load i32, i32* %3
%50 = srem i32 %49, 4
%51 = add nsw i32 16, %50
%52 = call i32 @dfont_insert(%struct.dfont* %40, i32 %42, i32 %44, i32 %48, i32 %51)
br label %53
53: ; preds = %39
%54 = load i32, i32* %3
%55 = add nsw i32 %54, 1
store i32 %55, i32* %3
br label %36
56: ; preds = %36
%57 = load %struct.dfont*, %struct.dfont** %2
%58 = call i32 @dfont_dump(%struct.dfont* %57)
ret void
}

LLVM IR (-O2):
%struct.dfont = type { i32 }
define void @test(%struct.dfont* %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 0, %1 ], [ %13, %2 ]
%4 = lshr i32 %3, 1
%5 = add nuw nsw i32 %4, 12
%6 = tail call i32 @dfont_insert(%struct.dfont* %0, i32 %3, i32 0, i32 %5, i32 16)
%7 = add nuw nsw i32 %4, 13
%8 = tail call i32 @dfont_insert(%struct.dfont* %0, i32 %3, i32 1, i32 %7, i32 17)
%9 = add nuw nsw i32 %4, 14
%10 = tail call i32 @dfont_insert(%struct.dfont* %0, i32 %3, i32 2, i32 %9, i32 18)
%11 = add nuw nsw i32 %4, 15
%12 = tail call i32 @dfont_insert(%struct.dfont* %0, i32 %3, i32 3, i32 %11, i32 19)
%13 = add nuw nsw i32 %3, 1
%14 = icmp eq i32 %13, 20
br i1 %14, label %15, label %2
15: ; preds = %2
%16 = tail call i32 @dfont_dump(%struct.dfont* %0)
%17 = tail call i32 @dfont_flush(%struct.dfont* %0)
%18 = tail call i32 @dfont_insert(%struct.dfont* %0, i32 100, i32 0, i32 16, i32 16)
%19 = tail call i32 @dfont_insert(%struct.dfont* %0, i32 101, i32 1, i32 17, i32 17)
%20 = tail call i32 @dfont_insert(%struct.dfont* %0, i32 102, i32 2, i32 18, i32 18)
%21 = tail call i32 @dfont_insert(%struct.dfont* %0, i32 103, i32 3, i32 19, i32 19)
%22 = tail call i32 @dfont_insert(%struct.dfont* %0, i32 104, i32 0, i32 20, i32 16)
%23 = tail call i32 @dfont_insert(%struct.dfont* %0, i32 105, i32 1, i32 21, i32 17)
%24 = tail call i32 @dfont_insert(%struct.dfont* %0, i32 106, i32 2, i32 22, i32 18)
%25 = tail call i32 @dfont_insert(%struct.dfont* %0, i32 107, i32 3, i32 23, i32 19)
%26 = tail call i32 @dfont_insert(%struct.dfont* %0, i32 108, i32 0, i32 24, i32 16)
%27 = tail call i32 @dfont_insert(%struct.dfont* %0, i32 109, i32 1, i32 25, i32 17)
%28 = tail call i32 @dfont_dump(%struct.dfont* %0)
ret void
}