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

/* Variables and functions */
scalar_t__ LOGIN_PROCESS;
scalar_t__ USER_PROCESS;
int /*<<< orphan*/ __UT_LINESIZE;
struct utmpx *__getutxent();
scalar_t__ strncmp(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
struct utmpx *getutxline(const struct utmpx *line) {
  for (;;) {
    struct utmpx *next = __getutxent();
    if (next == NULL)
      return NULL;
    if ((next->ut_type == LOGIN_PROCESS || next->ut_type == USER_PROCESS) &&
        strncmp(next->ut_line, line->ut_line, __UT_LINESIZE) == 0)
      return next;
  }
}


x86 assembly (clang, -O0):
<getutxline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <__getutxent@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    114f <getutxline+0x2f>
movq   $0x0,-0x8(%rbp)
jmp    11b5 <getutxline+0x95>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2e6b(%rip),%rcx
cmp    (%rcx),%rax
je     117d <getutxline+0x5d>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2e74(%rip),%rcx
cmp    (%rcx),%rax
jne    11b0 <getutxline+0x90>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%esi
mov    0x2e4e(%rip),%rax
mov    (%rax),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11b0 <getutxline+0x90>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b5 <getutxline+0x95>
jmp    112c <getutxline+0xc>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getutxline>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <__getutxent@plt>
test   %rax,%rax
je     1196 <getutxline+0x76>
mov    0x2e87(%rip),%r15
mov    0x2ea0(%rip),%r12
mov    0x2e91(%rip),%r13
mov    %rax,%rbx
jmp    1184 <getutxline+0x64>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rbx),%edi
mov    0x8(%r14),%esi
mov    0x0(%r13),%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1196 <getutxline+0x76>
xor    %eax,%eax
call   1040 <__getutxent@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1194 <getutxline+0x74>
mov    (%rbx),%rax
cmp    (%r15),%rax
je     1160 <getutxline+0x40>
cmp    (%r12),%rax
jne    1175 <getutxline+0x55>
jmp    1160 <getutxline+0x40>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.utmpx = type { i64, i32 }
@LOGIN_PROCESS = global i64 0
@USER_PROCESS = global i64 0
@__UT_LINESIZE = global i32 0
define %struct.utmpx* @getutxline(%struct.utmpx* %0) {
%2 = alloca %struct.utmpx*
%3 = alloca %struct.utmpx*
%4 = alloca %struct.utmpx*
store %struct.utmpx* %0, %struct.utmpx** %3
br label %5
5: ; preds = %34, %1
%6 = call %struct.utmpx* (...) @__getutxent()
store %struct.utmpx* %6, %struct.utmpx** %4
%7 = load %struct.utmpx*, %struct.utmpx** %4
%8 = icmp eq %struct.utmpx* %7, null
br i1 %8, label %9, label %10
9: ; preds = %5
store %struct.utmpx* null, %struct.utmpx** %2
br label %35
10: ; preds = %5
%11 = load %struct.utmpx*, %struct.utmpx** %4
%12 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %11, i32 0, i32 0
%13 = load i64, i64* %12
%14 = load i64, i64* @LOGIN_PROCESS
%15 = icmp eq i64 %13, %14
br i1 %15, label %22, label %16
16: ; preds = %10
%17 = load %struct.utmpx*, %struct.utmpx** %4
%18 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %17, i32 0, i32 0
%19 = load i64, i64* %18
%20 = load i64, i64* @USER_PROCESS
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %34
22: ; preds = %16, %10
%23 = load %struct.utmpx*, %struct.utmpx** %4
%24 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %23, i32 0, i32 1
%25 = load i32, i32* %24
%26 = load %struct.utmpx*, %struct.utmpx** %3
%27 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %26, i32 0, i32 1
%28 = load i32, i32* %27
%29 = load i32, i32* @__UT_LINESIZE
%30 = call i64 @strncmp(i32 %25, i32 %28, i32 %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %22
%33 = load %struct.utmpx*, %struct.utmpx** %4
store %struct.utmpx* %33, %struct.utmpx** %2
br label %35
34: ; preds = %22, %16
br label %5
35: ; preds = %32, %9
%36 = load %struct.utmpx*, %struct.utmpx** %2
ret %struct.utmpx* %36
}

LLVM IR (-O2):
%struct.utmpx = type { i64, i32 }
@LOGIN_PROCESS = global i64 0
@USER_PROCESS = global i64 0
@__UT_LINESIZE = global i32 0
define %struct.utmpx* @getutxline(%struct.utmpx* nocapture %0) {
%2 = tail call %struct.utmpx* (...) @__getutxent()
%3 = icmp eq %struct.utmpx* %2, null
br i1 %3, label %25, label %4
4: ; preds = %1
%5 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %0, i64 0, i32 1
br label %6
6: ; preds = %4, %22
%7 = phi %struct.utmpx* [ %2, %4 ], [ %23, %22 ]
%8 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %7, i64 0, i32 0
%9 = load i64, i64* %8
%10 = load i64, i64* @LOGIN_PROCESS
%11 = icmp eq i64 %9, %10
%12 = load i64, i64* @USER_PROCESS
%13 = icmp eq i64 %9, %12
%14 = select i1 %11, i1 true, i1 %13
br i1 %14, label %15, label %22
15: ; preds = %6
%16 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %7, i64 0, i32 1
%17 = load i32, i32* %16
%18 = load i32, i32* %5
%19 = load i32, i32* @__UT_LINESIZE
%20 = tail call i64 @strncmp(i32 %17, i32 %18, i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %15, %6
%23 = tail call %struct.utmpx* (...) @__getutxent()
%24 = icmp eq %struct.utmpx* %23, null
br i1 %24, label %25, label %6
25: ; preds = %15, %22, %1
%26 = phi %struct.utmpx* [ null, %1 ], [ null, %22 ], [ %7, %15 ]
ret %struct.utmpx* %26
}