#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 scalar_t__ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ addCpy(scalar_t__ *, scalar_t__ *, scalar_t__ *);
int /*<<< orphan*/ nullcell(scalar_t__ *);
void mul(uint16_t *mem, uint16_t *dst, uint16_t *src, uint16_t *mul) {
  uint16_t *tmp = mem + 1;
  uint16_t *pos = mem;
  nullcell(pos);
  addCpy(dst, src, pos);
  (*mul)--;
  while (*mul) {
    addCpy(dst, pos, pos + 1);
    pos++;
    (*mul)--;
  }
}


x86 assembly (clang, -O0):
<mul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <nullcell@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1040 <addCpy@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11b6 <mul+0x96>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x30(%rbp),%rdx
add    $0x8,%rdx
call   1040 <addCpy@plt>
mov    -0x30(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,(%rax)
jmp    1174 <mul+0x54>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mul>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <nullcell@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <addCpy@plt>
addq   $0xffffffffffffffff,(%r14)
je     116b <mul+0x4b>
nopl   (%rax)
lea    0x8(%rbx),%r12
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1040 <addCpy@plt>
addq   $0xffffffffffffffff,(%r14)
mov    %r12,%rbx
jne    1150 <mul+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @mul(i64* %0, i64* %1, i64* %2, i64* nocapture %3) {
%5 = tail call i32 @nullcell(i64* %0)
%6 = tail call i32 @addCpy(i64* %1, i64* %2, i64* %0)
%7 = load i64, i64* %3
%8 = add nsw i64 %7, -1
store i64 %8, i64* %3
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %4, %10
%11 = phi i64* [ %12, %10 ], [ %0, %4 ]
%12 = getelementptr inbounds i64, i64* %11, i64 1
%13 = tail call i32 @addCpy(i64* %1, i64* %11, i64* %12)
%14 = load i64, i64* %3
%15 = add nsw i64 %14, -1
store i64 %15, i64* %3
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %10
17: ; preds = %10, %4
ret void
}