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


x86 assembly (clang, -O0):
<FlatBoundQuantizeMatrix>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0xfe,(%rax)
jle    1127 <FlatBoundQuantizeMatrix+0x27>
mov    -0x8(%rbp),%rax
movl   $0xfe,(%rax)
jmp    1143 <FlatBoundQuantizeMatrix+0x43>
mov    -0x8(%rbp),%rax
cmpl   $0x1,(%rax)
jge    113e <FlatBoundQuantizeMatrix+0x3e>
mov    -0x8(%rbp),%rax
movl   $0x1,(%rax)
jmp    1143 <FlatBoundQuantizeMatrix+0x43>
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    11b5 <FlatBoundQuantizeMatrix+0xb5>
mov    -0x10(%rbp),%rax
cmpl   $0xffffff81,(%rax)
jge    1183 <FlatBoundQuantizeMatrix+0x83>
mov    -0x10(%rbp),%rax
movl   $0xffffff81,(%rax)
jmp    119f <FlatBoundQuantizeMatrix+0x9f>
mov    -0x10(%rbp),%rax
cmpl   $0x7f,(%rax)
jle    119a <FlatBoundQuantizeMatrix+0x9a>
mov    -0x10(%rbp),%rax
movl   $0x7f,(%rax)
jmp    119f <FlatBoundQuantizeMatrix+0x9f>
jmp    11a4 <FlatBoundQuantizeMatrix+0xa4>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
jmp    114f <FlatBoundQuantizeMatrix+0x4f>
pop    %rbp
ret

x86 assembly (clang, -O2):
<FlatBoundQuantizeMatrix>:
mov    (%rdi),%ecx
mov    $0xfe,%eax
cmp    $0xfe,%ecx
jg     1118 <FlatBoundQuantizeMatrix+0x18>
test   %ecx,%ecx
jg     111a <FlatBoundQuantizeMatrix+0x1a>
mov    $0x1,%eax
mov    %eax,(%rdi)
xor    %eax,%eax
jmp    112e <FlatBoundQuantizeMatrix+0x2e>
xchg   %ax,%ax
mov    %ecx,0xc(%rdi,%rax,4)
add    $0x3,%rax
cmp    $0x3f,%rax
je     1189 <FlatBoundQuantizeMatrix+0x89>
mov    0x4(%rdi,%rax,4),%edx
mov    $0xffffff81,%ecx
cmp    $0xffffff81,%edx
jl     1149 <FlatBoundQuantizeMatrix+0x49>
mov    $0x7f,%ecx
cmp    $0x80,%edx
jl     114d <FlatBoundQuantizeMatrix+0x4d>
mov    %ecx,0x4(%rdi,%rax,4)
mov    0x8(%rdi,%rax,4),%edx
mov    $0xffffff81,%ecx
cmp    $0xffffff81,%edx
jl     1168 <FlatBoundQuantizeMatrix+0x68>
mov    $0x7f,%ecx
cmp    $0x80,%edx
jl     116c <FlatBoundQuantizeMatrix+0x6c>
mov    %ecx,0x8(%rdi,%rax,4)
mov    0xc(%rdi,%rax,4),%edx
mov    $0xffffff81,%ecx
cmp    $0xffffff81,%edx
jl     1120 <FlatBoundQuantizeMatrix+0x20>
mov    $0x7f,%ecx
cmp    $0x80,%edx
jge    1120 <FlatBoundQuantizeMatrix+0x20>
jmp    1124 <FlatBoundQuantizeMatrix+0x24>
ret

LLVM IR (-O0):
@FlatBoundQuantizeMatrix.RoutineName = internal global [24 x i8] c"FlatBoundQuantizeMatrix\00"
define void @FlatBoundQuantizeMatrix(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, 254
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load i32*, i32** %2
store i32 254, i32* %8
br label %16
9: ; preds = %1
%10 = load i32*, i32** %2
%11 = load i32, i32* %10
%12 = icmp slt i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = load i32*, i32** %2
store i32 1, i32* %14
br label %15
15: ; preds = %13, %9
br label %16
16: ; preds = %15, %7
%17 = load i32*, i32** %2
%18 = getelementptr inbounds i32, i32* %17, i64 1
store i32* %18, i32** %3
br label %19
19: ; preds = %38, %16
%20 = load i32*, i32** %3
%21 = load i32*, i32** %2
%22 = getelementptr inbounds i32, i32* %21, i64 64
%23 = icmp ult i32* %20, %22
br i1 %23, label %24, label %41
24: ; preds = %19
%25 = load i32*, i32** %3
%26 = load i32, i32* %25
%27 = icmp slt i32 %26, -127
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = load i32*, i32** %3
store i32 -127, i32* %29
br label %37
30: ; preds = %24
%31 = load i32*, i32** %3
%32 = load i32, i32* %31
%33 = icmp sgt i32 %32, 127
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = load i32*, i32** %3
store i32 127, i32* %35
br label %36
36: ; preds = %34, %30
br label %37
37: ; preds = %36, %28
br label %38
38: ; preds = %37
%39 = load i32*, i32** %3
%40 = getelementptr inbounds i32, i32* %39, i32 1
store i32* %40, i32** %3
br label %19
41: ; preds = %19
ret void
}

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