void motion_vectors(PMV, dmvector, mv_field_sel, s, mv_count, mv_format,
                    h_r_size, v_r_size, dmv, mvscale) int PMV[2][2][2];
int dmvector[2];
int mv_field_sel[2][2];
int s, mv_count, mv_format, h_r_size, v_r_size, dmv, mvscale;
{
  if (mv_count == 1) {
    if (mv_format == 0 && !dmv) {
      mv_field_sel[1][s] = mv_field_sel[0][s] = getbits(1);
    }
    motion_vector(PMV[0][s], dmvector, h_r_size, v_r_size, dmv, mvscale, 0);
    PMV[1][s][0] = PMV[0][s][0];
    PMV[1][s][1] = PMV[0][s][1];
  } else {
    mv_field_sel[0][s] = getbits(1);
    motion_vector(PMV[0][s], dmvector, h_r_size, v_r_size, dmv, mvscale, 0);
    mv_field_sel[1][s] = getbits(1);
    motion_vector(PMV[1][s], dmvector, h_r_size, v_r_size, dmv, mvscale, 0);
  }
}


x86 assembly (clang, -O0):
<motion_vectors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
cmpl   $0x1,-0x20(%rbp)
jne    11f3 <motion_vectors+0xd3>
cmpl   $0x0,-0x24(%rbp)
jne    118e <motion_vectors+0x6e>
cmpl   $0x0,0x20(%rbp)
jne    118e <motion_vectors+0x6e>
mov    $0x1,%edi
mov    $0x0,%al
call   1030 <getbits@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,0x8(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    0x10(%rbp),%edx
mov    0x18(%rbp),%ecx
mov    0x20(%rbp),%r8d
mov    0x28(%rbp),%r9d
xor    %eax,%eax
movl   $0x0,(%rsp)
mov    $0x0,%al
call   1040 <motion_vector@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,0x10(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,0x14(%rax,%rcx,8)
jmp    128c <motion_vectors+0x16c>
mov    $0x1,%edi
mov    $0x0,%al
call   1030 <getbits@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    0x10(%rbp),%edx
mov    0x18(%rbp),%ecx
mov    0x20(%rbp),%r8d
mov    0x28(%rbp),%r9d
xor    %eax,%eax
movl   $0x0,(%rsp)
mov    $0x0,%al
call   1040 <motion_vector@plt>
mov    $0x1,%edi
mov    $0x0,%al
call   1030 <getbits@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,0x8(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
add    $0x10,%rdi
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    0x10(%rbp),%edx
mov    0x18(%rbp),%ecx
mov    0x20(%rbp),%r8d
mov    0x28(%rbp),%r9d
xor    %eax,%eax
movl   $0x0,(%rsp)
mov    $0x0,%al
call   1040 <motion_vector@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<motion_vectors>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%rbx
mov    0x58(%rsp),%eax
mov    0x50(%rsp),%r15d
mov    0x48(%rsp),%ecx
mov    0x40(%rsp),%edx
cmp    $0x1,%r8d
jne    115f <motion_vectors+0x3f>
or     %r15d,%r9d
je     11d8 <motion_vectors+0xb8>
movslq %r12d,%rbp
jmp    11fc <motion_vectors+0xdc>
mov    $0x1,%edi
xor    %eax,%eax
mov    %edx,%r15d
call   1030 <getbits@plt>
movslq %r12d,%rbp
mov    %eax,(%r14,%rbp,4)
lea    (%rbx,%rbp,8),%rdi
movl   $0x0,(%rsp)
mov    %r13,%rsi
mov    %r15d,%edx
mov    0x48(%rsp),%ecx
mov    0x50(%rsp),%r8d
mov    0x58(%rsp),%r9d
xor    %eax,%eax
call   1040 <motion_vector@plt>
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <getbits@plt>
mov    %eax,0x8(%r14,%rbp,4)
lea    (%rbx,%rbp,8),%rdi
add    $0x10,%rdi
movl   $0x0,(%rsp)
mov    %r13,%rsi
mov    %r15d,%edx
mov    0x48(%rsp),%ecx
mov    0x50(%rsp),%r8d
mov    0x58(%rsp),%r9d
xor    %eax,%eax
call   1040 <motion_vector@plt>
jmp    1220 <motion_vectors+0x100>
mov    $0x1,%edi
xor    %eax,%eax
mov    %edx,%ebp
call   1030 <getbits@plt>
mov    %ebp,%edx
mov    0x48(%rsp),%ecx
movslq %r12d,%rbp
mov    %eax,(%r14,%rbp,4)
mov    %eax,0x8(%r14,%rbp,4)
mov    0x58(%rsp),%eax
lea    (%rbx,%rbp,8),%rdi
movl   $0x0,(%rsp)
mov    %r13,%rsi
mov    %r15d,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1040 <motion_vector@plt>
mov    (%rbx,%rbp,8),%rax
mov    %rax,0x10(%rbx,%rbp,8)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @motion_vectors([2 x [2 x i32]]* %0, i32* %1, [2 x i32]* %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9) {
%11 = alloca [2 x [2 x i32]]*
%12 = alloca i32*
%13 = alloca [2 x i32]*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store [2 x [2 x i32]]* %0, [2 x [2 x i32]]** %11
store i32* %1, i32** %12
store [2 x i32]* %2, [2 x i32]** %13
store i32 %3, i32* %14
store i32 %4, i32* %15
store i32 %5, i32* %16
store i32 %6, i32* %17
store i32 %7, i32* %18
store i32 %8, i32* %19
store i32 %9, i32* %20
%21 = load i32, i32* %15
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %80
23: ; preds = %10
%24 = load i32, i32* %16
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %41
26: ; preds = %23
%27 = load i32, i32* %19
%28 = icmp ne i32 %27, 0
br i1 %28, label %41, label %29
29: ; preds = %26
%30 = call i32 (i32, ...) bitcast (i32 (...)* @getbits to i32 (i32, ...)*)(i32 1)
%31 = load [2 x i32]*, [2 x i32]** %13
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %31, i64 0
%33 = load i32, i32* %14
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %32, i64 0, i64 %34
store i32 %30, i32* %35
%36 = load [2 x i32]*, [2 x i32]** %13
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %36, i64 1
%38 = load i32, i32* %14
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %37, i64 0, i64 %39
store i32 %30, i32* %40
br label %41
41: ; preds = %29, %26, %23
%42 = load [2 x [2 x i32]]*, [2 x [2 x i32]]** %11
%43 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %42, i64 0
%44 = load i32, i32* %14
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %43, i64 0, i64 %45
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %46, i64 0, i64 0
%48 = load i32*, i32** %12
%49 = load i32, i32* %17
%50 = load i32, i32* %18
%51 = load i32, i32* %19
%52 = load i32, i32* %20
%53 = call i32 (i32*, i32*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @motion_vector to i32 (i32*, i32*, i32, i32, i32, i32, i32, ...)*)(i32* %47, i32* %48, i32 %49, i32 %50, i32 %51, i32 %52, i32 0)
%54 = load [2 x [2 x i32]]*, [2 x [2 x i32]]** %11
%55 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %54, i64 0
%56 = load i32, i32* %14
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %55, i64 0, i64 %57
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %58, i64 0, i64 0
%60 = load i32, i32* %59
%61 = load [2 x [2 x i32]]*, [2 x [2 x i32]]** %11
%62 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %61, i64 1
%63 = load i32, i32* %14
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %62, i64 0, i64 %64
%66 = getelementptr inbounds [2 x i32], [2 x i32]* %65, i64 0, i64 0
store i32 %60, i32* %66
%67 = load [2 x [2 x i32]]*, [2 x [2 x i32]]** %11
%68 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %67, i64 0
%69 = load i32, i32* %14
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %68, i64 0, i64 %70
%72 = getelementptr inbounds [2 x i32], [2 x i32]* %71, i64 0, i64 1
%73 = load i32, i32* %72
%74 = load [2 x [2 x i32]]*, [2 x [2 x i32]]** %11
%75 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %74, i64 1
%76 = load i32, i32* %14
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %75, i64 0, i64 %77
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %78, i64 0, i64 1
store i32 %73, i32* %79
br label %117
80: ; preds = %10
%81 = call i32 (i32, ...) bitcast (i32 (...)* @getbits to i32 (i32, ...)*)(i32 1)
%82 = load [2 x i32]*, [2 x i32]** %13
%83 = getelementptr inbounds [2 x i32], [2 x i32]* %82, i64 0
%84 = load i32, i32* %14
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [2 x i32], [2 x i32]* %83, i64 0, i64 %85
store i32 %81, i32* %86
%87 = load [2 x [2 x i32]]*, [2 x [2 x i32]]** %11
%88 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %87, i64 0
%89 = load i32, i32* %14
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %88, i64 0, i64 %90
%92 = getelementptr inbounds [2 x i32], [2 x i32]* %91, i64 0, i64 0
%93 = load i32*, i32** %12
%94 = load i32, i32* %17
%95 = load i32, i32* %18
%96 = load i32, i32* %19
%97 = load i32, i32* %20
%98 = call i32 (i32*, i32*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @motion_vector to i32 (i32*, i32*, i32, i32, i32, i32, i32, ...)*)(i32* %92, i32* %93, i32 %94, i32 %95, i32 %96, i32 %97, i32 0)
%99 = call i32 (i32, ...) bitcast (i32 (...)* @getbits to i32 (i32, ...)*)(i32 1)
%100 = load [2 x i32]*, [2 x i32]** %13
%101 = getelementptr inbounds [2 x i32], [2 x i32]* %100, i64 1
%102 = load i32, i32* %14
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [2 x i32], [2 x i32]* %101, i64 0, i64 %103
store i32 %99, i32* %104
%105 = load [2 x [2 x i32]]*, [2 x [2 x i32]]** %11
%106 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %105, i64 1
%107 = load i32, i32* %14
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %106, i64 0, i64 %108
%110 = getelementptr inbounds [2 x i32], [2 x i32]* %109, i64 0, i64 0
%111 = load i32*, i32** %12
%112 = load i32, i32* %17
%113 = load i32, i32* %18
%114 = load i32, i32* %19
%115 = load i32, i32* %20
%116 = call i32 (i32*, i32*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @motion_vector to i32 (i32*, i32*, i32, i32, i32, i32, i32, ...)*)(i32* %110, i32* %111, i32 %112, i32 %113, i32 %114, i32 %115, i32 0)
br label %117
117: ; preds = %80, %41
ret void
}

LLVM IR (-O2):
define void @motion_vectors([2 x [2 x i32]]* %0, i32* %1, [2 x i32]* nocapture writeonly %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9) {
%11 = icmp eq i32 %4, 1
br i1 %11, label %12, label %31
12: ; preds = %10
%13 = or i32 %8, %5
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = sext i32 %3 to i64
br label %22
17: ; preds = %12
%18 = tail call i32 (i32, ...) bitcast (i32 (...)* @getbits to i32 (i32, ...)*)(i32 1)
%19 = sext i32 %3 to i64
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 %19
store i32 %18, i32* %20
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 1, i64 %19
store i32 %18, i32* %21
br label %22
22: ; preds = %15, %17
%23 = phi i64 [ %16, %15 ], [ %19, %17 ]
%24 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %0, i64 0, i64 %23, i64 0
%25 = tail call i32 (i32*, i32*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @motion_vector to i32 (i32*, i32*, i32, i32, i32, i32, i32, ...)*)(i32* %24, i32* %1, i32 %6, i32 %7, i32 %8, i32 %9, i32 0)
%26 = load i32, i32* %24
%27 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %0, i64 1, i64 %23, i64 0
store i32 %26, i32* %27
%28 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %0, i64 0, i64 %23, i64 1
%29 = load i32, i32* %28
%30 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %0, i64 1, i64 %23, i64 1
store i32 %29, i32* %30
br label %41
31: ; preds = %10
%32 = tail call i32 (i32, ...) bitcast (i32 (...)* @getbits to i32 (i32, ...)*)(i32 1)
%33 = sext i32 %3 to i64
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 %33
store i32 %32, i32* %34
%35 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %0, i64 0, i64 %33, i64 0
%36 = tail call i32 (i32*, i32*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @motion_vector to i32 (i32*, i32*, i32, i32, i32, i32, i32, ...)*)(i32* %35, i32* %1, i32 %6, i32 %7, i32 %8, i32 %9, i32 0)
%37 = tail call i32 (i32, ...) bitcast (i32 (...)* @getbits to i32 (i32, ...)*)(i32 1)
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 1, i64 %33
store i32 %37, i32* %38
%39 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %0, i64 1, i64 %33, i64 0
%40 = tail call i32 (i32*, i32*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @motion_vector to i32 (i32*, i32*, i32, i32, i32, i32, i32, ...)*)(i32* %39, i32* %1, i32 %6, i32 %7, i32 %8, i32 %9, i32 0)
br label %41
41: ; preds = %31, %22
ret void
}