#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_assoc(unsigned long assoc) {
  switch (assoc & 0xff) {
  case 0x0:
    break;
  case 0x1:
    printf("Direct mapped. ");
    break;
  case 0xff:
    printf("Fully associative. ");
    break;
  default:
    printf("%lu-way associative. ", assoc);
  }
}


x86 assembly (clang, -O0):
<do_assoc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movzbl -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
test   %rax,%rax
je     115a <do_assoc+0x4a>
jmp    1132 <do_assoc+0x22>
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
je     115f <do_assoc+0x4f>
jmp    1145 <do_assoc+0x35>
mov    -0x10(%rbp),%rax
sub    $0xff,%rax
je     1172 <do_assoc+0x62>
jmp    1185 <do_assoc+0x75>
jmp    1197 <do_assoc+0x87>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1197 <do_assoc+0x87>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1197 <do_assoc+0x87>
mov    -0x8(%rbp),%rsi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_assoc>:
mov    %rdi,%rsi
cmp    $0xff,%sil
je     1132 <do_assoc+0x22>
test   %sil,%sil
je     1140 <do_assoc+0x30>
cmp    $0x1,%sil
jne    1141 <do_assoc+0x31>
lea    0xed5(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xed7(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
ret
lea    0xedc(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"Direct mapped. \00"
@.str.1 = [20 x i8] c"Fully associative. \00"
@.str.2 = [22 x i8] c"%lu-way associative. \00"
define void @do_assoc(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = and i64 %3, 255
switch i64 %4, label %10 [
i64 0, label %5
i64 1, label %6
i64 255, label %8
]
5: ; preds = %1
br label %13
6: ; preds = %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %13
8: ; preds = %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %13
10: ; preds = %1
%11 = load i64, i64* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i64 %11)
br label %13
13: ; preds = %10, %8, %6, %5
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"Direct mapped. \00"
@.str.1 = [20 x i8] c"Fully associative. \00"
@.str.2 = [22 x i8] c"%lu-way associative. \00"
define void @do_assoc(i64 %0) {
%2 = trunc i64 %0 to i8
switch i8 %2, label %7 [
i8 0, label %9
i8 1, label %3
i8 -1, label %5
]
3: ; preds = %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %9
5: ; preds = %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %9
7: ; preds = %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i64 %0)
br label %9
9: ; preds = %7, %5, %3, %1
ret void
}