#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_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int length;
  scalar_t__ value;
};
typedef TYPE_1__ SmPropValue;
typedef scalar_t__ SmPointer;

/* Variables and functions */
scalar_t__ XtMalloc(int);
int /*<<< orphan*/ memcpy(scalar_t__, scalar_t__, int);
SmPropValue *CopyPropValues(int numPropValues, SmPropValue *thePropValues) {
  SmPropValue *pPropValueRet;
  int i;
  pPropValueRet = (SmPropValue *)XtMalloc(numPropValues * sizeof(SmPropValue));
  if (!pPropValueRet)
    return (NULL);
  for (i = 0; i < numPropValues; i++) {
    pPropValueRet[i].length = thePropValues[i].length;
    pPropValueRet[i].value = (SmPointer)XtMalloc(thePropValues[i].length + 1);
    if (!pPropValueRet[i].value)
      return (NULL);
    memcpy(pPropValueRet[i].value, thePropValues[i].value,
           thePropValues[i].length);
    ((char *)pPropValueRet[i].value)[pPropValueRet[i].length] = '\0';
  }
  return (pPropValueRet);
}


x86 assembly (clang, -O0):
<CopyPropValues>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x4,%rax
mov    %eax,%edi
call   1030 <XtMalloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    115a <CopyPropValues+0x3a>
movq   $0x0,-0x8(%rbp)
jmp    1260 <CopyPropValues+0x140>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1258 <CopyPropValues+0x138>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rdx
shl    $0x4,%rdx
add    %rdx,%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%edi
add    $0x1,%edi
call   1030 <XtMalloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rdx
shl    $0x4,%rdx
add    %rdx,%rax
mov    %rcx,0x8(%rax)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
cmpq   $0x0,0x8(%rax)
jne    11e5 <CopyPropValues+0xc5>
movq   $0x0,-0x8(%rbp)
jmp    1260 <CopyPropValues+0x140>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%edx
call   1040 <memcpy@plt>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rax
mov    -0x20(%rbp),%rcx
movslq -0x24(%rbp),%rdx
shl    $0x4,%rdx
add    %rdx,%rcx
movslq (%rcx),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1161 <CopyPropValues+0x41>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CopyPropValues>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
shl    $0x4,%edi
call   1030 <XtMalloc@plt>
test   %rax,%rax
je     1196 <CopyPropValues+0x76>
mov    %rax,%rbx
test   %ebp,%ebp
jle    1198 <CopyPropValues+0x78>
mov    %ebp,%r15d
shl    $0x4,%r15
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%r14,%rbp,1),%eax
mov    %eax,(%rbx,%rbp,1)
mov    (%r14,%rbp,1),%edi
add    $0x1,%edi
call   1030 <XtMalloc@plt>
mov    %rax,0x8(%rbx,%rbp,1)
test   %rax,%rax
je     1196 <CopyPropValues+0x76>
mov    0x8(%r14,%rbp,1),%rsi
mov    (%r14,%rbp,1),%edx
mov    %rax,%rdi
call   1040 <memcpy@plt>
mov    0x8(%rbx,%rbp,1),%rax
movslq (%rbx,%rbp,1),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x10,%rbp
cmp    %rbp,%r15
jne    1150 <CopyPropValues+0x30>
jmp    1198 <CopyPropValues+0x78>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32, i64 }
define %struct.TYPE_4__* @CopyPropValues(i32 %0, %struct.TYPE_4__* %1) {
%3 = alloca %struct.TYPE_4__*
%4 = alloca i32
%5 = alloca %struct.TYPE_4__*
%6 = alloca %struct.TYPE_4__*
%7 = alloca i32
store i32 %0, i32* %4
store %struct.TYPE_4__* %1, %struct.TYPE_4__** %5
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 16
%11 = trunc i64 %10 to i32
%12 = call i64 @XtMalloc(i32 %11)
%13 = inttoptr i64 %12 to %struct.TYPE_4__*
store %struct.TYPE_4__* %13, %struct.TYPE_4__** %6
%14 = load %struct.TYPE_4__*, %struct.TYPE_4__** %6
%15 = icmp ne %struct.TYPE_4__* %14, null
br i1 %15, label %17, label %16
16: ; preds = %2
store %struct.TYPE_4__* null, %struct.TYPE_4__** %3
br label %95
17: ; preds = %2
store i32 0, i32* %7
br label %18
18: ; preds = %90, %17
%19 = load i32, i32* %7
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %93
22: ; preds = %18
%23 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %23, i64 %25
%27 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %26, i32 0, i32 0
%28 = load i32, i32* %27
%29 = load %struct.TYPE_4__*, %struct.TYPE_4__** %6
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %29, i64 %31
%33 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %32, i32 0, i32 0
store i32 %28, i32* %33
%34 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %34, i64 %36
%38 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %37, i32 0, i32 0
%39 = load i32, i32* %38
%40 = add nsw i32 %39, 1
%41 = call i64 @XtMalloc(i32 %40)
%42 = load %struct.TYPE_4__*, %struct.TYPE_4__** %6
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %42, i64 %44
%46 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %45, i32 0, i32 1
store i64 %41, i64* %46
%47 = load %struct.TYPE_4__*, %struct.TYPE_4__** %6
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %47, i64 %49
%51 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %50, i32 0, i32 1
%52 = load i64, i64* %51
%53 = icmp ne i64 %52, 0
br i1 %53, label %55, label %54
54: ; preds = %22
store %struct.TYPE_4__* null, %struct.TYPE_4__** %3
br label %95
55: ; preds = %22
%56 = load %struct.TYPE_4__*, %struct.TYPE_4__** %6
%57 = load i32, i32* %7
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %56, i64 %58
%60 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %59, i32 0, i32 1
%61 = load i64, i64* %60
%62 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%63 = load i32, i32* %7
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %62, i64 %64
%66 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %65, i32 0, i32 1
%67 = load i64, i64* %66
%68 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%69 = load i32, i32* %7
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %68, i64 %70
%72 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %71, i32 0, i32 0
%73 = load i32, i32* %72
%74 = call i32 @memcpy(i64 %61, i64 %67, i32 %73)
%75 = load %struct.TYPE_4__*, %struct.TYPE_4__** %6
%76 = load i32, i32* %7
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %75, i64 %77
%79 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %78, i32 0, i32 1
%80 = load i64, i64* %79
%81 = inttoptr i64 %80 to i8*
%82 = load %struct.TYPE_4__*, %struct.TYPE_4__** %6
%83 = load i32, i32* %7
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %82, i64 %84
%86 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %85, i32 0, i32 0
%87 = load i32, i32* %86
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %81, i64 %88
store i8 0, i8* %89
br label %90
90: ; preds = %55
%91 = load i32, i32* %7
%92 = add nsw i32 %91, 1
store i32 %92, i32* %7
br label %18
93: ; preds = %18
%94 = load %struct.TYPE_4__*, %struct.TYPE_4__** %6
store %struct.TYPE_4__* %94, %struct.TYPE_4__** %3
br label %95
95: ; preds = %93, %54, %16
%96 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
ret %struct.TYPE_4__* %96
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32, i64 }
define %struct.TYPE_4__* @CopyPropValues(i32 %0, %struct.TYPE_4__* nocapture %1) {
%3 = shl i32 %0, 4
%4 = tail call i64 @XtMalloc(i32 %3)
%5 = inttoptr i64 %4 to %struct.TYPE_4__*
%6 = icmp eq i64 %4, 0
br i1 %6, label %33, label %7
7: ; preds = %2
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %33
9: ; preds = %7
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %9, %21
%12 = phi i64 [ 0, %9 ], [ %31, %21 ]
%13 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 %12, i32 0
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %5, i64 %12, i32 0
store i32 %14, i32* %15
%16 = load i32, i32* %13
%17 = add nsw i32 %16, 1
%18 = tail call i64 @XtMalloc(i32 %17)
%19 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %5, i64 %12, i32 1
store i64 %18, i64* %19
%20 = icmp eq i64 %18, 0
br i1 %20, label %33, label %21
21: ; preds = %11
%22 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 %12, i32 1
%23 = load i64, i64* %22
%24 = load i32, i32* %13
%25 = tail call i32 @memcpy(i64 %18, i64 %23, i32 %24)
%26 = load i64, i64* %19
%27 = inttoptr i64 %26 to i8*
%28 = load i32, i32* %15
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8 0, i8* %30
%31 = add nuw nsw i64 %12, 1
%32 = icmp eq i64 %31, %10
br i1 %32, label %33, label %11
33: ; preds = %11, %21, %7, %2
%34 = phi %struct.TYPE_4__* [ null, %2 ], [ %5, %7 ], [ null, %11 ], [ %5, %21 ]
ret %struct.TYPE_4__* %34
}