#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;
  char *ut_user;
  char *ut_line;
  char *ut_host;
};

/* Variables and functions */
scalar_t__ USER_PROCESS;
struct utmpx *getutxent();
int /*<<< orphan*/ printf(char *, char *, char *, char *);
int main() {
  struct utmpx *utmp_info;
  while ((utmp_info = getutxent()) != NULL) {
    if (utmp_info->ut_type != USER_PROCESS)
      continue;
    printf("%s; %s; %s\n", utmp_info->ut_user, utmp_info->ut_line,
           utmp_info->ut_host);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getutxent@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1189 <main+0x69>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e96(%rip),%rcx
cmp    (%rcx),%rax
je     1160 <main+0x40>
jmp    112f <main+0xf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getutxent@plt>
test   %rax,%rax
je     116a <main+0x4a>
mov    0x2eb1(%rip),%rbx
lea    0xec2(%rip),%r14
jmp    114c <main+0x2c>
xor    %eax,%eax
call   1040 <getutxent@plt>
test   %rax,%rax
je     116a <main+0x4a>
mov    (%rax),%rcx
cmp    (%rbx),%rcx
jne    1140 <main+0x20>
mov    0x8(%rax),%rsi
mov    0x10(%rax),%rdx
mov    0x18(%rax),%rcx
mov    %r14,%rdi
call   1030 <printf@plt>
jmp    1140 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.utmpx = type { i64, i8*, i8*, i8* }
@USER_PROCESS = global i64 0
@.str = [12 x i8] c"%s; %s; %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.utmpx*
store i32 0, i32* %1
br label %3
3: ; preds = %13, %12, %0
%4 = call %struct.utmpx* (...) @getutxent()
store %struct.utmpx* %4, %struct.utmpx** %2
%5 = icmp ne %struct.utmpx* %4, null
br i1 %5, label %6, label %24
6: ; preds = %3
%7 = load %struct.utmpx*, %struct.utmpx** %2
%8 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %7, i32 0, i32 0
%9 = load i64, i64* %8
%10 = load i64, i64* @USER_PROCESS
%11 = icmp ne i64 %9, %10
br i1 %11, label %12, label %13
12: ; preds = %6
br label %3
13: ; preds = %6
%14 = load %struct.utmpx*, %struct.utmpx** %2
%15 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %14, i32 0, i32 1
%16 = load i8*, i8** %15
%17 = load %struct.utmpx*, %struct.utmpx** %2
%18 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %17, i32 0, i32 2
%19 = load i8*, i8** %18
%20 = load %struct.utmpx*, %struct.utmpx** %2
%21 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %20, i32 0, i32 3
%22 = load i8*, i8** %21
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %19, i8* %22)
br label %3
24: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
%struct.utmpx = type { i64, i8*, i8*, i8* }
@USER_PROCESS = global i64 0
@.str = [12 x i8] c"%s; %s; %s\0A\00"
define i32 @main() {
%1 = tail call %struct.utmpx* (...) @getutxent()
%2 = icmp eq %struct.utmpx* %1, null
br i1 %2, label %20, label %3
3: ; preds = %0, %17
%4 = phi %struct.utmpx* [ %18, %17 ], [ %1, %0 ]
%5 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %4, i64 0, i32 0
%6 = load i64, i64* %5
%7 = load i64, i64* @USER_PROCESS
%8 = icmp eq i64 %6, %7
br i1 %8, label %9, label %17
9: ; preds = %3
%10 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %4, i64 0, i32 1
%11 = load i8*, i8** %10
%12 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %4, i64 0, i32 2
%13 = load i8*, i8** %12
%14 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %4, i64 0, i32 3
%15 = load i8*, i8** %14
%16 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %13, i8* %15)
br label %17
17: ; preds = %9, %3
%18 = tail call %struct.utmpx* (...) @getutxent()
%19 = icmp eq %struct.utmpx* %18, null
br i1 %19, label %20, label %3
20: ; preds = %17, %0
ret i32 0
}