#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef scalar_t__ time_t;
struct TYPE_2__ {
  scalar_t__ tv_sec;
};
struct utmp {
  scalar_t__ ut_type;
  char *ut_user;
  char *ut_line;
  char *ut_host;
  TYPE_1__ ut_tv;
};

/* Variables and functions */
scalar_t__ USER_PROCESS;
char *ctime(scalar_t__ *);
struct utmp *getutent();
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int /*<<< orphan*/ time(scalar_t__ *);
int get_user(char *l) {
  struct utmp *p;
  char line[1024];
  time_t t, now;
  char *s;
  time(&now);
  s = ctime(&now);
  while (p = getutent()) {
    if (p->ut_type == USER_PROCESS) {
      t = (time_t)p->ut_tv.tv_sec;
      sprintf(line, "\t%s %s %s %s", p->ut_user, p->ut_line, p->ut_host,
              ctime(&t));
      line[strlen(line) - 1] = '\0';
      strcat(l, line);
    }
  }
}


x86 assembly (clang, -O0):
<get_user>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x430(%rbp),%rdi
call   1050 <time@plt>
lea    -0x430(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,-0x438(%rbp)
mov    $0x0,%al
call   1060 <getutent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1269 <get_user+0x109>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2e37(%rip),%rcx
cmp    (%rcx),%rax
jne    1264 <get_user+0x104>
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x428(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x458(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x450(%rbp)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x448(%rbp)
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x440(%rbp)
lea    -0x428(%rbp),%rdi
call   1030 <ctime@plt>
mov    -0x458(%rbp),%rdi
mov    -0x450(%rbp),%rdx
mov    -0x448(%rbp),%rcx
mov    -0x440(%rbp),%r8
mov    %rax,%r9
lea    0xdca(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x420(%rbp,%rax,1)
mov    -0x10(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   1070 <strcat@plt>
jmp    118e <get_user+0x2e>
mov    -0x4(%rbp),%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_user>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rdi,%r12
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <time@plt>
mov    %rbx,%rdi
call   1030 <ctime@plt>
xor    %eax,%eax
call   1060 <getutent@plt>
test   %rax,%rax
je     1218 <get_user+0xb8>
mov    0x2e48(%rip),%r15
lea    0x10(%rsp),%r13
jmp    11bc <get_user+0x5c>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getutent@plt>
test   %rax,%rax
je     1218 <get_user+0xb8>
mov    (%rax),%rcx
cmp    (%r15),%rcx
jne    11b0 <get_user+0x50>
mov    0x20(%rax),%rcx
mov    %rcx,(%rsp)
mov    0x8(%rax),%rbx
mov    0x10(%rax),%rbp
mov    0x18(%rax),%r14
mov    %rsp,%rdi
call   1030 <ctime@plt>
mov    %r13,%rdi
lea    0xe16(%rip),%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
mov    %r14,%r8
mov    %rax,%r9
call   1080 <sprintf@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r13,1)
mov    %r12,%rdi
mov    %r13,%rsi
call   1070 <strcat@plt>
jmp    11b0 <get_user+0x50>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.utmp = type { i64, i8*, i8*, i8*, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64 }
@USER_PROCESS = global i64 0
@.str = [13 x i8] c"\09%s %s %s %s\00"
define i32 @get_user(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.utmp*
%5 = alloca [1024 x i8]
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
store i8* %0, i8** %3
%9 = call i32 @time(i64* %7)
%10 = call i8* @ctime(i64* %7)
store i8* %10, i8** %8
br label %11
11: ; preds = %45, %1
%12 = call %struct.utmp* (...) @getutent()
store %struct.utmp* %12, %struct.utmp** %4
%13 = icmp ne %struct.utmp* %12, null
br i1 %13, label %14, label %46
14: ; preds = %11
%15 = load %struct.utmp*, %struct.utmp** %4
%16 = getelementptr inbounds %struct.utmp, %struct.utmp* %15, i32 0, i32 0
%17 = load i64, i64* %16
%18 = load i64, i64* @USER_PROCESS
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %45
20: ; preds = %14
%21 = load %struct.utmp*, %struct.utmp** %4
%22 = getelementptr inbounds %struct.utmp, %struct.utmp* %21, i32 0, i32 4
%23 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %22, i32 0, i32 0
%24 = load i64, i64* %23
store i64 %24, i64* %6
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%26 = load %struct.utmp*, %struct.utmp** %4
%27 = getelementptr inbounds %struct.utmp, %struct.utmp* %26, i32 0, i32 1
%28 = load i8*, i8** %27
%29 = load %struct.utmp*, %struct.utmp** %4
%30 = getelementptr inbounds %struct.utmp, %struct.utmp* %29, i32 0, i32 2
%31 = load i8*, i8** %30
%32 = load %struct.utmp*, %struct.utmp** %4
%33 = getelementptr inbounds %struct.utmp, %struct.utmp* %32, i32 0, i32 3
%34 = load i8*, i8** %33
%35 = call i8* @ctime(i64* %6)
%36 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %28, i8* %31, i8* %34, i8* %35)
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%38 = call i32 @strlen(i8* %37)
%39 = sub nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %40
store i8 0, i8* %41
%42 = load i8*, i8** %3
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%44 = call i32 @strcat(i8* %42, i8* %43)
br label %45
45: ; preds = %20, %14
br label %11
46: ; preds = %11
%47 = load i32, i32* %2
ret i32 %47
}

LLVM IR (-O2):
%struct.utmp = type { i64, i8*, i8*, i8*, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64 }
@USER_PROCESS = global i64 0
@.str = [13 x i8] c"\09%s %s %s %s\00"
define i32 @get_user(i8* %0) {
%2 = alloca [1024 x i8]
%3 = alloca i64
%4 = alloca i64
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = bitcast i64* %3 to i8*
%7 = bitcast i64* %4 to i8*
%8 = call i32 @time(i64* %4)
%9 = call i8* @ctime(i64* %4)
%10 = call %struct.utmp* (...) @getutent()
%11 = icmp eq %struct.utmp* %10, null
br i1 %11, label %37, label %12
12: ; preds = %1, %34
%13 = phi %struct.utmp* [ %35, %34 ], [ %10, %1 ]
%14 = getelementptr inbounds %struct.utmp, %struct.utmp* %13, i64 0, i32 0
%15 = load i64, i64* %14
%16 = load i64, i64* @USER_PROCESS
%17 = icmp eq i64 %15, %16
br i1 %17, label %18, label %34
18: ; preds = %12
%19 = getelementptr inbounds %struct.utmp, %struct.utmp* %13, i64 0, i32 4, i32 0
%20 = load i64, i64* %19
store i64 %20, i64* %3
%21 = getelementptr inbounds %struct.utmp, %struct.utmp* %13, i64 0, i32 1
%22 = load i8*, i8** %21
%23 = getelementptr inbounds %struct.utmp, %struct.utmp* %13, i64 0, i32 2
%24 = load i8*, i8** %23
%25 = getelementptr inbounds %struct.utmp, %struct.utmp* %13, i64 0, i32 3
%26 = load i8*, i8** %25
%27 = call i8* @ctime(i64* %3)
%28 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %22, i8* %24, i8* %26, i8* %27)
%29 = call i32 @strlen(i8* %5)
%30 = add nsw i32 %29, -1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %31
store i8 0, i8* %32
%33 = call i32 @strcat(i8* %0, i8* %5)
br label %34
34: ; preds = %18, %12
%35 = call %struct.utmp* (...) @getutent()
%36 = icmp eq %struct.utmp* %35, null
br i1 %36, label %37, label %12
37: ; preds = %34, %1
ret i32 undef
}