#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 */

/* Variables and functions */
int UT_LINESIZE;
int /*<<< orphan*/ write_utmp(char *, char *, int, int, char *, char *);
int /*<<< orphan*/ write_wtmp(char *, char *, int, int, char *);
void write_utmp_wtmp(char *user, char *id, int pid, int type, char *line) {
  char oldline[UT_LINESIZE];
  if (user == NULL)
    return;
  oldline[0] = 0;
  write_utmp(user, id, pid, type, line, oldline);
  write_wtmp(user, id, pid, type, line && line[0] ? line : oldline);
}


x86 assembly (clang, -O0):
<write_utmp_wtmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    0x2ea7(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    117d <write_utmp_wtmp+0x5d>
movl   $0x1,-0x34(%rbp)
jmp    120b <write_utmp_wtmp+0xeb>
mov    -0x40(%rbp),%r9
movb   $0x0,(%r9)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%r8
call   1040 <write_utmp@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x44(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11e0 <write_utmp_wtmp+0xc0>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11e0 <write_utmp_wtmp+0xc0>
mov    -0x20(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    11ed <write_utmp_wtmp+0xcd>
mov    -0x40(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    11ed <write_utmp_wtmp+0xcd>
mov    -0x44(%rbp),%ecx
mov    -0x48(%rbp),%edx
mov    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%r8
call   1030 <write_wtmp@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_utmp_wtmp>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2eb3(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
test   %rdi,%rdi
je     118a <write_utmp_wtmp+0x6a>
mov    %r8,%r13
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%rbx
movb   $0x0,(%r14)
mov    %ecx,-0x2c(%rbp)
mov    %r14,%r9
call   1040 <write_utmp@plt>
test   %r13,%r13
je     1176 <write_utmp_wtmp+0x56>
cmpb   $0x0,0x0(%r13)
cmovne %r13,%r14
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    -0x2c(%rbp),%ecx
mov    %r14,%r8
call   1030 <write_wtmp@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@UT_LINESIZE = global i32 0
define void @write_utmp_wtmp(i8* %0, i8* %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%14 = load i32, i32* @UT_LINESIZE
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %11
%17 = alloca i8, i64 %15
store i64 %15, i64* %12
%18 = load i8*, i8** %6
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %5
store i32 1, i32* %13
br label %47
21: ; preds = %5
%22 = getelementptr inbounds i8, i8* %17, i64 0
store i8 0, i8* %22
%23 = load i8*, i8** %6
%24 = load i8*, i8** %7
%25 = load i32, i32* %8
%26 = load i32, i32* %9
%27 = load i8*, i8** %10
%28 = call i32 @write_utmp(i8* %23, i8* %24, i32 %25, i32 %26, i8* %27, i8* %17)
%29 = load i8*, i8** %6
%30 = load i8*, i8** %7
%31 = load i32, i32* %8
%32 = load i32, i32* %9
%33 = load i8*, i8** %10
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %43
35: ; preds = %21
%36 = load i8*, i8** %10
%37 = getelementptr inbounds i8, i8* %36, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = load i8*, i8** %10
br label %44
43: ; preds = %35, %21
br label %44
44: ; preds = %43, %41
%45 = phi i8* [ %42, %41 ], [ %17, %43 ]
%46 = call i32 @write_wtmp(i8* %29, i8* %30, i32 %31, i32 %32, i8* %45)
store i32 0, i32* %13
br label %47
47: ; preds = %44, %20
%48 = load i8*, i8** %11
%49 = load i32, i32* %13
switch i32 %49, label %51 [
i32 0, label %50
i32 1, label %50
]
50: ; preds = %47, %47
ret void
51: ; preds = %47
unreachable
}

LLVM IR (-O2):
@UT_LINESIZE = global i32 0
define void @write_utmp_wtmp(i8* %0, i8* %1, i32 %2, i32 %3, i8* %4) {
%6 = load i32, i32* @UT_LINESIZE
%7 = zext i32 %6 to i64
%8 = alloca i8, i64 %7
%9 = icmp eq i8* %0, null
br i1 %9, label %20, label %10
10: ; preds = %5
store i8 0, i8* %8
%11 = call i32 @write_utmp(i8* %0, i8* %1, i32 %2, i32 %3, i8* %4, i8* %8)
%12 = icmp eq i8* %4, null
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = load i8, i8* %4
%15 = icmp eq i8 %14, 0
%16 = select i1 %15, i8* %8, i8* %4
br label %17
17: ; preds = %13, %10
%18 = phi i8* [ %8, %10 ], [ %16, %13 ]
%19 = call i32 @write_wtmp(i8* %0, i8* %1, i32 %2, i32 %3, i8* %18)
br label %20
20: ; preds = %5, %17
ret void
}