#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 main(void) {
  unsigned int mask = 0;
  unsigned int vlan = 20;
  unsigned int vlanlow = 1;
  unsigned int vlanhigh = 4095;
  unsigned long test = 0;
  unsigned int crap = 2102;
  printf("\n\nVLAN test bitmask\n\n");
  test = (1 << vlan) | (1 << vlanlow) | (1 << vlanhigh);
  printf("stored value is %lx, vlan value is %lu, is true is %d\n", test, vlan,
         (test & (1 << vlan)));
  printf("stored value is %lx, vlan value is %lu, is true is %d\n", test,
         vlanlow, (test & (1 << vlanlow)));
  printf("stored value is %lx, vlan value is %lu, is true is %lu\n", test,
         vlanhigh, (test & (1 << vlanhigh)));
  printf("stored value is %lx, vlan value is %lu, is true is %lu\n", test, crap,
         (test & (1 << crap)));
  test ^= (1 << vlan);
  printf("\n\nstored value is %lx, vlan value is %lu, is true is %d\n", test,
         vlan, (test & (1 << vlan)));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x14,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0xfff,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x836,-0x1c(%rbp)
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    -0xc(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    -0x48(%rbp),%rcx
cltq
and    %rax,%rcx
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0xc(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    -0x40(%rbp),%rcx
cltq
and    %rax,%rcx
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    -0x38(%rbp),%rcx
cltq
and    %rax,%rcx
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    -0x30(%rbp),%rcx
cltq
and    %rax,%rcx
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
cltq
xor    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    -0x28(%rbp),%rcx
cltq
and    %rax,%rcx
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xf49(%rip),%rdi
call   1030 <puts@plt>
lea    0xf06(%rip),%rbx
mov    %rbx,%rdi
mov    $0x14,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea7(%rip),%rbx
mov    %rbx,%rdi
mov    $0xfff,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x836,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeba(%rip),%rdi
mov    $0x14,%edx
xor    %eax,%eax
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"\0A\0AVLAN test bitmask\0A\0A\00"
@.str.1 = [55 x i8] c"stored value is %lx, vlan value is %lu, is true is %d\0A\00"
@.str.2 = [56 x i8] c"stored value is %lx, vlan value is %lu, is true is %lu\0A\00"
@.str.3 = [57 x i8] c"\0A\0Astored value is %lx, vlan value is %lu, is true is %d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32
store i32 0, i32* %1
store i32 20, i32* %2
store i32 1, i32* %3
store i32 4095, i32* %4
store i64 0, i64* %5
store i32 2102, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %2
%9 = shl i32 1, %8
%10 = load i32, i32* %3
%11 = shl i32 1, %10
%12 = or i32 %9, %11
%13 = load i32, i32* %4
%14 = shl i32 1, %13
%15 = or i32 %12, %14
%16 = sext i32 %15 to i64
store i64 %16, i64* %5
%17 = load i64, i64* %5
%18 = load i32, i32* %2
%19 = load i64, i64* %5
%20 = load i32, i32* %2
%21 = shl i32 1, %20
%22 = sext i32 %21 to i64
%23 = and i64 %19, %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i64 %17, i32 %18, i64 %23)
%25 = load i64, i64* %5
%26 = load i32, i32* %3
%27 = load i64, i64* %5
%28 = load i32, i32* %3
%29 = shl i32 1, %28
%30 = sext i32 %29 to i64
%31 = and i64 %27, %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i64 %25, i32 %26, i64 %31)
%33 = load i64, i64* %5
%34 = load i32, i32* %4
%35 = load i64, i64* %5
%36 = load i32, i32* %4
%37 = shl i32 1, %36
%38 = sext i32 %37 to i64
%39 = and i64 %35, %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i64 %33, i32 %34, i64 %39)
%41 = load i64, i64* %5
%42 = load i32, i32* %6
%43 = load i64, i64* %5
%44 = load i32, i32* %6
%45 = shl i32 1, %44
%46 = sext i32 %45 to i64
%47 = and i64 %43, %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i64 %41, i32 %42, i64 %47)
%49 = load i32, i32* %2
%50 = shl i32 1, %49
%51 = sext i32 %50 to i64
%52 = load i64, i64* %5
%53 = xor i64 %52, %51
store i64 %53, i64* %5
%54 = load i64, i64* %5
%55 = load i32, i32* %2
%56 = load i64, i64* %5
%57 = load i32, i32* %2
%58 = shl i32 1, %57
%59 = sext i32 %58 to i64
%60 = and i64 %56, %59
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0), i64 %54, i32 %55, i64 %60)
ret void
}

LLVM IR (-O2):
@.str.1 = [55 x i8] c"stored value is %lx, vlan value is %lu, is true is %d\0A\00"
@.str.2 = [56 x i8] c"stored value is %lx, vlan value is %lu, is true is %lu\0A\00"
@.str.3 = [57 x i8] c"\0A\0Astored value is %lx, vlan value is %lu, is true is %d\0A\00"
@str = [21 x i8] c"\0A\0AVLAN test bitmask\0A\00"
define void @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i64 poison, i32 20, i64 poison)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i64 poison, i32 1, i64 poison)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i64 poison, i32 4095, i64 poison)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i64 poison, i32 2102, i64 poison)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0), i64 poison, i32 20, i64 poison)
ret void
}