#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;
};

/* Variables and functions */
scalar_t__ USER_PROCESS;
int /*<<< orphan*/ endutxent();
int /*<<< orphan*/ flush(int, char *, int);
int /*<<< orphan*/ free(char *);
struct utmpx *getutxent();
char *parse_user(struct utmpx *, int *);
int /*<<< orphan*/ setutxent();
void process_online_users(int s, void *(f)(char *)) {
  setutxent();
  struct utmpx *uinfo;
  while ((uinfo = getutxent())) {
    if (uinfo->ut_type != USER_PROCESS)
      continue;
    int uline_len;
    char *uline = parse_user(uinfo, &uline_len);
    if (!uline) {
      return;
    }
    if (s) {
      flush(s, uline, uline_len);
    } else {
      f(uline);
    }
    free(uline);
  }
  endutxent();
}


x86 assembly (clang, -O0):
<process_online_users>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <setutxent@plt>
mov    $0x0,%al
call   1080 <getutxent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11fe <process_online_users+0x9e>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2e4f(%rip),%rcx
cmp    (%rcx),%rax
je     11a7 <process_online_users+0x47>
jmp    1176 <process_online_users+0x16>
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <parse_user@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11c8 <process_online_users+0x68>
jmp    1205 <process_online_users+0xa5>
cmpl   $0x0,-0x4(%rbp)
je     11e6 <process_online_users+0x86>
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <flush@plt>
jmp    11f0 <process_online_users+0x90>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rdi
call   *%rax
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    1176 <process_online_users+0x16>
mov    $0x0,%al
call   1050 <endutxent@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_online_users>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
xor    %eax,%eax
call   1070 <setutxent@plt>
xor    %eax,%eax
call   1080 <getutxent@plt>
test   %rax,%rax
je     11ea <process_online_users+0x8a>
mov    0x2e5d(%rip),%r12
lea    0xc(%rsp),%r15
jmp    11c2 <process_online_users+0x62>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0xc(%rsp),%edx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <flush@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1080 <getutxent@plt>
test   %rax,%rax
je     11ea <process_online_users+0x8a>
mov    (%rax),%rcx
cmp    (%r12),%rcx
jne    11b6 <process_online_users+0x56>
mov    %rax,%rdi
mov    %r15,%rsi
call   1060 <parse_user@plt>
test   %rax,%rax
je     11f1 <process_online_users+0x91>
mov    %rax,%rbx
test   %ebp,%ebp
jne    11a0 <process_online_users+0x40>
mov    %rbx,%rdi
call   *%r14
jmp    11ae <process_online_users+0x4e>
xor    %eax,%eax
call   1050 <endutxent@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.utmpx = type { i64 }
@USER_PROCESS = global i64 0
define void @process_online_users(i32 %0, i8* (i8*)* %1) {
%3 = alloca i32
%4 = alloca i8* (i8*)*
%5 = alloca %struct.utmpx*
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %3
store i8* (i8*)* %1, i8* (i8*)** %4
%8 = call i32 (...) @setutxent()
br label %9
9: ; preds = %37, %18, %2
%10 = call %struct.utmpx* (...) @getutxent()
store %struct.utmpx* %10, %struct.utmpx** %5
%11 = icmp ne %struct.utmpx* %10, null
br i1 %11, label %12, label %40
12: ; preds = %9
%13 = load %struct.utmpx*, %struct.utmpx** %5
%14 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %13, i32 0, i32 0
%15 = load i64, i64* %14
%16 = load i64, i64* @USER_PROCESS
%17 = icmp ne i64 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %12
br label %9
19: ; preds = %12
%20 = load %struct.utmpx*, %struct.utmpx** %5
%21 = call i8* @parse_user(%struct.utmpx* %20, i32* %6)
store i8* %21, i8** %7
%22 = load i8*, i8** %7
%23 = icmp ne i8* %22, null
br i1 %23, label %25, label %24
24: ; preds = %19
br label %42
25: ; preds = %19
%26 = load i32, i32* %3
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i32, i32* %3
%30 = load i8*, i8** %7
%31 = load i32, i32* %6
%32 = call i32 @flush(i32 %29, i8* %30, i32 %31)
br label %37
33: ; preds = %25
%34 = load i8* (i8*)*, i8* (i8*)** %4
%35 = load i8*, i8** %7
%36 = call i8* %34(i8* %35)
br label %37
37: ; preds = %33, %28
%38 = load i8*, i8** %7
%39 = call i32 @free(i8* %38)
br label %9
40: ; preds = %9
%41 = call i32 (...) @endutxent()
br label %42
42: ; preds = %40, %24
ret void
}

LLVM IR (-O2):
%struct.utmpx = type { i64 }
@USER_PROCESS = global i64 0
define void @process_online_users(i32 %0, i8* (i8*)* nocapture %1) {
%3 = alloca i32
%4 = tail call i32 (...) @setutxent()
%5 = call %struct.utmpx* (...) @getutxent()
%6 = icmp eq %struct.utmpx* %5, null
br i1 %6, label %30, label %7
7: ; preds = %2
%8 = bitcast i32* %3 to i8*
%9 = icmp eq i32 %0, 0
br label %10
10: ; preds = %7, %16
%11 = phi %struct.utmpx* [ %5, %7 ], [ %17, %16 ]
%12 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %11, i64 0, i32 0
%13 = load i64, i64* %12
%14 = load i64, i64* @USER_PROCESS
%15 = icmp eq i64 %13, %14
br i1 %15, label %19, label %16
16: ; preds = %10, %28
%17 = call %struct.utmpx* (...) @getutxent()
%18 = icmp eq %struct.utmpx* %17, null
br i1 %18, label %30, label %10
19: ; preds = %10
%20 = call i8* @parse_user(%struct.utmpx* %11, i32* %3)
%21 = icmp eq i8* %20, null
br i1 %21, label %32, label %22
22: ; preds = %19
br i1 %9, label %26, label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = call i32 @flush(i32 %0, i8* %20, i32 %24)
br label %28
26: ; preds = %22
%27 = call i8* %1(i8* %20)
br label %28
28: ; preds = %26, %23
%29 = call i32 @free(i8* %20)
br label %16
30: ; preds = %16, %2
%31 = call i32 (...) @endutxent()
br label %33
32: ; preds = %19
br label %33
33: ; preds = %32, %30
ret void
}