void *DRM_vdup(file, line, func, ptr)
char *file, *func;
int line;
void *ptr;
{
  void *p;
  p = vdup(ptr);
  if (p) {
    char buf[1024];
    DRM_setmsg(buf, sizeof(buf), p, 0, file, line, func);
    DRM_add(p, buf);
  }
  return p;
}


x86 assembly (clang, -O0):
<DRM_vdup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1050 <vdup@plt>
cltq
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11a1 <DRM_vdup+0x71>
lea    -0x430(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x8(%rbp),%r8
mov    -0xc(%rbp),%r9d
mov    -0x18(%rbp),%rax
mov    $0x400,%esi
xor    %ecx,%ecx
mov    %rax,(%rsp)
mov    $0x0,%al
call   1040 <DRM_setmsg@plt>
mov    -0x28(%rbp),%rdi
lea    -0x430(%rbp),%rsi
mov    $0x0,%al
call   1030 <DRM_add@plt>
mov    -0x28(%rbp),%rax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DRM_vdup>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x418,%rsp
mov    %rdx,%rbp
mov    %esi,%r14d
mov    %rdi,%r15
mov    %rcx,%rdi
xor    %eax,%eax
call   1050 <vdup@plt>
movslq %eax,%rbx
test   %ebx,%ebx
je     1187 <DRM_vdup+0x57>
mov    %rbp,(%rsp)
lea    0x10(%rsp),%rbp
mov    $0x400,%esi
mov    %rbp,%rdi
mov    %rbx,%rdx
xor    %ecx,%ecx
mov    %r15,%r8
mov    %r14d,%r9d
xor    %eax,%eax
call   1040 <DRM_setmsg@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <DRM_add@plt>
mov    %rbx,%rax
add    $0x418,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @DRM_vdup(i8* %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [1024 x i8]
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%11 = load i8*, i8** %8
%12 = call i32 (i8*, ...) bitcast (i32 (...)* @vdup to i32 (i8*, ...)*)(i8* %11)
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %9
%15 = load i8*, i8** %9
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %27
17: ; preds = %4
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%19 = load i8*, i8** %9
%20 = load i8*, i8** %5
%21 = load i32, i32* %6
%22 = load i8*, i8** %7
%23 = call i32 (i8*, i64, i8*, i32, i8*, i32, i8*, ...) bitcast (i32 (...)* @DRM_setmsg to i32 (i8*, i64, i8*, i32, i8*, i32, i8*, ...)*)(i8* %18, i64 1024, i8* %19, i32 0, i8* %20, i32 %21, i8* %22)
%24 = load i8*, i8** %9
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%26 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @DRM_add to i32 (i8*, i8*, ...)*)(i8* %24, i8* %25)
br label %27
27: ; preds = %17, %4
%28 = load i8*, i8** %9
ret i8* %28
}

LLVM IR (-O2):
define i8* @DRM_vdup(i8* %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca [1024 x i8]
%6 = tail call i32 (i8*, ...) bitcast (i32 (...)* @vdup to i32 (i8*, ...)*)(i8* %3)
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %7 to i8*
%9 = icmp eq i32 %6, 0
br i1 %9, label %14, label %10
10: ; preds = %4
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = call i32 (i8*, i64, i8*, i32, i8*, i32, i8*, ...) bitcast (i32 (...)* @DRM_setmsg to i32 (i8*, i64, i8*, i32, i8*, i32, i8*, ...)*)(i8* %11, i64 1024, i8* %8, i32 0, i8* %0, i32 %1, i8* %2)
%13 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @DRM_add to i32 (i8*, i8*, ...)*)(i8* %8, i8* %11)
br label %14
14: ; preds = %10, %4
ret i8* %8
}