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


x86 assembly (clang, -O0):
<BoundQuantizeMatrix>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
add    $0x100,%rcx
cmp    %rcx,%rax
jae    1176 <BoundQuantizeMatrix+0x76>
mov    -0x10(%rbp),%rax
cmpl   $0xffffff81,(%rax)
jge    1144 <BoundQuantizeMatrix+0x44>
mov    -0x10(%rbp),%rax
movl   $0xffffff81,(%rax)
jmp    1160 <BoundQuantizeMatrix+0x60>
mov    -0x10(%rbp),%rax
cmpl   $0x7f,(%rax)
jle    115b <BoundQuantizeMatrix+0x5b>
mov    -0x10(%rbp),%rax
movl   $0x7f,(%rax)
jmp    1160 <BoundQuantizeMatrix+0x60>
jmp    1165 <BoundQuantizeMatrix+0x65>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
jmp    1110 <BoundQuantizeMatrix+0x10>
pop    %rbp
ret

x86 assembly (clang, -O2):
<BoundQuantizeMatrix>:
xor    %eax,%eax
jmp    111e <BoundQuantizeMatrix+0x1e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ecx,0x4(%rdi,%rax,4)
add    $0x2,%rax
cmp    $0x40,%rax
je     1158 <BoundQuantizeMatrix+0x58>
mov    (%rdi,%rax,4),%edx
mov    $0xffffff81,%ecx
cmp    $0xffffff81,%edx
jl     1138 <BoundQuantizeMatrix+0x38>
mov    $0x7f,%ecx
cmp    $0x80,%edx
jl     113b <BoundQuantizeMatrix+0x3b>
mov    %ecx,(%rdi,%rax,4)
mov    0x4(%rdi,%rax,4),%edx
mov    $0xffffff81,%ecx
cmp    $0xffffff81,%edx
jl     1110 <BoundQuantizeMatrix+0x10>
mov    $0x7f,%ecx
cmp    $0x80,%edx
jge    1110 <BoundQuantizeMatrix+0x10>
jmp    1114 <BoundQuantizeMatrix+0x14>
ret

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

LLVM IR (-O2):
define void @BoundQuantizeMatrix(i32* nocapture %0) {
br label %2
2: ; preds = %20, %1
%3 = phi i32* [ %0, %1 ], [ %22, %20 ]
%4 = phi i64 [ 0, %1 ], [ %21, %20 ]
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, -127
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = icmp sgt i32 %5, 127
br i1 %8, label %9, label %11
9: ; preds = %7, %2
%10 = phi i32 [ -127, %2 ], [ 127, %7 ]
store i32 %10, i32* %3
br label %11
11: ; preds = %9, %7
%12 = or i64 %4, 1
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
%15 = icmp slt i32 %14, -127
br i1 %15, label %18, label %16
16: ; preds = %11
%17 = icmp sgt i32 %14, 127
br i1 %17, label %18, label %20
18: ; preds = %16, %11
%19 = phi i32 [ -127, %11 ], [ 127, %16 ]
store i32 %19, i32* %13
br label %20
20: ; preds = %18, %16
%21 = add nuw nsw i64 %4, 2
%22 = getelementptr inbounds i32, i32* %0, i64 %21
%23 = icmp eq i64 %21, 64
br i1 %23, label %24, label %2
24: ; preds = %20
ret void
}