int CMod_SurfaceContents(int oldcontents) {
  int contents = 0;
  if (oldcontents & 1)
    contents |= 1;
  if (oldcontents & 2) {
    contents |= 1;
    contents |= 0x20000000;
  }
  if (oldcontents & 8)
    contents |= 8;
  if (oldcontents & 16)
    contents |= 16;
  if (oldcontents & 32)
    contents |= 32;
  if (oldcontents & 0x8000)
    contents |= 0x8000;
  if (oldcontents & 0x10000)
    contents |= 0x10000;
  if (oldcontents & 0x20000)
    contents |= 0x20000;
  if (oldcontents & 0x1000000)
    contents |= 0x1000000;
  if (oldcontents & 0x10000000)
    contents |= 0x20000000;
  return contents;
}


x86 assembly (clang, -O0):
<CMod_SurfaceContents>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1126 <CMod_SurfaceContents+0x26>
mov    -0x8(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1149 <CMod_SurfaceContents+0x49>
mov    -0x8(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
or     $0x20000000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1161 <CMod_SurfaceContents+0x61>
mov    -0x8(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     1179 <CMod_SurfaceContents+0x79>
mov    -0x8(%rbp),%eax
or     $0x10,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     1191 <CMod_SurfaceContents+0x91>
mov    -0x8(%rbp),%eax
or     $0x20,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     11ad <CMod_SurfaceContents+0xad>
mov    -0x8(%rbp),%eax
or     $0x8000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x10000,%eax
cmp    $0x0,%eax
je     11c9 <CMod_SurfaceContents+0xc9>
mov    -0x8(%rbp),%eax
or     $0x10000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x20000,%eax
cmp    $0x0,%eax
je     11e5 <CMod_SurfaceContents+0xe5>
mov    -0x8(%rbp),%eax
or     $0x20000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1000000,%eax
cmp    $0x0,%eax
je     1201 <CMod_SurfaceContents+0x101>
mov    -0x8(%rbp),%eax
or     $0x1000000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x10000000,%eax
cmp    $0x0,%eax
je     121d <CMod_SurfaceContents+0x11d>
mov    -0x8(%rbp),%eax
or     $0x20000000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<CMod_SurfaceContents>:
mov    %edi,%eax
and    $0x1,%eax
test   $0x2,%dil
mov    $0x20000001,%ecx
cmove  %eax,%ecx
mov    %edi,%eax
and    $0x10000000,%eax
and    $0x1038038,%edi
lea    (%rdi,%rax,2),%eax
or     %ecx,%eax
ret

LLVM IR (-O0):
define i32 @CMod_SurfaceContents(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
%5 = and i32 %4, 1
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* %3
%9 = or i32 %8, 1
store i32 %9, i32* %3
br label %10
10: ; preds = %7, %1
%11 = load i32, i32* %2
%12 = and i32 %11, 2
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i32, i32* %3
%16 = or i32 %15, 1
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = or i32 %17, 536870912
store i32 %18, i32* %3
br label %19
19: ; preds = %14, %10
%20 = load i32, i32* %2
%21 = and i32 %20, 8
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i32, i32* %3
%25 = or i32 %24, 8
store i32 %25, i32* %3
br label %26
26: ; preds = %23, %19
%27 = load i32, i32* %2
%28 = and i32 %27, 16
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i32, i32* %3
%32 = or i32 %31, 16
store i32 %32, i32* %3
br label %33
33: ; preds = %30, %26
%34 = load i32, i32* %2
%35 = and i32 %34, 32
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i32, i32* %3
%39 = or i32 %38, 32
store i32 %39, i32* %3
br label %40
40: ; preds = %37, %33
%41 = load i32, i32* %2
%42 = and i32 %41, 32768
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i32, i32* %3
%46 = or i32 %45, 32768
store i32 %46, i32* %3
br label %47
47: ; preds = %44, %40
%48 = load i32, i32* %2
%49 = and i32 %48, 65536
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = load i32, i32* %3
%53 = or i32 %52, 65536
store i32 %53, i32* %3
br label %54
54: ; preds = %51, %47
%55 = load i32, i32* %2
%56 = and i32 %55, 131072
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %54
%59 = load i32, i32* %3
%60 = or i32 %59, 131072
store i32 %60, i32* %3
br label %61
61: ; preds = %58, %54
%62 = load i32, i32* %2
%63 = and i32 %62, 16777216
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %61
%66 = load i32, i32* %3
%67 = or i32 %66, 16777216
store i32 %67, i32* %3
br label %68
68: ; preds = %65, %61
%69 = load i32, i32* %2
%70 = and i32 %69, 268435456
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %68
%73 = load i32, i32* %3
%74 = or i32 %73, 536870912
store i32 %74, i32* %3
br label %75
75: ; preds = %72, %68
%76 = load i32, i32* %3
ret i32 %76
}

LLVM IR (-O2):
define i32 @CMod_SurfaceContents(i32 %0) {
%2 = and i32 %0, 1
%3 = and i32 %0, 2
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i32 %2, i32 536870913
%6 = shl i32 %0, 1
%7 = and i32 %6, 536870912
%8 = and i32 %0, 17006648
%9 = or i32 %8, %7
%10 = or i32 %9, %5
ret i32 %10
}