void BoundDctMatrix(int *matrix) {
  static char RoutineName[] = "BoundDctMatrix";
  int *mptr;
  if (*matrix > 2047) {
    *matrix = 2047;
  }
  for (mptr = matrix + 1; mptr < matrix + 64; mptr++) {
    if (*mptr < -1023) {
      *mptr = -1023;
    } else if (*mptr > 1023) {
      *mptr = 1023;
    }
  }
}


x86 assembly (clang, -O0):
<BoundDctMatrix>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x7ff,(%rax)
jle    1122 <BoundDctMatrix+0x22>
mov    -0x8(%rbp),%rax
movl   $0x7ff,(%rax)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
add    $0x100,%rcx
cmp    %rcx,%rax
jae    119a <BoundDctMatrix+0x9a>
mov    -0x10(%rbp),%rax
cmpl   $0xfffffc01,(%rax)
jge    1165 <BoundDctMatrix+0x65>
mov    -0x10(%rbp),%rax
movl   $0xfffffc01,(%rax)
jmp    1184 <BoundDctMatrix+0x84>
mov    -0x10(%rbp),%rax
cmpl   $0x3ff,(%rax)
jle    117f <BoundDctMatrix+0x7f>
mov    -0x10(%rbp),%rax
movl   $0x3ff,(%rax)
jmp    1184 <BoundDctMatrix+0x84>
jmp    1189 <BoundDctMatrix+0x89>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
jmp    112e <BoundDctMatrix+0x2e>
pop    %rbp
ret

x86 assembly (clang, -O2):
<BoundDctMatrix>:
cmpl   $0x800,(%rdi)
jl     110e <BoundDctMatrix+0xe>
movl   $0x7ff,(%rdi)
xor    %eax,%eax
jmp    112e <BoundDctMatrix+0x2e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ecx,0xc(%rdi,%rax,4)
add    $0x3,%rax
cmp    $0x3f,%rax
je     1192 <BoundDctMatrix+0x92>
mov    0x4(%rdi,%rax,4),%edx
mov    $0xfffffc01,%ecx
cmp    $0xfffffc01,%edx
jl     114c <BoundDctMatrix+0x4c>
mov    $0x3ff,%ecx
cmp    $0x400,%edx
jl     1150 <BoundDctMatrix+0x50>
mov    %ecx,0x4(%rdi,%rax,4)
mov    0x8(%rdi,%rax,4),%edx
mov    $0xfffffc01,%ecx
cmp    $0xfffffc01,%edx
jl     116e <BoundDctMatrix+0x6e>
mov    $0x3ff,%ecx
cmp    $0x400,%edx
jl     1172 <BoundDctMatrix+0x72>
mov    %ecx,0x8(%rdi,%rax,4)
mov    0xc(%rdi,%rax,4),%edx
mov    $0xfffffc01,%ecx
cmp    $0xfffffc01,%edx
jl     1120 <BoundDctMatrix+0x20>
mov    $0x3ff,%ecx
cmp    $0x400,%edx
jge    1120 <BoundDctMatrix+0x20>
jmp    1124 <BoundDctMatrix+0x24>
ret

LLVM IR (-O0):
@BoundDctMatrix.RoutineName = internal global [15 x i8] c"BoundDctMatrix\00"
define void @BoundDctMatrix(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = load i32, i32* %4
%6 = icmp sgt i32 %5, 2047
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load i32*, i32** %2
store i32 2047, i32* %8
br label %9
9: ; preds = %7, %1
%10 = load i32*, i32** %2
%11 = getelementptr inbounds i32, i32* %10, i64 1
store i32* %11, i32** %3
br label %12
12: ; preds = %31, %9
%13 = load i32*, i32** %3
%14 = load i32*, i32** %2
%15 = getelementptr inbounds i32, i32* %14, i64 64
%16 = icmp ult i32* %13, %15
br i1 %16, label %17, label %34
17: ; preds = %12
%18 = load i32*, i32** %3
%19 = load i32, i32* %18
%20 = icmp slt i32 %19, -1023
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i32*, i32** %3
store i32 -1023, i32* %22
br label %30
23: ; preds = %17
%24 = load i32*, i32** %3
%25 = load i32, i32* %24
%26 = icmp sgt i32 %25, 1023
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = load i32*, i32** %3
store i32 1023, i32* %28
br label %29
29: ; preds = %27, %23
br label %30
30: ; preds = %29, %21
br label %31
31: ; preds = %30
%32 = load i32*, i32** %3
%33 = getelementptr inbounds i32, i32* %32, i32 1
store i32* %33, i32** %3
br label %12
34: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @BoundDctMatrix(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = icmp sgt i32 %2, 2047
br i1 %3, label %4, label %5
4: ; preds = %1
store i32 2047, i32* %0
br label %5
5: ; preds = %4, %1
%6 = getelementptr inbounds i32, i32* %0, i64 1
br label %7
7: ; preds = %34, %5
%8 = phi i32* [ %6, %5 ], [ %36, %34 ]
%9 = phi i64 [ 1, %5 ], [ %35, %34 ]
%10 = load i32, i32* %8
%11 = icmp slt i32 %10, -1023
br i1 %11, label %14, label %12
12: ; preds = %7
%13 = icmp sgt i32 %10, 1023
br i1 %13, label %14, label %16
14: ; preds = %12, %7
%15 = phi i32 [ -1023, %7 ], [ 1023, %12 ]
store i32 %15, i32* %8
br label %16
16: ; preds = %14, %12
%17 = add nuw nsw i64 %9, 1
%18 = getelementptr inbounds i32, i32* %0, i64 %17
%19 = load i32, i32* %18
%20 = icmp slt i32 %19, -1023
br i1 %20, label %23, label %21
21: ; preds = %16
%22 = icmp sgt i32 %19, 1023
br i1 %22, label %23, label %25
23: ; preds = %21, %16
%24 = phi i32 [ -1023, %16 ], [ 1023, %21 ]
store i32 %24, i32* %18
br label %25
25: ; preds = %23, %21
%26 = add nuw nsw i64 %9, 2
%27 = getelementptr inbounds i32, i32* %0, i64 %26
%28 = load i32, i32* %27
%29 = icmp slt i32 %28, -1023
br i1 %29, label %32, label %30
30: ; preds = %25
%31 = icmp sgt i32 %28, 1023
br i1 %31, label %32, label %34
32: ; preds = %30, %25
%33 = phi i32 [ -1023, %25 ], [ 1023, %30 ]
store i32 %33, i32* %27
br label %34
34: ; preds = %32, %30
%35 = add nuw nsw i64 %9, 3
%36 = getelementptr inbounds i32, i32* %0, i64 %35
%37 = icmp eq i64 %35, 64
br i1 %37, label %38, label %7
38: ; preds = %34
ret void
}