#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef TYPE_1__ *mpz_srcptr;
typedef int mp_size_t;
typedef int /*<<< orphan*/ mp_limb_t;
struct TYPE_3__ {
  scalar_t__ _mp_size;
  int /*<<< orphan*/ _mp_d;
};
typedef int NLIMBS;
typedef int /*<<< orphan*/ DST;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ memset(int /*<<< orphan*/, int /*<<< orphan*/, int);
void MPN_SET_MPZ(mp_limb_t *DST, size_t NLIMBS, mpz_srcptr SRC) {
  mp_size_t r =
      (((size_t)((((SRC)->_mp_size)) >= 0 ? (((SRC)->_mp_size))
                                          : -(((SRC)->_mp_size)))) < (NLIMBS)
           ? ((size_t)((((SRC)->_mp_size)) >= 0 ? (((SRC)->_mp_size))
                                                : -(((SRC)->_mp_size))))
           : (NLIMBS));
  memcpy((DST), ((SRC)->_mp_d), r * sizeof(mp_limb_t));
  memset((DST) + ((SRC)->_mp_size), 0, ((NLIMBS)-r) * sizeof(mp_limb_t));
}


x86 assembly (clang, -O0):
<MPN_SET_MPZ>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jl     1152 <MPN_SET_MPZ+0x32>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    115f <MPN_SET_MPZ+0x3f>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
sub    (%rcx),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11a5 <MPN_SET_MPZ+0x85>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jl     118b <MPN_SET_MPZ+0x6b>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    1198 <MPN_SET_MPZ+0x78>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
sub    (%rcx),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    11ad <MPN_SET_MPZ+0x8d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%esi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %eax,%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
sub    %rcx,%rax
shl    $0x2,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MPN_SET_MPZ>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
mov    (%rdx),%rax
mov    %rax,%rbx
neg    %rbx
cmovs  %rax,%rbx
cmp    %rsi,%rbx
mov    0x8(%rdx),%esi
cmovae %r12d,%ebx
lea    0x0(,%rbx,4),%edx
call   1040 <memcpy@plt>
mov    (%r14),%eax
lea    (%r15,%rax,4),%edi
sub    %ebx,%r12d
shl    $0x2,%r12d
xor    %esi,%esi
mov    %r12d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <memset@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64, i32 }
define void @MPN_SET_MPZ(i32* %0, i64 %1, %struct.TYPE_3__* %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca %struct.TYPE_3__*
%7 = alloca i32
store i32* %0, i32** %4
store i64 %1, i64* %5
store %struct.TYPE_3__* %2, %struct.TYPE_3__** %6
%8 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 0
%10 = load i64, i64* %9
%11 = icmp sge i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %13, i32 0, i32 0
%15 = load i64, i64* %14
br label %21
16: ; preds = %3
%17 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i32 0, i32 0
%19 = load i64, i64* %18
%20 = sub nsw i64 0, %19
br label %21
21: ; preds = %16, %12
%22 = phi i64 [ %15, %12 ], [ %20, %16 ]
%23 = load i64, i64* %5
%24 = icmp ult i64 %22, %23
br i1 %24, label %25, label %41
25: ; preds = %21
%26 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %26, i32 0, i32 0
%28 = load i64, i64* %27
%29 = icmp sge i64 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %25
%31 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%32 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %31, i32 0, i32 0
%33 = load i64, i64* %32
br label %39
34: ; preds = %25
%35 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%36 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %35, i32 0, i32 0
%37 = load i64, i64* %36
%38 = sub nsw i64 0, %37
br label %39
39: ; preds = %34, %30
%40 = phi i64 [ %33, %30 ], [ %38, %34 ]
br label %43
41: ; preds = %21
%42 = load i64, i64* %5
br label %43
43: ; preds = %41, %39
%44 = phi i64 [ %40, %39 ], [ %42, %41 ]
%45 = trunc i64 %44 to i32
store i32 %45, i32* %7
%46 = load i32*, i32** %4
%47 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%48 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %47, i32 0, i32 1
%49 = load i32, i32* %48
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = mul i64 %51, 4
%53 = trunc i64 %52 to i32
%54 = call i32 @memcpy(i32* %46, i32 %49, i32 %53)
%55 = load i32*, i32** %4
%56 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%57 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %56, i32 0, i32 0
%58 = load i64, i64* %57
%59 = getelementptr inbounds i32, i32* %55, i64 %58
%60 = ptrtoint i32* %59 to i32
%61 = load i64, i64* %5
%62 = load i32, i32* %7
%63 = sext i32 %62 to i64
%64 = sub i64 %61, %63
%65 = mul i64 %64, 4
%66 = trunc i64 %65 to i32
%67 = call i32 @memset(i32 %60, i32 0, i32 %66)
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i32 }
define void @MPN_SET_MPZ(i32* %0, i64 %1, %struct.TYPE_3__* nocapture %2) {
%4 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 0
%5 = load i64, i64* %4
%6 = tail call i64 @llvm.abs.i64(i64 %5, i1 true)
%7 = icmp ult i64 %6, %1
%8 = select i1 %7, i64 %6, i64 %1
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 1
%10 = load i32, i32* %9
%11 = trunc i64 %8 to i32
%12 = shl i32 %11, 2
%13 = tail call i32 @memcpy(i32* %0, i32 %10, i32 %12)
%14 = load i64, i64* %4
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = ptrtoint i32* %15 to i64
%17 = trunc i64 %16 to i32
%18 = sub i64 %1, %8
%19 = trunc i64 %18 to i32
%20 = shl i32 %19, 2
%21 = tail call i32 @memset(i32 %17, i32 0, i32 %20)
ret void
}