#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 */
typedef int uint8_t;

/* Variables and functions */
size_t getUnpaddedLength(uint8_t *message) {
  int i;
  for (i = 15; message[i] == 0x00 && i > 0; --i)
    ;
  if (message[i] == 0x80)
    return i;
  else
    return -1;
}


x86 assembly (clang, -O0):
<getUnpaddedLength>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movl   $0xf,-0x14(%rbp)
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rdx
xor    %eax,%eax
cmpl   $0x0,(%rcx,%rdx,4)
mov    %al,-0x15(%rbp)
jne    1130 <getUnpaddedLength+0x30>
cmpl   $0x0,-0x14(%rbp)
setg   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1140 <getUnpaddedLength+0x40>
jmp    1153 <getUnpaddedLength+0x53>
jmp    1145 <getUnpaddedLength+0x45>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    110f <getUnpaddedLength+0xf>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x80,(%rax,%rcx,4)
jne    1175 <getUnpaddedLength+0x75>
movslq -0x14(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    117d <getUnpaddedLength+0x7d>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<getUnpaddedLength>:
mov    $0x10,%eax
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x1(%rax),%rcx
mov    %ecx,%edx
mov    (%rdi,%rdx,4),%edx
test   %edx,%edx
jne    1125 <getUnpaddedLength+0x25>
cmp    $0x1,%eax
mov    %rcx,%rax
jne    1110 <getUnpaddedLength+0x10>
cmp    $0x80,%edx
mov    $0xffffffffffffffff,%rax
cmove  %rcx,%rax
ret

LLVM IR (-O0):
define i64 @getUnpaddedLength(i32* %0) {
%2 = alloca i64
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 15, i32* %4
br label %5
5: ; preds = %18, %1
%6 = load i32*, i32** %3
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %6, i64 %8
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %5
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 0
br label %15
15: ; preds = %12, %5
%16 = phi i1 [ false, %5 ], [ %14, %12 ]
br i1 %16, label %17, label %21
17: ; preds = %15
br label %18
18: ; preds = %17
%19 = load i32, i32* %4
%20 = add nsw i32 %19, -1
store i32 %20, i32* %4
br label %5
21: ; preds = %15
%22 = load i32*, i32** %3
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 128
br i1 %27, label %28, label %31
28: ; preds = %21
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
store i64 %30, i64* %2
br label %32
31: ; preds = %21
store i64 -1, i64* %2
br label %32
32: ; preds = %31, %28
%33 = load i64, i64* %2
ret i64 %33
}

LLVM IR (-O2):
define i64 @getUnpaddedLength(i32* nocapture %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i32 [ 15, %1 ], [ %10, %2 ]
%4 = zext i32 %3 to i64
%5 = getelementptr inbounds i32, i32* %0, i64 %4
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 0
%8 = icmp ne i32 %3, 0
%9 = select i1 %7, i1 %8, i1 false
%10 = add nsw i32 %3, -1
br i1 %9, label %2, label %11
11: ; preds = %2
%12 = zext i32 %3 to i64
%13 = icmp eq i32 %6, 128
%14 = select i1 %13, i64 %12, i64 -1
ret i64 %14
}