void set_scroll(unsigned int layer, unsigned int x, unsigned int y) {
  switch (layer) {
  case 0:
    *((unsigned char *)0x210d) = (x & 255);
    ;
    *((unsigned char *)0x210d) = (x >> 8);
    ;
    *((unsigned char *)0x210e) = (y & 255);
    ;
    *((unsigned char *)0x210e) = (y >> 8);
    ;
    break;
  case 1:
    *((unsigned char *)0x210f) = (x & 255);
    ;
    *((unsigned char *)0x210f) = (x >> 8);
    ;
    *((unsigned char *)0x2110) = (y & 255);
    ;
    *((unsigned char *)0x2110) = (y >> 8);
    ;
    break;
  case 2:
    *((unsigned char *)0x2111) = (x & 255);
    ;
    *((unsigned char *)0x2111) = (x >> 8);
    ;
    *((unsigned char *)0x2112) = (y & 255);
    ;
    *((unsigned char *)0x2112) = (y >> 8);
    ;
    break;
  case 3:
    *((unsigned char *)0x2113) = (x & 255);
    ;
    *((unsigned char *)0x2113) = (x >> 8);
    ;
    *((unsigned char *)0x2114) = (y & 255);
    ;
    *((unsigned char *)0x2114) = (y >> 8);
    ;
    break;
  }
}


x86 assembly (clang, -O0):
<set_scroll>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%rax
ja     1241 <set_scroll+0x141>
mov    -0x18(%rbp),%rax
lea    0xed7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    $0x210d,%eax
mov    %cl,(%rax)
mov    -0x8(%rbp),%eax
shr    $0x8,%eax
mov    %al,%cl
mov    $0x210d,%eax
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    $0x210e,%eax
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
shr    $0x8,%eax
mov    %al,%cl
mov    $0x210e,%eax
mov    %cl,(%rax)
jmp    1241 <set_scroll+0x141>
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    $0x210f,%eax
mov    %cl,(%rax)
mov    -0x8(%rbp),%eax
shr    $0x8,%eax
mov    %al,%cl
mov    $0x210f,%eax
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    $0x2110,%eax
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
shr    $0x8,%eax
mov    %al,%cl
mov    $0x2110,%eax
mov    %cl,(%rax)
jmp    1241 <set_scroll+0x141>
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    $0x2111,%eax
mov    %cl,(%rax)
mov    -0x8(%rbp),%eax
shr    $0x8,%eax
mov    %al,%cl
mov    $0x2111,%eax
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    $0x2112,%eax
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
shr    $0x8,%eax
mov    %al,%cl
mov    $0x2112,%eax
mov    %cl,(%rax)
jmp    1241 <set_scroll+0x141>
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    $0x2113,%eax
mov    %cl,(%rax)
mov    -0x8(%rbp),%eax
shr    $0x8,%eax
mov    %al,%cl
mov    $0x2113,%eax
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    $0x2114,%eax
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
shr    $0x8,%eax
mov    %al,%cl
mov    $0x2114,%eax
mov    %cl,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_scroll>:
cmp    $0x3,%edi
ja     1154 <set_scroll+0x54>
mov    %esi,%eax
mov    %edi,%ecx
lea    0xef0(%rip),%rsi
movslq (%rsi,%rcx,4),%rcx
add    %rsi,%rcx
jmp    *%rcx
mov    %ah,0x210d
mov    %dh,0x210e
ret
mov    %ah,0x210f
mov    %dh,0x2110
ret
mov    %ah,0x2111
mov    %dh,0x2112
ret
mov    %ah,0x2113
mov    %dh,0x2114
ret

LLVM IR (-O0):
define void @set_scroll(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* %4
switch i32 %7, label %60 [
i32 0, label %8
i32 1, label %21
i32 2, label %34
i32 3, label %47
]
8: ; preds = %3
%9 = load i32, i32* %5
%10 = and i32 %9, 255
%11 = trunc i32 %10 to i8
store i8 %11, i8* inttoptr (i64 8461 to i8*)
%12 = load i32, i32* %5
%13 = lshr i32 %12, 8
%14 = trunc i32 %13 to i8
store i8 %14, i8* inttoptr (i64 8461 to i8*)
%15 = load i32, i32* %6
%16 = and i32 %15, 255
%17 = trunc i32 %16 to i8
store i8 %17, i8* inttoptr (i64 8462 to i8*)
%18 = load i32, i32* %6
%19 = lshr i32 %18, 8
%20 = trunc i32 %19 to i8
store i8 %20, i8* inttoptr (i64 8462 to i8*)
br label %60
21: ; preds = %3
%22 = load i32, i32* %5
%23 = and i32 %22, 255
%24 = trunc i32 %23 to i8
store i8 %24, i8* inttoptr (i64 8463 to i8*)
%25 = load i32, i32* %5
%26 = lshr i32 %25, 8
%27 = trunc i32 %26 to i8
store i8 %27, i8* inttoptr (i64 8463 to i8*)
%28 = load i32, i32* %6
%29 = and i32 %28, 255
%30 = trunc i32 %29 to i8
store i8 %30, i8* inttoptr (i64 8464 to i8*)
%31 = load i32, i32* %6
%32 = lshr i32 %31, 8
%33 = trunc i32 %32 to i8
store i8 %33, i8* inttoptr (i64 8464 to i8*)
br label %60
34: ; preds = %3
%35 = load i32, i32* %5
%36 = and i32 %35, 255
%37 = trunc i32 %36 to i8
store i8 %37, i8* inttoptr (i64 8465 to i8*)
%38 = load i32, i32* %5
%39 = lshr i32 %38, 8
%40 = trunc i32 %39 to i8
store i8 %40, i8* inttoptr (i64 8465 to i8*)
%41 = load i32, i32* %6
%42 = and i32 %41, 255
%43 = trunc i32 %42 to i8
store i8 %43, i8* inttoptr (i64 8466 to i8*)
%44 = load i32, i32* %6
%45 = lshr i32 %44, 8
%46 = trunc i32 %45 to i8
store i8 %46, i8* inttoptr (i64 8466 to i8*)
br label %60
47: ; preds = %3
%48 = load i32, i32* %5
%49 = and i32 %48, 255
%50 = trunc i32 %49 to i8
store i8 %50, i8* inttoptr (i64 8467 to i8*)
%51 = load i32, i32* %5
%52 = lshr i32 %51, 8
%53 = trunc i32 %52 to i8
store i8 %53, i8* inttoptr (i64 8467 to i8*)
%54 = load i32, i32* %6
%55 = and i32 %54, 255
%56 = trunc i32 %55 to i8
store i8 %56, i8* inttoptr (i64 8468 to i8*)
%57 = load i32, i32* %6
%58 = lshr i32 %57, 8
%59 = trunc i32 %58 to i8
store i8 %59, i8* inttoptr (i64 8468 to i8*)
br label %60
60: ; preds = %3, %47, %34, %21, %8
ret void
}

LLVM IR (-O2):
define void @set_scroll(i32 %0, i32 %1, i32 %2) {
switch i32 %0, label %24 [
i32 0, label %4
i32 1, label %9
i32 2, label %14
i32 3, label %19
]
4: ; preds = %3
%5 = lshr i32 %1, 8
%6 = trunc i32 %5 to i8
store i8 %6, i8* inttoptr (i64 8461 to i8*)
%7 = lshr i32 %2, 8
%8 = trunc i32 %7 to i8
store i8 %8, i8* inttoptr (i64 8462 to i8*)
br label %24
9: ; preds = %3
%10 = lshr i32 %1, 8
%11 = trunc i32 %10 to i8
store i8 %11, i8* inttoptr (i64 8463 to i8*)
%12 = lshr i32 %2, 8
%13 = trunc i32 %12 to i8
store i8 %13, i8* inttoptr (i64 8464 to i8*)
br label %24
14: ; preds = %3
%15 = lshr i32 %1, 8
%16 = trunc i32 %15 to i8
store i8 %16, i8* inttoptr (i64 8465 to i8*)
%17 = lshr i32 %2, 8
%18 = trunc i32 %17 to i8
store i8 %18, i8* inttoptr (i64 8466 to i8*)
br label %24
19: ; preds = %3
%20 = lshr i32 %1, 8
%21 = trunc i32 %20 to i8
store i8 %21, i8* inttoptr (i64 8467 to i8*)
%22 = lshr i32 %2, 8
%23 = trunc i32 %22 to i8
store i8 %23, i8* inttoptr (i64 8468 to i8*)
br label %24
24: ; preds = %3, %19, %14, %9, %4
ret void
}