#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 */
unsigned int compute_crc32(int *, int);
int iCode_encode_list(int *, int, int, unsigned char *);
int iCode_encode(int *P, int len, int tot_items, unsigned char *res) {
  int add = 0;
  unsigned h = compute_crc32(P, sizeof(int) * len);
  ((int *)res)[0] = h;
  res += add = sizeof(int);
  return add + iCode_encode_list(P, len, tot_items, res);
}


x86 assembly (clang, -O0):
<iCode_encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
call   1030 <compute_crc32@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x4,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1040 <iCode_encode_list@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iCode_encode>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbp
lea    0x0(,%r15,4),%esi
call   1030 <compute_crc32@plt>
mov    %eax,(%rbx)
add    $0x4,%rbx
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %rbx,%rcx
call   1040 <iCode_encode_list@plt>
add    $0x4,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @iCode_encode(i32* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
store i32 0, i32* %9
%11 = load i32*, i32** %5
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = mul i64 4, %13
%15 = trunc i64 %14 to i32
%16 = call i32 @compute_crc32(i32* %11, i32 %15)
store i32 %16, i32* %10
%17 = load i32, i32* %10
%18 = load i8*, i8** %8
%19 = bitcast i8* %18 to i32*
%20 = getelementptr inbounds i32, i32* %19, i64 0
store i32 %17, i32* %20
store i32 4, i32* %9
%21 = load i8*, i8** %8
%22 = getelementptr inbounds i8, i8* %21, i64 4
store i8* %22, i8** %8
%23 = load i32, i32* %9
%24 = load i32*, i32** %5
%25 = load i32, i32* %6
%26 = load i32, i32* %7
%27 = load i8*, i8** %8
%28 = call i32 @iCode_encode_list(i32* %24, i32 %25, i32 %26, i8* %27)
%29 = add nsw i32 %23, %28
ret i32 %29
}

LLVM IR (-O2):
define i32 @iCode_encode(i32* %0, i32 %1, i32 %2, i8* %3) {
%5 = shl i32 %1, 2
%6 = tail call i32 @compute_crc32(i32* %0, i32 %5)
%7 = bitcast i8* %3 to i32*
store i32 %6, i32* %7
%8 = getelementptr inbounds i8, i8* %3, i64 4
%9 = tail call i32 @iCode_encode_list(i32* %0, i32 %1, i32 %2, i8* %8)
%10 = add nsw i32 %9, 4
ret i32 %10
}