#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 */
int my_decrypt(unsigned char *, unsigned char *, int);
int get_len(unsigned char *msg, int *len, int *pad) {
  unsigned char head[16 + 1];
  if (my_decrypt(msg, head, 16) == -1)
    return -1;
  *len = (int)head[5] * 255 * 255 + (int)head[7] * 255 + (int)head[11];
  *pad = (int)head[13];
  return *len;
}


x86 assembly (clang, -O0):
<get_len>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x10,%edx
call   1030 <my_decrypt@plt>
cmp    $0xffffffff,%eax
jne    114b <get_len+0x3b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1186 <get_len+0x76>
movzbl -0x3b(%rbp),%eax
imul   $0xff,%eax,%eax
imul   $0xff,%eax,%ecx
movzbl -0x39(%rbp),%eax
imul   $0xff,%eax,%eax
add    %eax,%ecx
movzbl -0x35(%rbp),%eax
add    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movzbl -0x33(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_len>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rsp,%rsi
mov    $0x10,%edx
call   1030 <my_decrypt@plt>
cmp    $0xffffffff,%eax
je     115d <get_len+0x4d>
movzbl 0x5(%rsp),%eax
imul   $0xfe01,%eax,%eax
movzbl 0x7(%rsp),%ecx
mov    %ecx,%edx
shl    $0x8,%edx
sub    %ecx,%edx
add    %eax,%edx
movzbl 0xb(%rsp),%eax
add    %edx,%eax
mov    %eax,(%rbx)
movzbl 0xd(%rsp),%eax
mov    %eax,(%r14)
mov    (%rbx),%eax
jmp    1162 <get_len+0x52>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @get_len(i8* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [17 x i8]
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%9 = load i8*, i8** %5
%10 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%11 = call i32 @my_decrypt(i8* %9, i8* %10, i32 16)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 -1, i32* %4
br label %36
14: ; preds = %3
%15 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 5
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = mul nsw i32 %17, 255
%19 = mul nsw i32 %18, 255
%20 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 7
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = mul nsw i32 %22, 255
%24 = add nsw i32 %19, %23
%25 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 11
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = add nsw i32 %24, %27
%29 = load i32*, i32** %6
store i32 %28, i32* %29
%30 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 13
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = load i32*, i32** %7
store i32 %32, i32* %33
%34 = load i32*, i32** %6
%35 = load i32, i32* %34
store i32 %35, i32* %4
br label %36
36: ; preds = %14, %13
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
define i32 @get_len(i8* %0, i32* nocapture %1, i32* nocapture writeonly %2) {
%4 = alloca [17 x i8]
%5 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%6 = call i32 @my_decrypt(i8* %0, i8* %5, i32 16)
%7 = icmp eq i32 %6, -1
br i1 %7, label %26, label %8
8: ; preds = %3
%9 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 5
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = mul nuw nsw i32 %11, 65025
%13 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 7
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = mul nuw nsw i32 %15, 255
%17 = add nuw nsw i32 %16, %12
%18 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 11
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = add nuw nsw i32 %17, %20
store i32 %21, i32* %1
%22 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 13
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
store i32 %24, i32* %2
%25 = load i32, i32* %1
br label %26
26: ; preds = %3, %8
%27 = phi i32 [ %25, %8 ], [ -1, %3 ]
ret i32 %27
}