#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 */
struct mntent {
  void *mnt_opts;
  void *mnt_type;
  void *mnt_dir;
  void *mnt_fsname;
};

/* Variables and functions */
void *strdup(void *);
struct mntent copymntent(const struct mntent *mnt) {
  struct mntent out;
  out.mnt_fsname = strdup(mnt->mnt_fsname);
  out.mnt_dir = strdup(mnt->mnt_dir);
  out.mnt_type = strdup(mnt->mnt_type);
  out.mnt_opts = strdup(mnt->mnt_opts);
  return out;
}


x86 assembly (clang, -O0):
<copymntent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x18(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <strdup@plt>
mov    -0x18(%rbp),%rdi
mov    %rax,0x18(%rdi)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <strdup@plt>
mov    -0x18(%rbp),%rdi
mov    %rax,0x10(%rdi)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strdup@plt>
mov    -0x18(%rbp),%rdi
mov    %rax,0x8(%rdi)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strdup@plt>
mov    -0x18(%rbp),%rdi
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rdi)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copymntent>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x18(%rsi),%rdi
call   1030 <strdup@plt>
mov    %rax,0x18(%rbx)
mov    0x10(%r14),%rdi
call   1030 <strdup@plt>
mov    %rax,0x10(%rbx)
mov    0x8(%r14),%rdi
call   1030 <strdup@plt>
mov    %rax,0x8(%rbx)
mov    (%r14),%rdi
call   1030 <strdup@plt>
mov    %rax,(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.mntent = type { i8*, i8*, i8*, i8* }
define void @copymntent(%struct.mntent* noalias sret(%struct.mntent) align 8 %0, %struct.mntent* %1) {
%3 = alloca %struct.mntent*
store %struct.mntent* %1, %struct.mntent** %3
%4 = load %struct.mntent*, %struct.mntent** %3
%5 = getelementptr inbounds %struct.mntent, %struct.mntent* %4, i32 0, i32 3
%6 = load i8*, i8** %5
%7 = call i8* @strdup(i8* %6)
%8 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i32 0, i32 3
store i8* %7, i8** %8
%9 = load %struct.mntent*, %struct.mntent** %3
%10 = getelementptr inbounds %struct.mntent, %struct.mntent* %9, i32 0, i32 2
%11 = load i8*, i8** %10
%12 = call i8* @strdup(i8* %11)
%13 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i32 0, i32 2
store i8* %12, i8** %13
%14 = load %struct.mntent*, %struct.mntent** %3
%15 = getelementptr inbounds %struct.mntent, %struct.mntent* %14, i32 0, i32 1
%16 = load i8*, i8** %15
%17 = call i8* @strdup(i8* %16)
%18 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i32 0, i32 1
store i8* %17, i8** %18
%19 = load %struct.mntent*, %struct.mntent** %3
%20 = getelementptr inbounds %struct.mntent, %struct.mntent* %19, i32 0, i32 0
%21 = load i8*, i8** %20
%22 = call i8* @strdup(i8* %21)
%23 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i32 0, i32 0
store i8* %22, i8** %23
ret void
}

LLVM IR (-O2):
%struct.mntent = type { i8*, i8*, i8*, i8* }
define void @copymntent(%struct.mntent* noalias nocapture writeonly sret(%struct.mntent) align 8 %0, %struct.mntent* nocapture %1) {
%3 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 3
%4 = load i8*, i8** %3
%5 = tail call i8* @strdup(i8* %4)
%6 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i64 0, i32 3
store i8* %5, i8** %6
%7 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 2
%8 = load i8*, i8** %7
%9 = tail call i8* @strdup(i8* %8)
%10 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i64 0, i32 2
store i8* %9, i8** %10
%11 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 1
%12 = load i8*, i8** %11
%13 = tail call i8* @strdup(i8* %12)
%14 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i64 0, i32 1
store i8* %13, i8** %14
%15 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 0
%16 = load i8*, i8** %15
%17 = tail call i8* @strdup(i8* %16)
%18 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i64 0, i32 0
store i8* %17, i8** %18
ret void
}