int extract_ssid(unsigned char *call) {
  int c, ssid;
  for (c = ssid = 0; c < 6; c++) {
    ssid |= (call[c] & 0x80) >> (c + 2);
    call[c] &= 0x7f;
  }
  return ssid;
}


x86 assembly (clang, -O0):
<extract_ssid>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x6,-0xc(%rbp)
jge    115f <extract_ssid+0x5f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
and    $0x80,%eax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
sar    %cl,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
and    $0x7f,%edx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1116 <extract_ssid+0x16>
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_ssid>:
mov    (%rdi),%al
mov    0x1(%rdi),%cl
mov    %eax,%edx
shr    $0x2,%dl
and    $0x20,%dl
and    $0x7f,%al
mov    %al,(%rdi)
mov    %ecx,%eax
shr    $0x3,%al
and    $0x10,%al
or     %dl,%al
and    $0x7f,%cl
mov    %cl,0x1(%rdi)
mov    0x2(%rdi),%cl
mov    %ecx,%edx
shr    $0x4,%dl
and    $0x8,%dl
or     %al,%dl
and    $0x7f,%cl
mov    %cl,0x2(%rdi)
mov    0x3(%rdi),%al
mov    %eax,%ecx
shr    $0x5,%cl
and    $0x4,%cl
or     %dl,%cl
and    $0x7f,%al
mov    %al,0x3(%rdi)
mov    0x4(%rdi),%al
mov    %eax,%edx
shr    $0x6,%dl
and    $0x2,%dl
or     %cl,%dl
and    $0x7f,%al
mov    %al,0x4(%rdi)
mov    0x5(%rdi),%cl
mov    %ecx,%eax
shr    $0x7,%al
or     %dl,%al
movzbl %al,%eax
and    $0x7f,%cl
mov    %cl,0x5(%rdi)
ret

LLVM IR (-O0):
define i32 @extract_ssid(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
store i32 0, i32* %3
br label %5
5: ; preds = %29, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 6
br i1 %7, label %8, label %32
8: ; preds = %5
%9 = load i8*, i8** %2
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = and i32 %14, 128
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 2
%18 = ashr i32 %15, %17
%19 = load i32, i32* %4
%20 = or i32 %19, %18
store i32 %20, i32* %4
%21 = load i8*, i8** %2
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = and i32 %26, 127
%28 = trunc i32 %27 to i8
store i8 %28, i8* %24
br label %29
29: ; preds = %8
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %5
32: ; preds = %5
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
define i32 @extract_ssid(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = lshr i8 %2, 2
%4 = and i8 %3, 32
%5 = and i8 %2, 127
store i8 %5, i8* %0
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = lshr i8 %7, 3
%9 = and i8 %8, 16
%10 = or i8 %9, %4
%11 = and i8 %7, 127
store i8 %11, i8* %6
%12 = getelementptr inbounds i8, i8* %0, i64 2
%13 = load i8, i8* %12
%14 = lshr i8 %13, 4
%15 = and i8 %14, 8
%16 = or i8 %15, %10
%17 = and i8 %13, 127
store i8 %17, i8* %12
%18 = getelementptr inbounds i8, i8* %0, i64 3
%19 = load i8, i8* %18
%20 = lshr i8 %19, 5
%21 = and i8 %20, 4
%22 = or i8 %21, %16
%23 = and i8 %19, 127
store i8 %23, i8* %18
%24 = getelementptr inbounds i8, i8* %0, i64 4
%25 = load i8, i8* %24
%26 = lshr i8 %25, 6
%27 = and i8 %26, 2
%28 = or i8 %27, %22
%29 = and i8 %25, 127
store i8 %29, i8* %24
%30 = getelementptr inbounds i8, i8* %0, i64 5
%31 = load i8, i8* %30
%32 = lshr i8 %31, 7
%33 = or i8 %32, %28
%34 = zext i8 %33 to i32
%35 = and i8 %31, 127
store i8 %35, i8* %30
ret i32 %34
}