#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 Get_Bits(int);
int /*<<< orphan*/ motion_vector(int *, int *, int, int, int, int,
                                 int /*<<< orphan*/);
void motion_vectors(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 = Get_Bits(1);
          tmp = (int)tmp___0;
          (*(motion_vertical_field_select + 0))[s] = tmp;
          (*(motion_vertical_field_select + 1))[s] = tmp;
        }
      }
      motion_vector((*(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 = Get_Bits(1);
      (*(motion_vertical_field_select + 0))[s] = (int)tmp___1;
      motion_vector((*(PMV + 0))[s], (int *)dmvector, h_r_size, v_r_size, dmv,
                    mvscale, 0);
      tmp___2 = Get_Bits(1);
      (*(motion_vertical_field_select + 1))[s] = (int)tmp___2;
      motion_vector((*(PMV + 1))[s], (int *)dmvector, h_r_size, v_r_size, dmv,
                    mvscale, 0);
    }
    return;
  }
}


x86 assembly (clang, -O0):
<motion_vectors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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    1201 <motion_vectors+0xe1>
cmpl   $0x0,-0x24(%rbp)
jne    119e <motion_vectors+0x7e>
cmpl   $0x0,0x20(%rbp)
jne    1199 <motion_vectors+0x79>
mov    $0x1,%edi
call   1040 <Get_Bits@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,0x8(%rax,%rcx,4)
jmp    119e <motion_vectors+0x7e>
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)
call   1030 <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    129a <motion_vectors+0x17a>
mov    $0x1,%edi
call   1040 <Get_Bits@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%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)
call   1030 <motion_vector@plt>
mov    $0x1,%edi
call   1040 <Get_Bits@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%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)
call   1030 <motion_vector@plt>
add    $0x40,%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    115b <motion_vectors+0x3b>
or     %r15d,%r9d
je     11cc <motion_vectors+0xac>
movslq %r12d,%rbp
jmp    11ee <motion_vectors+0xce>
mov    $0x1,%edi
mov    %edx,%r15d
call   1040 <Get_Bits@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
call   1030 <motion_vector@plt>
mov    $0x1,%edi
call   1040 <Get_Bits@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
call   1030 <motion_vector@plt>
jmp    1210 <motion_vectors+0xf0>
mov    $0x1,%edi
mov    %ecx,%ebp
call   1040 <Get_Bits@plt>
mov    0x40(%rsp),%edx
mov    %ebp,%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
call   1030 <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
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = 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
%25 = load i32, i32* %15
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %88
27: ; preds = %10
%28 = load i32, i32* %16
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %49
30: ; preds = %27
%31 = load i32, i32* %19
%32 = icmp ne i32 %31, 0
br i1 %32, label %48, label %33
33: ; preds = %30
%34 = call i32 @Get_Bits(i32 1)
store i32 %34, i32* %22
%35 = load i32, i32* %22
store i32 %35, i32* %21
%36 = load i32, i32* %21
%37 = load [2 x i32]*, [2 x i32]** %13
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %37, i64 0
%39 = load i32, i32* %14
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %38, i64 0, i64 %40
store i32 %36, i32* %41
%42 = load i32, i32* %21
%43 = load [2 x i32]*, [2 x i32]** %13
%44 = getelementptr inbounds [2 x i32], [2 x i32]* %43, i64 1
%45 = load i32, i32* %14
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %44, i64 0, i64 %46
store i32 %42, i32* %47
br label %48
48: ; preds = %33, %30
br label %49
49: ; preds = %48, %27
%50 = load [2 x [2 x i32]]*, [2 x [2 x i32]]** %11
%51 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %50, i64 0
%52 = load i32, i32* %14
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %51, i64 0, i64 %53
%55 = getelementptr inbounds [2 x i32], [2 x i32]* %54, i64 0, i64 0
%56 = load i32*, i32** %12
%57 = load i32, i32* %17
%58 = load i32, i32* %18
%59 = load i32, i32* %19
%60 = load i32, i32* %20
%61 = call i32 @motion_vector(i32* %55, i32* %56, i32 %57, i32 %58, i32 %59, i32 %60, i32 0)
%62 = load [2 x [2 x i32]]*, [2 x [2 x i32]]** %11
%63 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %62, i64 0
%64 = load i32, i32* %14
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %63, i64 0, i64 %65
%67 = getelementptr inbounds [2 x i32], [2 x i32]* %66, i64 0, i64 0
%68 = load i32, i32* %67
%69 = load [2 x [2 x i32]]*, [2 x [2 x i32]]** %11
%70 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %69, i64 1
%71 = load i32, i32* %14
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %70, i64 0, i64 %72
%74 = getelementptr inbounds [2 x i32], [2 x i32]* %73, i64 0, i64 0
store i32 %68, i32* %74
%75 = load [2 x [2 x i32]]*, [2 x [2 x i32]]** %11
%76 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %75, i64 0
%77 = load i32, i32* %14
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %76, i64 0, i64 %78
%80 = getelementptr inbounds [2 x i32], [2 x i32]* %79, i64 0, i64 1
%81 = load i32, i32* %80
%82 = load [2 x [2 x i32]]*, [2 x [2 x i32]]** %11
%83 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %82, i64 1
%84 = load i32, i32* %14
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %83, i64 0, i64 %85
%87 = getelementptr inbounds [2 x i32], [2 x i32]* %86, i64 0, i64 1
store i32 %81, i32* %87
br label %127
88: ; preds = %10
%89 = call i32 @Get_Bits(i32 1)
store i32 %89, i32* %23
%90 = load i32, i32* %23
%91 = load [2 x i32]*, [2 x i32]** %13
%92 = getelementptr inbounds [2 x i32], [2 x i32]* %91, i64 0
%93 = load i32, i32* %14
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [2 x i32], [2 x i32]* %92, i64 0, i64 %94
store i32 %90, i32* %95
%96 = load [2 x [2 x i32]]*, [2 x [2 x i32]]** %11
%97 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %96, i64 0
%98 = load i32, i32* %14
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %97, i64 0, i64 %99
%101 = getelementptr inbounds [2 x i32], [2 x i32]* %100, i64 0, i64 0
%102 = load i32*, i32** %12
%103 = load i32, i32* %17
%104 = load i32, i32* %18
%105 = load i32, i32* %19
%106 = load i32, i32* %20
%107 = call i32 @motion_vector(i32* %101, i32* %102, i32 %103, i32 %104, i32 %105, i32 %106, i32 0)
%108 = call i32 @Get_Bits(i32 1)
store i32 %108, i32* %24
%109 = load i32, i32* %24
%110 = load [2 x i32]*, [2 x i32]** %13
%111 = getelementptr inbounds [2 x i32], [2 x i32]* %110, i64 1
%112 = load i32, i32* %14
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [2 x i32], [2 x i32]* %111, i64 0, i64 %113
store i32 %109, i32* %114
%115 = load [2 x [2 x i32]]*, [2 x [2 x i32]]** %11
%116 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %115, i64 1
%117 = load i32, i32* %14
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %116, i64 0, i64 %118
%120 = getelementptr inbounds [2 x i32], [2 x i32]* %119, i64 0, i64 0
%121 = load i32*, i32** %12
%122 = load i32, i32* %17
%123 = load i32, i32* %18
%124 = load i32, i32* %19
%125 = load i32, i32* %20
%126 = call i32 @motion_vector(i32* %120, i32* %121, i32 %122, i32 %123, i32 %124, i32 %125, i32 0)
br label %127
127: ; preds = %88, %49
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 @Get_Bits(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 @motion_vector(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 @Get_Bits(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 @motion_vector(i32* %35, i32* %1, i32 %6, i32 %7, i32 %8, i32 %9, i32 0)
%37 = tail call i32 @Get_Bits(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 @motion_vector(i32* %39, i32* %1, i32 %6, i32 %7, i32 %8, i32 %9, i32 0)
br label %41
41: ; preds = %31, %22
ret void
}