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

/* Variables and functions */
int /*<<< orphan*/ _PATH_UTMP;
int /*<<< orphan*/ endutent();
struct utmp *getutline(struct utmp *);
int /*<<< orphan*/ memset(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ *pututline(struct utmp *);
int /*<<< orphan*/ setutent();
int /*<<< orphan*/ strncpy(int /*<<< orphan*/, char const *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ utmpname(int /*<<< orphan*/);
int logout(const char *line) {
  struct utmp tmp;
  struct utmp *ut;
  int result = 0;
  utmpname(_PATH_UTMP);
  setutent();
  strncpy(tmp.ut_line, line, sizeof tmp.ut_line);
  if ((ut = getutline(&tmp))) {
    memset(ut->ut_name, 0, sizeof ut->ut_name);
    time(&ut->ut_time);
    if (pututline(ut) != NULL)
      result = 1;
  }
  endutent();
  return result;
}


x86 assembly (clang, -O0):
<logout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x24(%rbp)
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
call   1040 <utmpname@plt>
mov    $0x0,%al
call   1090 <setutent@plt>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
lea    -0x18(%rbp),%rdi
call   1080 <getutline@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     120b <logout+0x8b>
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%edi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    -0x20(%rbp),%rdi
call   1070 <time@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <pututline@plt>
cmp    $0x0,%rax
je     1206 <logout+0x86>
movl   $0x1,-0x24(%rbp)
jmp    120b <logout+0x8b>
mov    $0x0,%al
call   1060 <endutent@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logout>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
call   1040 <utmpname@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1090 <setutent@plt>
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
lea    0x8(%rsp),%rdi
call   1080 <getutline@plt>
test   %rax,%rax
je     11e7 <logout+0x67>
mov    %rax,%rbx
mov    0x4(%rax),%edi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
call   1070 <time@plt>
mov    %rbx,%rdi
call   10a0 <pututline@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
xor    %eax,%eax
call   1060 <endutent@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.utmp = type { i32, i32, i32 }
@_PATH_UTMP = global i32 0
define i32 @logout(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.utmp
%4 = alloca %struct.utmp*
%5 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %5
%6 = load i32, i32* @_PATH_UTMP
%7 = call i32 @utmpname(i32 %6)
%8 = call i32 (...) @setutent()
%9 = getelementptr inbounds %struct.utmp, %struct.utmp* %3, i32 0, i32 2
%10 = load i32, i32* %9
%11 = load i8*, i8** %2
%12 = call i32 @strncpy(i32 %10, i8* %11, i32 4)
%13 = call %struct.utmp* @getutline(%struct.utmp* %3)
store %struct.utmp* %13, %struct.utmp** %4
%14 = icmp ne %struct.utmp* %13, null
br i1 %14, label %15, label %28
15: ; preds = %1
%16 = load %struct.utmp*, %struct.utmp** %4
%17 = getelementptr inbounds %struct.utmp, %struct.utmp* %16, i32 0, i32 1
%18 = load i32, i32* %17
%19 = call i32 @memset(i32 %18, i32 0, i32 4)
%20 = load %struct.utmp*, %struct.utmp** %4
%21 = getelementptr inbounds %struct.utmp, %struct.utmp* %20, i32 0, i32 0
%22 = call i32 @time(i32* %21)
%23 = load %struct.utmp*, %struct.utmp** %4
%24 = call i32* @pututline(%struct.utmp* %23)
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %27
26: ; preds = %15
store i32 1, i32* %5
br label %27
27: ; preds = %26, %15
br label %28
28: ; preds = %27, %1
%29 = call i32 (...) @endutent()
%30 = load i32, i32* %5
ret i32 %30
}

LLVM IR (-O2):
%struct.utmp = type { i32, i32, i32 }
@_PATH_UTMP = global i32 0
define i32 @logout(i8* %0) {
%2 = alloca %struct.utmp
%3 = bitcast %struct.utmp* %2 to i8*
%4 = load i32, i32* @_PATH_UTMP
%5 = tail call i32 @utmpname(i32 %4)
%6 = tail call i32 (...) @setutent()
%7 = tail call i32 @strncpy(i32 undef, i8* %0, i32 4)
%8 = call %struct.utmp* @getutline(%struct.utmp* %2)
%9 = icmp eq %struct.utmp* %8, null
br i1 %9, label %19, label %10
10: ; preds = %1
%11 = getelementptr inbounds %struct.utmp, %struct.utmp* %8, i64 0, i32 1
%12 = load i32, i32* %11
%13 = call i32 @memset(i32 %12, i32 0, i32 4)
%14 = getelementptr inbounds %struct.utmp, %struct.utmp* %8, i64 0, i32 0
%15 = call i32 @time(i32* %14)
%16 = call i32* @pututline(%struct.utmp* %8)
%17 = icmp ne i32* %16, null
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %10, %1
%20 = phi i32 [ 0, %1 ], [ %18, %10 ]
%21 = call i32 (...) @endutent()
ret i32 %20
}