#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 /*<<< orphan*/ memcpy(int *, int const *, int);
int numLimbs(int const *);
int *CopyPolynomialFixedCoeffSize(int *dest, const int *src, int polyDegree,
                                  int coeffSize) {
  int *ptrDest = dest;
  const int *ptrSrc = src;
  for (int currentDegree = 0; currentDegree <= polyDegree; currentDegree++) {
    int numLength = numLimbs(ptrSrc) + 1;
    int lenBytes = numLength * (int)sizeof(int);
    (void)memcpy(ptrDest, ptrSrc, lenBytes);
    ptrSrc += coeffSize;
    ptrDest += coeffSize;
  }
  return ptrDest;
}


x86 assembly (clang, -O0):
<CopyPolynomialFixedCoeffSize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11b9 <CopyPolynomialFixedCoeffSize+0x99>
mov    -0x28(%rbp),%rdi
call   1040 <numLimbs@plt>
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    114d <CopyPolynomialFixedCoeffSize+0x2d>
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CopyPolynomialFixedCoeffSize>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
test   %edx,%edx
js     1166 <CopyPolynomialFixedCoeffSize+0x46>
mov    %edx,%r14d
mov    %rsi,%rbp
movslq %ecx,%r15
shl    $0x2,%r15
add    $0x1,%r14d
nop
mov    %rbp,%rdi
call   1040 <numLimbs@plt>
lea    0x4(,%rax,4),%edx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <memcpy@plt>
add    %r15,%rbx
add    %r15,%rbp
add    $0xffffffff,%r14d
jne    1140 <CopyPolynomialFixedCoeffSize+0x20>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32* @CopyPolynomialFixedCoeffSize(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%14 = load i32*, i32** %5
store i32* %14, i32** %9
%15 = load i32*, i32** %6
store i32* %15, i32** %10
store i32 0, i32* %11
br label %16
16: ; preds = %38, %4
%17 = load i32, i32* %11
%18 = load i32, i32* %7
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %41
20: ; preds = %16
%21 = load i32*, i32** %10
%22 = call i32 @numLimbs(i32* %21)
%23 = add nsw i32 %22, 1
store i32 %23, i32* %12
%24 = load i32, i32* %12
%25 = mul nsw i32 %24, 4
store i32 %25, i32* %13
%26 = load i32*, i32** %9
%27 = load i32*, i32** %10
%28 = load i32, i32* %13
%29 = call i32 @memcpy(i32* %26, i32* %27, i32 %28)
%30 = load i32, i32* %8
%31 = load i32*, i32** %10
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds i32, i32* %31, i64 %32
store i32* %33, i32** %10
%34 = load i32, i32* %8
%35 = load i32*, i32** %9
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds i32, i32* %35, i64 %36
store i32* %37, i32** %9
br label %38
38: ; preds = %20
%39 = load i32, i32* %11
%40 = add nsw i32 %39, 1
store i32 %40, i32* %11
br label %16
41: ; preds = %16
%42 = load i32*, i32** %9
ret i32* %42
}

LLVM IR (-O2):
define i32* @CopyPolynomialFixedCoeffSize(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = icmp slt i32 %2, 0
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = sext i32 %3 to i64
br label %10
8: ; preds = %10, %4
%9 = phi i32* [ %0, %4 ], [ %19, %10 ]
ret i32* %9
10: ; preds = %6, %10
%11 = phi i32* [ %0, %6 ], [ %19, %10 ]
%12 = phi i32* [ %1, %6 ], [ %18, %10 ]
%13 = phi i32 [ 0, %6 ], [ %20, %10 ]
%14 = tail call i32 @numLimbs(i32* %12)
%15 = shl i32 %14, 2
%16 = add i32 %15, 4
%17 = tail call i32 @memcpy(i32* %11, i32* %12, i32 %16)
%18 = getelementptr inbounds i32, i32* %12, i64 %7
%19 = getelementptr inbounds i32, i32* %11, i64 %7
%20 = add nuw i32 %13, 1
%21 = icmp eq i32 %13, %2
br i1 %21, label %8, label %10
}