#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 utmpname(int /*<<< orphan*/);
int logout(const char *line) {
  struct utmp tmp;
  struct utmp *ut;
  int result = 0;
  if (utmpname(_PATH_UTMP) == -1)
    return 0;
  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,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
call   1040 <utmpname@plt>
cmp    $0xffffffff,%eax
jne    11b6 <logout+0x36>
movl   $0x0,-0x4(%rbp)
jmp    122d <logout+0xad>
mov    $0x0,%al
call   1090 <setutent@plt>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
lea    -0x20(%rbp),%rdi
call   1080 <getutline@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1220 <logout+0xa0>
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%edi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    -0x28(%rbp),%rdi
call   1070 <time@plt>
mov    -0x28(%rbp),%rdi
call   10a0 <pututline@plt>
cmp    $0x0,%rax
je     121b <logout+0x9b>
movl   $0x1,-0x2c(%rbp)
jmp    1220 <logout+0xa0>
mov    $0x0,%al
call   1060 <endutent@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%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
cmp    $0xffffffff,%eax
je     11f3 <logout+0x73>
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     11ec <logout+0x6c>
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 i32
%3 = alloca i8*
%4 = alloca %struct.utmp
%5 = alloca %struct.utmp*
%6 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %6
%7 = load i32, i32* @_PATH_UTMP
%8 = call i32 @utmpname(i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %35
11: ; preds = %1
%12 = call i32 (...) @setutent()
%13 = getelementptr inbounds %struct.utmp, %struct.utmp* %4, i32 0, i32 2
%14 = load i32, i32* %13
%15 = load i8*, i8** %3
%16 = call i32 @strncpy(i32 %14, i8* %15, i32 4)
%17 = call %struct.utmp* @getutline(%struct.utmp* %4)
store %struct.utmp* %17, %struct.utmp** %5
%18 = icmp ne %struct.utmp* %17, null
br i1 %18, label %19, label %32
19: ; preds = %11
%20 = load %struct.utmp*, %struct.utmp** %5
%21 = getelementptr inbounds %struct.utmp, %struct.utmp* %20, i32 0, i32 1
%22 = load i32, i32* %21
%23 = call i32 @memset(i32 %22, i32 0, i32 4)
%24 = load %struct.utmp*, %struct.utmp** %5
%25 = getelementptr inbounds %struct.utmp, %struct.utmp* %24, i32 0, i32 0
%26 = call i32 @time(i32* %25)
%27 = load %struct.utmp*, %struct.utmp** %5
%28 = call i32* @pututline(%struct.utmp* %27)
%29 = icmp ne i32* %28, null
br i1 %29, label %30, label %31
30: ; preds = %19
store i32 1, i32* %6
br label %31
31: ; preds = %30, %19
br label %32
32: ; preds = %31, %11
%33 = call i32 (...) @endutent()
%34 = load i32, i32* %6
store i32 %34, i32* %2
br label %35
35: ; preds = %32, %10
%36 = load i32, i32* %2
ret i32 %36
}

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 = icmp eq i32 %5, -1
br i1 %6, label %24, label %7
7: ; preds = %1
%8 = tail call i32 (...) @setutent()
%9 = tail call i32 @strncpy(i32 undef, i8* %0, i32 4)
%10 = call %struct.utmp* @getutline(%struct.utmp* %2)
%11 = icmp eq %struct.utmp* %10, null
br i1 %11, label %21, label %12
12: ; preds = %7
%13 = getelementptr inbounds %struct.utmp, %struct.utmp* %10, i64 0, i32 1
%14 = load i32, i32* %13
%15 = call i32 @memset(i32 %14, i32 0, i32 4)
%16 = getelementptr inbounds %struct.utmp, %struct.utmp* %10, i64 0, i32 0
%17 = call i32 @time(i32* %16)
%18 = call i32* @pututline(%struct.utmp* %10)
%19 = icmp ne i32* %18, null
%20 = zext i1 %19 to i32
br label %21
21: ; preds = %12, %7
%22 = phi i32 [ 0, %7 ], [ %20, %12 ]
%23 = call i32 (...) @endutent()
br label %24
24: ; preds = %1, %21
%25 = phi i32 [ %22, %21 ], [ 0, %1 ]
ret i32 %25
}