#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 */
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ flushmmucache_nopc();
int /*<<< orphan*/ mem_set_mem_state(int /*<<< orphan*/, int /*<<< orphan*/,
                                     int);
void i4x0_map(uint32_t addr, uint32_t size, int state) {
  switch (state & 3) {
  case 0:
    mem_set_mem_state(addr, size, 0x70 | 0x07);
    break;
  case 1:
    mem_set_mem_state(addr, size, 0x10 | 0x07);
    break;
  case 2:
    mem_set_mem_state(addr, size, 0x70 | 0x01);
    break;
  case 3:
    mem_set_mem_state(addr, size, 0x10 | 0x01);
    break;
  }
  flushmmucache_nopc();
}


x86 assembly (clang, -O0):
<i4x0_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x3,%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%eax
ja     11a7 <i4x0_map+0x87>
mov    -0x18(%rbp),%rax
lea    0xeb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x77,%edx
call   1030 <mem_set_mem_state@plt>
jmp    11a7 <i4x0_map+0x87>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x17,%edx
call   1030 <mem_set_mem_state@plt>
jmp    11a7 <i4x0_map+0x87>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x71,%edx
call   1030 <mem_set_mem_state@plt>
jmp    11a7 <i4x0_map+0x87>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x11,%edx
call   1030 <mem_set_mem_state@plt>
mov    $0x0,%al
call   1040 <flushmmucache_nopc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i4x0_map>:
push   %rax
and    $0x3,%edx
lea    0xed5(%rip),%rax
mov    (%rax,%rdx,4),%edx
call   1030 <mem_set_mem_state@plt>
xor    %eax,%eax
pop    %rcx
jmp    1040 <flushmmucache_nopc@plt>

LLVM IR (-O0):
define void @i4x0_map(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = and i32 %7, 3
switch i32 %8, label %25 [
i32 0, label %9
i32 1, label %13
i32 2, label %17
i32 3, label %21
]
9: ; preds = %3
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = call i32 @mem_set_mem_state(i32 %10, i32 %11, i32 119)
br label %25
13: ; preds = %3
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = call i32 @mem_set_mem_state(i32 %14, i32 %15, i32 23)
br label %25
17: ; preds = %3
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = call i32 @mem_set_mem_state(i32 %18, i32 %19, i32 113)
br label %25
21: ; preds = %3
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = call i32 @mem_set_mem_state(i32 %22, i32 %23, i32 17)
br label %25
25: ; preds = %3, %21, %17, %13, %9
%26 = call i32 (...) @flushmmucache_nopc()
ret void
}

LLVM IR (-O2):
@switch.table.i4x0_map = [4 x i32] [i32 119, i32 23, i32 113, i32 17]
define void @i4x0_map(i32 %0, i32 %1, i32 %2) {
%4 = and i32 %2, 3
%5 = zext i32 %4 to i64
%6 = getelementptr inbounds [4 x i32], [4 x i32]* @switch.table.i4x0_map, i64 0, i64 %5
%7 = load i32, i32* %6
%8 = tail call i32 @mem_set_mem_state(i32 %0, i32 %1, i32 %7)
%9 = tail call i32 (...) @flushmmucache_nopc()
ret void
}