#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 */
typedef int /*<<< orphan*/ time_t;
struct utmp {
  int ut_type;
  char *ut_user;
  char *ut_line;
  char *ut_host;
  int /*<<< orphan*/ ut_time;
};

/* Variables and functions */
int /*<<< orphan*/ ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ endutent();
struct utmp *getutent();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setutent();
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
void my_who() {
  struct utmp *info;
  char tmps[80];
  setutent();
  info = getutent();
  while (info != NULL) {
    if (info->ut_type == 7) {
      printf("%-9s", info->ut_user);
      printf("%-12s", info->ut_line);
      time_t *time;
      time = &info->ut_time;
      strcpy(tmps, ctime(time));
      printf("%s", tmps);
      printf(" (");
      printf("%s", info->ut_host);
      printf(")\n");
    }
    info = getutent();
  }
  endutent();
}


x86 assembly (clang, -O0):
<my_who>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    $0x0,%al
call   1080 <setutent@plt>
mov    $0x0,%al
call   1070 <getutent@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     123a <my_who+0xda>
mov    -0x8(%rbp),%rax
cmpl   $0x7,(%rax)
jne    122a <my_who+0xca>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x68(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x68(%rbp),%rdi
call   1040 <ctime@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
lea    -0x60(%rbp),%rsi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getutent@plt>
mov    %rax,-0x8(%rbp)
jmp    117a <my_who+0x1a>
mov    $0x0,%al
call   1060 <endutent@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_who>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
xor    %eax,%eax
call   1090 <setutent@plt>
xor    %eax,%eax
call   1080 <getutent@plt>
test   %rax,%rax
je     1237 <my_who+0xc7>
mov    %rax,%r14
lea    0xe66(%rip),%r15
mov    %rsp,%r12
lea    0xe62(%rip),%rbx
lea    0xe5e(%rip),%r13
lea    0xe5a(%rip),%rbp
jmp    11cf <my_who+0x5f>
nopl   0x0(%rax)
xor    %eax,%eax
call   1080 <getutent@plt>
mov    %rax,%r14
test   %rax,%rax
je     1237 <my_who+0xc7>
cmpl   $0x7,(%r14)
jne    11c0 <my_who+0x50>
mov    0x8(%r14),%rsi
lea    0xe20(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%r14),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x20(%r14),%rdi
call   1050 <ctime@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%r14),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
jmp    11c0 <my_who+0x50>
xor    %eax,%eax
call   1070 <endutent@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.utmp = type { i32, i8*, i8*, i8*, i32 }
@.str = [5 x i8] c"%-9s\00"
@.str.1 = [6 x i8] c"%-12s\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [3 x i8] c" (\00"
@.str.4 = [3 x i8] c")\0A\00"
define void @my_who() {
%1 = alloca %struct.utmp*
%2 = alloca [80 x i8]
%3 = alloca i32*
%4 = call i32 (...) @setutent()
%5 = call %struct.utmp* (...) @getutent()
store %struct.utmp* %5, %struct.utmp** %1
br label %6
6: ; preds = %37, %0
%7 = load %struct.utmp*, %struct.utmp** %1
%8 = icmp ne %struct.utmp* %7, null
br i1 %8, label %9, label %39
9: ; preds = %6
%10 = load %struct.utmp*, %struct.utmp** %1
%11 = getelementptr inbounds %struct.utmp, %struct.utmp* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, 7
br i1 %13, label %14, label %37
14: ; preds = %9
%15 = load %struct.utmp*, %struct.utmp** %1
%16 = getelementptr inbounds %struct.utmp, %struct.utmp* %15, i32 0, i32 1
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load %struct.utmp*, %struct.utmp** %1
%20 = getelementptr inbounds %struct.utmp, %struct.utmp* %19, i32 0, i32 2
%21 = load i8*, i8** %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load %struct.utmp*, %struct.utmp** %1
%24 = getelementptr inbounds %struct.utmp, %struct.utmp* %23, i32 0, i32 4
store i32* %24, i32** %3
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%26 = load i32*, i32** %3
%27 = call i32 @ctime(i32* %26)
%28 = call i32 @strcpy(i8* %25, i32 %27)
%29 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%32 = load %struct.utmp*, %struct.utmp** %1
%33 = getelementptr inbounds %struct.utmp, %struct.utmp* %32, i32 0, i32 3
%34 = load i8*, i8** %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %37
37: ; preds = %14, %9
%38 = call %struct.utmp* (...) @getutent()
store %struct.utmp* %38, %struct.utmp** %1
br label %6
39: ; preds = %6
%40 = call i32 (...) @endutent()
ret void
}

LLVM IR (-O2):
%struct.utmp = type { i32, i8*, i8*, i8*, i32 }
@.str = [5 x i8] c"%-9s\00"
@.str.1 = [6 x i8] c"%-12s\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [3 x i8] c" (\00"
@str = [2 x i8] c")\00"
define void @my_who() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @setutent()
%4 = tail call %struct.utmp* (...) @getutent()
%5 = icmp eq %struct.utmp* %4, null
br i1 %5, label %30, label %6
6: ; preds = %0, %27
%7 = phi %struct.utmp* [ %28, %27 ], [ %4, %0 ]
%8 = getelementptr inbounds %struct.utmp, %struct.utmp* %7, i64 0, i32 0
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 7
br i1 %10, label %11, label %27
11: ; preds = %6
%12 = getelementptr inbounds %struct.utmp, %struct.utmp* %7, i64 0, i32 1
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds %struct.utmp, %struct.utmp* %7, i64 0, i32 2
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds %struct.utmp, %struct.utmp* %7, i64 0, i32 4
%19 = call i32 @ctime(i32* %18)
%20 = call i32 @strcpy(i8* %2, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%23 = getelementptr inbounds %struct.utmp, %struct.utmp* %7, i64 0, i32 3
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %27
27: ; preds = %11, %6
%28 = call %struct.utmp* (...) @getutent()
%29 = icmp eq %struct.utmp* %28, null
br i1 %29, label %30, label %6
30: ; preds = %27, %0
%31 = call i32 (...) @endutent()
ret void
}