#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 do_l2assoc(unsigned long assoc) {
  unsigned long a;
  a = 0;
  switch (assoc) {
  case 0x0:
    printf("Disabled. ");
    break;
  case 0x1:
    printf("Direct mapped. ");
    break;
  case 0xf:
    printf("Fully associative. ");
    break;
  case 0x2:
    a = 2;
    break;
  case 0x4:
    a = 4;
    break;
  case 0x6:
    a = 8;
    break;
  case 0x8:
    a = 16;
    break;
  case 0xa:
    a = 32;
    break;
  case 0xb:
    a = 48;
    break;
  case 0xc:
    a = 64;
    break;
  case 0xd:
    a = 96;
    break;
  case 0xe:
    a = 128;
    break;
  default:
    break;
  }
  if (a)
    printf("%lu-way associative. ", a);
}


x86 assembly (clang, -O0):
<do_l2assoc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
sub    $0xf,%rax
ja     11f8 <do_l2assoc+0xe8>
mov    -0x18(%rbp),%rax
lea    0xebf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fd <do_l2assoc+0xed>
lea    0xee7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fd <do_l2assoc+0xed>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fd <do_l2assoc+0xed>
movq   $0x2,-0x10(%rbp)
jmp    11fd <do_l2assoc+0xed>
movq   $0x4,-0x10(%rbp)
jmp    11fd <do_l2assoc+0xed>
movq   $0x8,-0x10(%rbp)
jmp    11fd <do_l2assoc+0xed>
movq   $0x10,-0x10(%rbp)
jmp    11fd <do_l2assoc+0xed>
movq   $0x20,-0x10(%rbp)
jmp    11fd <do_l2assoc+0xed>
movq   $0x30,-0x10(%rbp)
jmp    11fd <do_l2assoc+0xed>
movq   $0x40,-0x10(%rbp)
jmp    11fd <do_l2assoc+0xed>
movq   $0x60,-0x10(%rbp)
jmp    11fd <do_l2assoc+0xed>
movq   $0x80,-0x10(%rbp)
jmp    11fd <do_l2assoc+0xed>
jmp    11fd <do_l2assoc+0xed>
cmpq   $0x0,-0x10(%rbp)
je     121a <do_l2assoc+0x10a>
mov    -0x10(%rbp),%rsi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_l2assoc>:
cmp    $0xf,%rdi
ja     1145 <do_l2assoc+0x35>
mov    %rdi,%rsi
lea    0xee0(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xf10(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xf0d(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
ret
mov    $0x4,%esi
jmp    117c <do_l2assoc+0x6c>
mov    $0x8,%esi
jmp    117c <do_l2assoc+0x6c>
mov    $0x10,%esi
jmp    117c <do_l2assoc+0x6c>
mov    $0x20,%esi
jmp    117c <do_l2assoc+0x6c>
mov    $0x30,%esi
jmp    117c <do_l2assoc+0x6c>
mov    $0x40,%esi
jmp    117c <do_l2assoc+0x6c>
mov    $0x60,%esi
jmp    117c <do_l2assoc+0x6c>
mov    $0x80,%esi
lea    0xeec(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xeca(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"Disabled. \00"
@.str.1 = [16 x i8] c"Direct mapped. \00"
@.str.2 = [20 x i8] c"Fully associative. \00"
@.str.3 = [22 x i8] c"%lu-way associative. \00"
define void @do_l2assoc(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %2
store i64 0, i64* %3
%4 = load i64, i64* %2
switch i64 %4, label %20 [
i64 0, label %5
i64 1, label %7
i64 15, label %9
i64 2, label %11
i64 4, label %12
i64 6, label %13
i64 8, label %14
i64 10, label %15
i64 11, label %16
i64 12, label %17
i64 13, label %18
i64 14, label %19
]
5: ; preds = %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %21
7: ; preds = %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %21
9: ; preds = %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %21
11: ; preds = %1
store i64 2, i64* %3
br label %21
12: ; preds = %1
store i64 4, i64* %3
br label %21
13: ; preds = %1
store i64 8, i64* %3
br label %21
14: ; preds = %1
store i64 16, i64* %3
br label %21
15: ; preds = %1
store i64 32, i64* %3
br label %21
16: ; preds = %1
store i64 48, i64* %3
br label %21
17: ; preds = %1
store i64 64, i64* %3
br label %21
18: ; preds = %1
store i64 96, i64* %3
br label %21
19: ; preds = %1
store i64 128, i64* %3
br label %21
20: ; preds = %1
br label %21
21: ; preds = %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %9, %7, %5
%22 = load i64, i64* %3
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i64, i64* %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i64 %25)
br label %27
27: ; preds = %24, %21
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"Disabled. \00"
@.str.1 = [16 x i8] c"Direct mapped. \00"
@.str.2 = [20 x i8] c"Fully associative. \00"
@.str.3 = [22 x i8] c"%lu-way associative. \00"
define void @do_l2assoc(i64 %0) {
switch i64 %0, label %19 [
i64 0, label %2
i64 1, label %4
i64 15, label %6
i64 2, label %16
i64 4, label %8
i64 6, label %9
i64 8, label %10
i64 10, label %11
i64 11, label %12
i64 12, label %13
i64 13, label %14
i64 14, label %15
]
2: ; preds = %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %19
4: ; preds = %1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %19
6: ; preds = %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %19
8: ; preds = %1
br label %16
9: ; preds = %1
br label %16
10: ; preds = %1
br label %16
11: ; preds = %1
br label %16
12: ; preds = %1
br label %16
13: ; preds = %1
br label %16
14: ; preds = %1
br label %16
15: ; preds = %1
br label %16
16: ; preds = %1, %15, %14, %13, %12, %11, %10, %9, %8
%17 = phi i64 [ 4, %8 ], [ 8, %9 ], [ 16, %10 ], [ 32, %11 ], [ 48, %12 ], [ 64, %13 ], [ 96, %14 ], [ 128, %15 ], [ %0, %1 ]
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i64 %17)
br label %19
19: ; preds = %2, %4, %6, %1, %16
ret void
}