int parse_tca_tcindex_mask(char *msg, char **mp, struct rtattr *tcindex) {
  if (RTA_PAYLOAD(tcindex) < sizeof(unsigned short)) {
    rec_log("error: %s: payload too short", __func__);
    return (1);
  }
  *mp = add_log(msg, *mp, "mask=0x%04x ", *(unsigned short *)RTA_DATA(tcindex));
  return (0);
}


x86 assembly (clang, -O0):
<parse_tca_tcindex_mask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1030 <RTA_PAYLOAD@plt>
cltq
cmp    $0x2,%rax
jae    118c <parse_tca_tcindex_mask+0x4c>
lea    0xe8e(%rip),%rdi
lea    0xea4(%rip),%rsi
mov    $0x0,%al
call   1050 <rec_log@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d6 <parse_tca_tcindex_mask+0x96>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1040 <RTA_DATA@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
cltq
movzwl (%rax),%ecx
lea    0xe76(%rip),%rdx
mov    $0x0,%al
call   1060 <add_log@plt>
movslq %eax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_tca_tcindex_mask>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebp,%ebp
mov    %rdx,%rdi
xor    %eax,%eax
call   1030 <RTA_PAYLOAD@plt>
cmp    $0x1,%eax
ja     117e <parse_tca_tcindex_mask+0x3e>
lea    0xe97(%rip),%rdi
lea    0xead(%rip),%rsi
xor    %eax,%eax
call   1050 <rec_log@plt>
mov    $0x1,%ebp
jmp    11a9 <parse_tca_tcindex_mask+0x69>
mov    (%r14),%r12
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <RTA_DATA@plt>
cltq
movzwl (%rax),%ecx
lea    0xe9d(%rip),%rdx
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <add_log@plt>
cltq
mov    %rax,(%r14)
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.rtattr = type opaque
@.str = [29 x i8] c"error: %s: payload too short\00"
@__func__.parse_tca_tcindex_mask = [23 x i8] c"parse_tca_tcindex_mask\00"
@.str.1 = [13 x i8] c"mask=0x%04x \00"
define i32 @parse_tca_tcindex_mask(i8* %0, i8** %1, %struct.rtattr* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca %struct.rtattr*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store %struct.rtattr* %2, %struct.rtattr** %7
%8 = load %struct.rtattr*, %struct.rtattr** %7
%9 = call i32 (%struct.rtattr*, ...) bitcast (i32 (...)* @RTA_PAYLOAD to i32 (%struct.rtattr*, ...)*)(%struct.rtattr* %8)
%10 = sext i32 %9 to i64
%11 = icmp ult i64 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @rec_log to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @__func__.parse_tca_tcindex_mask, i64 0, i64 0))
store i32 1, i32* %4
br label %28
14: ; preds = %3
%15 = load i8*, i8** %5
%16 = load i8**, i8*** %6
%17 = load i8*, i8** %16
%18 = load %struct.rtattr*, %struct.rtattr** %7
%19 = call i32 (%struct.rtattr*, ...) bitcast (i32 (...)* @RTA_DATA to i32 (%struct.rtattr*, ...)*)(%struct.rtattr* %18)
%20 = sext i32 %19 to i64
%21 = inttoptr i64 %20 to i16*
%22 = load i16, i16* %21
%23 = zext i16 %22 to i32
%24 = call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @add_log to i32 (i8*, i8*, i8*, i32, ...)*)(i8* %15, i8* %17, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = sext i32 %24 to i64
%26 = inttoptr i64 %25 to i8*
%27 = load i8**, i8*** %6
store i8* %26, i8** %27
store i32 0, i32* %4
br label %28
28: ; preds = %14, %12
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
%struct.rtattr = type opaque
@.str = [29 x i8] c"error: %s: payload too short\00"
@__func__.parse_tca_tcindex_mask = [23 x i8] c"parse_tca_tcindex_mask\00"
@.str.1 = [13 x i8] c"mask=0x%04x \00"
define i32 @parse_tca_tcindex_mask(i8* %0, i8** nocapture %1, %struct.rtattr* %2) {
%4 = tail call i32 (%struct.rtattr*, ...) bitcast (i32 (...)* @RTA_PAYLOAD to i32 (%struct.rtattr*, ...)*)(%struct.rtattr* %2)
%5 = icmp ult i32 %4, 2
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @rec_log to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @__func__.parse_tca_tcindex_mask, i64 0, i64 0))
br label %18
8: ; preds = %3
%9 = load i8*, i8** %1
%10 = tail call i32 (%struct.rtattr*, ...) bitcast (i32 (...)* @RTA_DATA to i32 (%struct.rtattr*, ...)*)(%struct.rtattr* %2)
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i16*
%13 = load i16, i16* %12
%14 = zext i16 %13 to i32
%15 = tail call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @add_log to i32 (i8*, i8*, i8*, i32, ...)*)(i8* %0, i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %1
br label %18
18: ; preds = %8, %6
%19 = phi i32 [ 1, %6 ], [ 0, %8 ]
ret i32 %19
}