#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 scalar_t__ uid_t;
typedef int /*<<< orphan*/ in_line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ _parse_line(char *, char **, int *);
long _time_login(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ geteuid();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
main(int argc, char **argv) {
  FILE *passwd_fd;
  char in_line[256], *user_name;
  int i, user_id;
  long int delta_t;
  if (geteuid() != (uid_t)0) {
    printf("need to run as user root\n");
    exit(1);
  }
  for (i = 1; i < argc; i++) {
    delta_t = _time_login(argv[i]);
    printf("user %-8s time %ld usec\n", argv[i], delta_t);
  }
  if (i > 1)
    exit(0);
  passwd_fd = fopen("/etc/passwd", "r");
  if (!passwd_fd) {
    perror("fopen(/etc/passwd)");
    exit(1);
  }
  while (fgets(in_line, sizeof(in_line), passwd_fd)) {
    _parse_line(in_line, &user_name, &user_id);
    if (user_id <= 100)
      continue;
    delta_t = _time_login(user_name);
    if (delta_t < ((8000 * 0.8) * 1000))
      continue;
    printf("user %-8s time %ld usec\n", user_name, delta_t);
  }
  fclose(passwd_fd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <geteuid@plt>
cmp    $0x0,%rax
je     11d2 <main+0x42>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
movl   $0x1,-0x12c(%rbp)
mov    -0x12c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    123e <main+0xae>
mov    -0x10(%rbp),%rax
movslq -0x12c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <_time_login@plt>
mov    %rax,-0x138(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x12c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x138(%rbp),%rdx
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x12c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x12c(%rbp)
jmp    11dc <main+0x4c>
cmpl   $0x1,-0x12c(%rbp)
jle    1252 <main+0xc2>
xor    %edi,%edi
call   10b0 <exit@plt>
lea    0xde2(%rip),%rdi
lea    0xde7(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    128a <main+0xfa>
lea    0xdce(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    128f <main+0xff>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     132e <main+0x19e>
lea    -0x120(%rbp),%rdi
lea    -0x128(%rbp),%rsi
lea    -0x130(%rbp),%rdx
call   1080 <_parse_line@plt>
cmpl   $0x64,-0x130(%rbp)
jg     12da <main+0x14a>
jmp    128f <main+0xff>
mov    -0x128(%rbp),%rdi
call   1040 <_time_login@plt>
mov    %rax,-0x138(%rbp)
cvtsi2sdq -0x138(%rbp),%xmm1
ff ff
movsd  0xd02(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    130d <main+0x17d>
jmp    128f <main+0xff>
mov    -0x128(%rbp),%rsi
mov    -0x138(%rbp),%rdx
lea    0xd00(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    128f <main+0xff>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x110,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
xor    %eax,%eax
call   1070 <geteuid@plt>
test   %rax,%rax
jne    12ca <main+0x12a>
cmp    $0x2,%r14d
jl     120d <main+0x6d>
mov    %r14d,%r12d
mov    $0x1,%ebp
lea    0xe26(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rdi
call   1050 <_time_login@plt>
mov    (%rbx,%rbp,8),%rsi
mov    %r15,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    11e0 <main+0x40>
cmp    $0x2,%r14d
jae    12f6 <main+0x156>
lea    0xe05(%rip),%rdi
lea    0xe0a(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12e0 <main+0x140>
mov    %rax,%r14
lea    0x10(%rsp),%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12b0 <main+0x110>
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r15
lea    0x4(%rsp),%rbp
lea    0xda7(%rip),%r12
jmp    1275 <main+0xd5>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12b0 <main+0x110>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1090 <_parse_line@plt>
cmpl   $0x65,0x4(%rsp)
jl     1260 <main+0xc0>
mov    0x8(%rsp),%rdi
call   1050 <_time_login@plt>
cmp    $0x61a800,%rax
jl     1260 <main+0xc0>
mov    0x8(%rsp),%rsi
mov    %r12,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1260 <main+0xc0>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd69(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xd40(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"need to run as user root\0A\00"
@.str.1 = [25 x i8] c"user %-8s time %ld usec\0A\00"
@.str.2 = [12 x i8] c"/etc/passwd\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [19 x i8] c"fopen(/etc/passwd)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [256 x i8]
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i64 (...) @geteuid()
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
store i32 1, i32* %9
br label %18
18: ; preds = %36, %17
%19 = load i32, i32* %9
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %39
22: ; preds = %18
%23 = load i8**, i8*** %5
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i64 @_time_login(i8* %27)
store i64 %28, i64* %11
%29 = load i8**, i8*** %5
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = load i64, i64* %11
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %33, i64 %34)
br label %36
36: ; preds = %22
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
store i32 %38, i32* %9
br label %18
39: ; preds = %18
%40 = load i32, i32* %9
%41 = icmp sgt i32 %40, 1
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %39
%45 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %45, i32** %6
%46 = load i32*, i32** %6
%47 = icmp ne i32* %46, null
br i1 %47, label %51, label %48
48: ; preds = %44
%49 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %44
br label %52
52: ; preds = %70, %69, %62, %51
%53 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%54 = load i32*, i32** %6
%55 = call i64 @fgets(i8* %53, i32 256, i32* %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %74
57: ; preds = %52
%58 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%59 = call i32 @_parse_line(i8* %58, i8** %8, i32* %10)
%60 = load i32, i32* %10
%61 = icmp sle i32 %60, 100
br i1 %61, label %62, label %63
62: ; preds = %57
br label %52
63: ; preds = %57
%64 = load i8*, i8** %8
%65 = call i64 @_time_login(i8* %64)
store i64 %65, i64* %11
%66 = load i64, i64* %11
%67 = sitofp i64 %66 to double
%68 = fcmp olt double %67, 6.400000e+06
br i1 %68, label %69, label %70
69: ; preds = %63
br label %52
70: ; preds = %63
%71 = load i8*, i8** %8
%72 = load i64, i64* %11
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %71, i64 %72)
br label %52
74: ; preds = %52
%75 = load i32*, i32** %6
%76 = call i32 @fclose(i32* %75)
%77 = load i32, i32* %3
ret i32 %77
}

LLVM IR (-O2):
@.str.1 = [25 x i8] c"user %-8s time %ld usec\0A\00"
@.str.2 = [12 x i8] c"/etc/passwd\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [19 x i8] c"fopen(/etc/passwd)\00"
@str = [25 x i8] c"need to run as user root\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca i8*
%5 = alloca i32
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = bitcast i8** %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = tail call i64 (...) @geteuid()
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = icmp sgt i32 %0, 1
br i1 %12, label %13, label %31
13: ; preds = %11
%14 = zext i32 %0 to i64
br label %18
15: ; preds = %2
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %13, %18
%19 = phi i64 [ 1, %13 ], [ %25, %18 ]
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
%22 = tail call i64 @_time_login(i8* %21)
%23 = load i8*, i8** %20
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %23, i64 %22)
%25 = add nuw nsw i64 %19, 1
%26 = icmp eq i64 %25, %14
br i1 %26, label %27, label %18
27: ; preds = %18
%28 = icmp ugt i32 %0, 1
br i1 %28, label %29, label %31
29: ; preds = %27
%30 = tail call i32 @exit(i32 0)
unreachable
31: ; preds = %11, %27
%32 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp eq i32* %32, null
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = call i64 @fgets(i8* %6, i32 256, i32* %32)
%36 = icmp eq i64 %35, 0
br i1 %36, label %54, label %40
37: ; preds = %31
%38 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%39 = tail call i32 @exit(i32 1)
unreachable
40: ; preds = %34, %51
%41 = call i32 @_parse_line(i8* %6, i8** %4, i32* %5)
%42 = load i32, i32* %5
%43 = icmp slt i32 %42, 101
br i1 %43, label %51, label %44
44: ; preds = %40
%45 = load i8*, i8** %4
%46 = call i64 @_time_login(i8* %45)
%47 = icmp slt i64 %46, 6400000
br i1 %47, label %51, label %48
48: ; preds = %44
%49 = load i8*, i8** %4
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %49, i64 %46)
br label %51
51: ; preds = %48, %40, %44
%52 = call i64 @fgets(i8* %6, i32 256, i32* %32)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %40
54: ; preds = %51, %34
%55 = call i32 @fclose(i32* %32)
ret i32 0
}