#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 {
  int /*<<< orphan*/ mnt_passno;
  int /*<<< orphan*/ mnt_freq;
  int /*<<< orphan*/ *mnt_opts;
  int /*<<< orphan*/ *mnt_type;
  int /*<<< orphan*/ *mnt_dir;
  int /*<<< orphan*/ *mnt_fsname;
};

/* Variables and functions */
int /*<<< orphan*/ memset(struct mntent *, int /*<<< orphan*/, int);
void *strdup(int /*<<< orphan*/ *);
bool copy_mntent(struct mntent *dest, const struct mntent *src) {
  memset(dest, 0, sizeof(*dest));
  if (src->mnt_fsname != NULL) {
    dest->mnt_fsname = strdup(src->mnt_fsname);
    if (dest->mnt_fsname == NULL) {
      return false;
    }
  }
  if (src->mnt_dir != NULL) {
    dest->mnt_dir = strdup(src->mnt_dir);
    if (dest->mnt_dir == NULL) {
      return false;
    }
  }
  if (src->mnt_type != NULL) {
    dest->mnt_type = strdup(src->mnt_type);
    if (dest->mnt_type == NULL) {
      return false;
    }
  }
  if (src->mnt_opts != NULL) {
    dest->mnt_opts = strdup(src->mnt_opts);
    if (dest->mnt_opts == NULL) {
      return false;
    }
  }
  dest->mnt_freq = src->mnt_freq;
  dest->mnt_passno = src->mnt_passno;
  return true;
}


x86 assembly (clang, -O0):
<copy_mntent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x20(%rax)
je     1187 <copy_mntent+0x67>
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rdi
call   1040 <strdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x20(%rax)
jne    1182 <copy_mntent+0x62>
movl   $0x0,-0x4(%rbp)
jmp    127d <copy_mntent+0x15d>
jmp    1187 <copy_mntent+0x67>
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     11ce <copy_mntent+0xae>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <strdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x18(%rax)
jne    11c9 <copy_mntent+0xa9>
movl   $0x0,-0x4(%rbp)
jmp    127d <copy_mntent+0x15d>
jmp    11ce <copy_mntent+0xae>
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1215 <copy_mntent+0xf5>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <strdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
jne    1210 <copy_mntent+0xf0>
movl   $0x0,-0x4(%rbp)
jmp    127d <copy_mntent+0x15d>
jmp    1215 <copy_mntent+0xf5>
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     125c <copy_mntent+0x13c>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    1257 <copy_mntent+0x137>
movl   $0x0,-0x4(%rbp)
jmp    127d <copy_mntent+0x15d>
jmp    125c <copy_mntent+0x13c>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_mntent>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbp
mov    %rdi,%rbx
xor    %r14d,%r14d
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
mov    0x20(%rbp),%rdi
test   %rdi,%rdi
je     1150 <copy_mntent+0x30>
call   1040 <strdup@plt>
mov    %rax,0x20(%rbx)
test   %rax,%rax
je     11a6 <copy_mntent+0x86>
mov    0x18(%rbp),%rdi
test   %rdi,%rdi
je     1167 <copy_mntent+0x47>
call   1040 <strdup@plt>
mov    %rax,0x18(%rbx)
test   %rax,%rax
je     11a6 <copy_mntent+0x86>
mov    0x10(%rbp),%rdi
test   %rdi,%rdi
je     117e <copy_mntent+0x5e>
call   1040 <strdup@plt>
mov    %rax,0x10(%rbx)
test   %rax,%rax
je     11a6 <copy_mntent+0x86>
mov    0x8(%rbp),%rdi
test   %rdi,%rdi
je     1195 <copy_mntent+0x75>
call   1040 <strdup@plt>
mov    %rax,0x8(%rbx)
test   %rax,%rax
je     11a6 <copy_mntent+0x86>
mov    0x4(%rbp),%eax
mov    %eax,0x4(%rbx)
mov    0x0(%rbp),%eax
mov    %eax,(%rbx)
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.mntent = type { i32, i32, i32*, i32*, i32*, i32* }
define i32 @copy_mntent(%struct.mntent* %0, %struct.mntent* nocapture %1) {
%3 = tail call i32 @memset(%struct.mntent* %0, i32 0, i32 40)
%4 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 5
%5 = load i32*, i32** %4
%6 = icmp eq i32* %5, null
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = tail call i8* @strdup(i32* %5)
%9 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i64 0, i32 5
%10 = bitcast i32** %9 to i8**
store i8* %8, i8** %10
%11 = icmp eq i8* %8, null
br i1 %11, label %46, label %12
12: ; preds = %7, %2
%13 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 4
%14 = load i32*, i32** %13
%15 = icmp eq i32* %14, null
br i1 %15, label %21, label %16
16: ; preds = %12
%17 = tail call i8* @strdup(i32* %14)
%18 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i64 0, i32 4
%19 = bitcast i32** %18 to i8**
store i8* %17, i8** %19
%20 = icmp eq i8* %17, null
br i1 %20, label %46, label %21
21: ; preds = %16, %12
%22 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 3
%23 = load i32*, i32** %22
%24 = icmp eq i32* %23, null
br i1 %24, label %30, label %25
25: ; preds = %21
%26 = tail call i8* @strdup(i32* %23)
%27 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i64 0, i32 3
%28 = bitcast i32** %27 to i8**
store i8* %26, i8** %28
%29 = icmp eq i8* %26, null
br i1 %29, label %46, label %30
30: ; preds = %25, %21
%31 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 2
%32 = load i32*, i32** %31
%33 = icmp eq i32* %32, null
br i1 %33, label %39, label %34
34: ; preds = %30
%35 = tail call i8* @strdup(i32* %32)
%36 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i64 0, i32 2
%37 = bitcast i32** %36 to i8**
store i8* %35, i8** %37
%38 = icmp eq i8* %35, null
br i1 %38, label %46, label %39
39: ; preds = %34, %30
%40 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 1
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i64 0, i32 1
store i32 %41, i32* %42
%43 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 0
%44 = load i32, i32* %43
%45 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i64 0, i32 0
store i32 %44, i32* %45
br label %46
46: ; preds = %34, %25, %16, %7, %39
%47 = phi i32 [ 1, %39 ], [ 0, %7 ], [ 0, %16 ], [ 0, %25 ], [ 0, %34 ]
ret i32 %47
}