#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 utmpx {
  int /*<<< orphan*/ ut_time;
  int /*<<< orphan*/ ut_user;
  int /*<<< orphan*/ ut_line;
};
struct utmp {
  int /*<<< orphan*/ ut_time;
  int /*<<< orphan*/ ut_user;
  int /*<<< orphan*/ ut_line;
};

/* Variables and functions */
int /*<<< orphan*/ memcpy(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ memset(struct utmpx *, int /*<<< orphan*/, int);
void getutmpx(const struct utmp *utmp, struct utmpx *utmpx) {
  memset(utmpx, 0, sizeof(struct utmpx));
  memcpy(utmpx->ut_line, utmp->ut_line, sizeof(utmp->ut_line));
  memcpy(utmpx->ut_user, utmp->ut_user, sizeof(utmp->ut_user));
  utmpx->ut_time = utmp->ut_time;
}


x86 assembly (clang, -O0):
<getutmpx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%esi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%esi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getutmpx>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1030 <memset@plt>
mov    0x8(%rbx),%edi
mov    0x8(%r14),%esi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    0x4(%rbx),%edi
mov    0x4(%r14),%esi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    (%r14),%eax
mov    %eax,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.utmp = type { i32, i32, i32 }
%struct.utmpx = type { i32, i32, i32 }
define void @getutmpx(%struct.utmp* %0, %struct.utmpx* %1) {
%3 = alloca %struct.utmp*
%4 = alloca %struct.utmpx*
store %struct.utmp* %0, %struct.utmp** %3
store %struct.utmpx* %1, %struct.utmpx** %4
%5 = load %struct.utmpx*, %struct.utmpx** %4
%6 = call i32 @memset(%struct.utmpx* %5, i32 0, i32 12)
%7 = load %struct.utmpx*, %struct.utmpx** %4
%8 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %7, i32 0, i32 2
%9 = load i32, i32* %8
%10 = load %struct.utmp*, %struct.utmp** %3
%11 = getelementptr inbounds %struct.utmp, %struct.utmp* %10, i32 0, i32 2
%12 = load i32, i32* %11
%13 = call i32 @memcpy(i32 %9, i32 %12, i32 4)
%14 = load %struct.utmpx*, %struct.utmpx** %4
%15 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %14, i32 0, i32 1
%16 = load i32, i32* %15
%17 = load %struct.utmp*, %struct.utmp** %3
%18 = getelementptr inbounds %struct.utmp, %struct.utmp* %17, i32 0, i32 1
%19 = load i32, i32* %18
%20 = call i32 @memcpy(i32 %16, i32 %19, i32 4)
%21 = load %struct.utmp*, %struct.utmp** %3
%22 = getelementptr inbounds %struct.utmp, %struct.utmp* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = load %struct.utmpx*, %struct.utmpx** %4
%25 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %24, i32 0, i32 0
store i32 %23, i32* %25
ret void
}

LLVM IR (-O2):
%struct.utmp = type { i32, i32, i32 }
%struct.utmpx = type { i32, i32, i32 }
define void @getutmpx(%struct.utmp* nocapture %0, %struct.utmpx* %1) {
%3 = tail call i32 @memset(%struct.utmpx* %1, i32 0, i32 12)
%4 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %1, i64 0, i32 2
%5 = load i32, i32* %4
%6 = getelementptr inbounds %struct.utmp, %struct.utmp* %0, i64 0, i32 2
%7 = load i32, i32* %6
%8 = tail call i32 @memcpy(i32 %5, i32 %7, i32 4)
%9 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %1, i64 0, i32 1
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.utmp, %struct.utmp* %0, i64 0, i32 1
%12 = load i32, i32* %11
%13 = tail call i32 @memcpy(i32 %10, i32 %12, i32 4)
%14 = getelementptr inbounds %struct.utmp, %struct.utmp* %0, i64 0, i32 0
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %1, i64 0, i32 0
store i32 %15, i32* %16
ret void
}