#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*/ 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 logout(const char *line) {
  struct utmp tmp;
  struct utmp *ut;
  int result = 0;
  setutent();
  strncpy(tmp.ut_line, line, sizeof tmp.ut_line);
  if ((ut = getutline(&tmp)) != NULL) {
    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    $0x0,%al
call   1080 <setutent@plt>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
lea    -0x18(%rbp),%rdi
call   1070 <getutline@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11ed <logout+0x7d>
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%edi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x20(%rbp),%rdi
call   1060 <time@plt>
mov    -0x20(%rbp),%rdi
call   1090 <pututline@plt>
cmp    $0x0,%rax
je     11e8 <logout+0x78>
movl   $0x1,-0x24(%rbp)
jmp    11ed <logout+0x7d>
mov    $0x0,%al
call   1050 <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
xor    %ebp,%ebp
xor    %eax,%eax
call   1080 <setutent@plt>
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
lea    0x8(%rsp),%rdi
call   1070 <getutline@plt>
test   %rax,%rax
je     11c9 <logout+0x59>
mov    %rax,%rbx
mov    0x4(%rax),%edi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
call   1060 <time@plt>
mov    %rbx,%rdi
call   1090 <pututline@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
xor    %eax,%eax
call   1050 <endutent@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

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