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

/* Variables and functions */
int /*<<< orphan*/ UT_LINESIZE;
int /*<<< orphan*/ _PATH_UTMP;
int /*<<< orphan*/ endutent();
int /*<<< orphan*/ pututline(struct utmp const *);
int /*<<< orphan*/ setutent();
int /*<<< orphan*/ strncpy(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ utmpname(int /*<<< orphan*/);
void login(const struct utmp *entry) {
  struct utmp copy = *entry;
  utmpname(_PATH_UTMP);
  setutent();
  strncpy(copy.ut_line, entry->ut_line, UT_LINESIZE);
  pututline(entry);
  endutent();
}


x86 assembly (clang, -O0):
<login>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
call   1040 <utmpname@plt>
mov    $0x0,%al
call   1060 <setutent@plt>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    0x2e56(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rdi
call   1070 <pututline@plt>
mov    $0x0,%al
call   1050 <endutent@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<login>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%ebp
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
call   1040 <utmpname@plt>
xor    %eax,%eax
call   1060 <setutent@plt>
mov    (%rbx),%esi
mov    0x2e6a(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1070 <pututline@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <endutent@plt>

LLVM IR (-O0):
%struct.utmp = type { i32 }
@_PATH_UTMP = global i32 0
@UT_LINESIZE = global i32 0
define void @login(%struct.utmp* %0) {
%2 = alloca %struct.utmp*
%3 = alloca %struct.utmp
store %struct.utmp* %0, %struct.utmp** %2
%4 = load %struct.utmp*, %struct.utmp** %2
%5 = bitcast %struct.utmp* %3 to i8*
%6 = bitcast %struct.utmp* %4 to i8*
%7 = load i32, i32* @_PATH_UTMP
%8 = call i32 @utmpname(i32 %7)
%9 = call i32 (...) @setutent()
%10 = getelementptr inbounds %struct.utmp, %struct.utmp* %3, i32 0, i32 0
%11 = load i32, i32* %10
%12 = load %struct.utmp*, %struct.utmp** %2
%13 = getelementptr inbounds %struct.utmp, %struct.utmp* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = load i32, i32* @UT_LINESIZE
%16 = call i32 @strncpy(i32 %11, i32 %14, i32 %15)
%17 = load %struct.utmp*, %struct.utmp** %2
%18 = call i32 @pututline(%struct.utmp* %17)
%19 = call i32 (...) @endutent()
ret void
}

LLVM IR (-O2):
%struct.utmp = type { i32 }
@_PATH_UTMP = global i32 0
@UT_LINESIZE = global i32 0
define void @login(%struct.utmp* %0) {
%2 = getelementptr inbounds %struct.utmp, %struct.utmp* %0, i64 0, i32 0
%3 = load i32, i32* %2
%4 = load i32, i32* @_PATH_UTMP
%5 = tail call i32 @utmpname(i32 %4)
%6 = tail call i32 (...) @setutent()
%7 = load i32, i32* %2
%8 = load i32, i32* @UT_LINESIZE
%9 = tail call i32 @strncpy(i32 %3, i32 %7, i32 %8)
%10 = tail call i32 @pututline(%struct.utmp* %0)
%11 = tail call i32 (...) @endutent()
ret void
}