#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 */
unsigned int Thrd_Get_Bits(int, int);
int /*<<< orphan*/ Thrd_motion_vector(int, int *, int *, int, int, int, int,
                                      int /*<<< orphan*/);
void Thrd_motion_vectors(int t, int (*PMV)[2][2], int *dmvector,
                         int (*motion_vertical_field_select)[2], int s,
                         int motion_vector_count, int mv_format, int h_r_size,
                         int v_r_size, int dmv, int mvscale) {
  int tmp;
  unsigned int tmp___0;
  unsigned int tmp___1;
  unsigned int tmp___2;
  {
    if (motion_vector_count == 1) {
      if (mv_format == 0) {
        if (!dmv) {
          tmp___0 = Thrd_Get_Bits(t, 1);
          tmp = (int)tmp___0;
          (*(motion_vertical_field_select + 0))[s] = tmp;
          (*(motion_vertical_field_select + 1))[s] = tmp;
        }
      }
      Thrd_motion_vector(t, (*(PMV + 0))[s], (int *)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 {
      tmp___1 = Thrd_Get_Bits(t, 1);
      (*(motion_vertical_field_select + 0))[s] = (int)tmp___1;
      Thrd_motion_vector(t, (*(PMV + 0))[s], (int *)dmvector, h_r_size,
                         v_r_size, dmv, mvscale, 0);
      tmp___2 = Thrd_Get_Bits(t, 1);
      (*(motion_vertical_field_select + 1))[s] = (int)tmp___2;
      Thrd_motion_vector(t, (*(PMV + 1))[s], (int *)dmvector, h_r_size,
                         v_r_size, dmv, mvscale, 0);
    }
    return;
  }
}


x86 assembly (clang, -O0):
<Thrd_motion_vectors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
jne    120f <Thrd_motion_vectors+0xef>
cmpl   $0x0,0x10(%rbp)
jne    11a4 <Thrd_motion_vectors+0x84>
cmpl   $0x0,0x28(%rbp)
jne    119f <Thrd_motion_vectors+0x7f>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1030 <Thrd_Get_Bits@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,0x8(%rax,%rcx,4)
jmp    11a4 <Thrd_motion_vectors+0x84>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rdx
mov    0x18(%rbp),%ecx
mov    0x20(%rbp),%r8d
mov    0x28(%rbp),%r9d
mov    0x30(%rbp),%eax
xor    %r10d,%r10d
mov    %eax,(%rsp)
movl   $0x0,0x8(%rsp)
call   1040 <Thrd_motion_vector@plt>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%edx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,0x10(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,0x14(%rax,%rcx,8)
jmp    12be <Thrd_motion_vectors+0x19e>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1030 <Thrd_Get_Bits@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rdx
mov    0x18(%rbp),%ecx
mov    0x20(%rbp),%r8d
mov    0x28(%rbp),%r9d
mov    0x30(%rbp),%eax
xor    %r10d,%r10d
mov    %eax,(%rsp)
movl   $0x0,0x8(%rsp)
call   1040 <Thrd_motion_vector@plt>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1030 <Thrd_Get_Bits@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,0x8(%rax,%rcx,4)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    $0x10,%rsi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rdx
mov    0x18(%rbp),%ecx
mov    0x20(%rbp),%r8d
mov    0x28(%rbp),%r9d
mov    0x30(%rbp),%eax
xor    %r10d,%r10d
mov    %eax,(%rsp)
movl   $0x0,0x8(%rsp)
call   1040 <Thrd_motion_vector@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Thrd_motion_vectors>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r12d
mov    %rcx,%r15
mov    %rsi,%r14
mov    %edi,%r13d
mov    0x60(%rsp),%r10d
mov    0x58(%rsp),%ebp
mov    0x50(%rsp),%r8d
mov    0x48(%rsp),%ecx
cmp    $0x1,%r9d
jne    1163 <Thrd_motion_vectors+0x43>
mov    0x40(%rsp),%eax
or     %ebp,%eax
je     11e2 <Thrd_motion_vectors+0xc2>
movslq %r12d,%rbx
jmp    120f <Thrd_motion_vectors+0xef>
mov    %r13d,%edi
mov    $0x1,%esi
mov    %rdx,%rbp
call   1030 <Thrd_Get_Bits@plt>
movslq %r12d,%rbx
mov    %eax,(%r15,%rbx,4)
lea    (%r14,%rbx,8),%rsi
mov    %r13d,%edi
mov    %rbp,%rdx
mov    0x48(%rsp),%ecx
mov    0x50(%rsp),%r8d
mov    0x58(%rsp),%r9d
push   $0x0
mov    0x68(%rsp),%eax
push   %rax
call   1040 <Thrd_motion_vector@plt>
add    $0x10,%rsp
mov    %r13d,%edi
mov    $0x1,%esi
call   1030 <Thrd_Get_Bits@plt>
mov    %eax,0x8(%r15,%rbx,4)
lea    (%r14,%rbx,8),%rsi
add    $0x10,%rsi
mov    %r13d,%edi
mov    %rbp,%rdx
mov    0x48(%rsp),%ecx
mov    0x50(%rsp),%r8d
mov    0x58(%rsp),%r9d
push   $0x0
mov    0x68(%rsp),%eax
push   %rax
call   1040 <Thrd_motion_vector@plt>
add    $0x18,%rsp
jmp    1233 <Thrd_motion_vectors+0x113>
mov    %r13d,%edi
mov    $0x1,%esi
mov    %rdx,%rbx
call   1030 <Thrd_Get_Bits@plt>
mov    0x48(%rsp),%ecx
mov    0x50(%rsp),%r8d
mov    %rbx,%rdx
mov    0x60(%rsp),%r10d
movslq %r12d,%rbx
mov    %eax,(%r15,%rbx,4)
mov    %eax,0x8(%r15,%rbx,4)
lea    (%r14,%rbx,8),%rsi
mov    %r13d,%edi
mov    %ebp,%r9d
push   $0x0
push   %r10
call   1040 <Thrd_motion_vector@plt>
add    $0x10,%rsp
mov    (%r14,%rbx,8),%rax
mov    %rax,0x10(%r14,%rbx,8)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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