#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 u_int;
struct passwd {
  char *pw_name;
};
struct group {
  char *gr_name;
};

/* Variables and functions */
int /*<<< orphan*/ err(int, char *);
int getegid();
int geteuid();
int getgid();
struct group *getgrgid(int);
char *getlogin();
struct passwd *getpwuid(int);
int getuid();
int /*<<< orphan*/ group(struct passwd *, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char const *, char *);
void pretty(struct passwd *pw) {
  struct group *gr;
  u_int eid, rid;
  const char *login;
  if (pw) {
    (void)printf("uid\t%s\n", pw->pw_name);
    (void)printf("groups\t");
    group(pw, 1);
  } else {
    if ((login = getlogin()) == NULL)
      err(1, "getlogin");
    pw = getpwuid(rid = getuid());
    if (pw == NULL || strcmp(login, pw->pw_name))
      (void)printf("login\t%s\n", login);
    if (pw)
      (void)printf("uid\t%s\n", pw->pw_name);
    else
      (void)printf("uid\t%u\n", rid);
    if ((eid = geteuid()) != rid) {
      if ((pw = getpwuid(eid)) != NULL)
        (void)printf("euid\t%s\n", pw->pw_name);
      else
        (void)printf("euid\t%u\n", eid);
    }
    if ((rid = getgid()) != (eid = getegid())) {
      if ((gr = getgrgid(rid)) != NULL)
        (void)printf("rgid\t%s\n", gr->gr_name);
      else
        (void)printf("rgid\t%u\n", rid);
    }
    (void)printf("groups\t");
    group(NULL, 1);
  }
}


x86 assembly (clang, -O0):
<pretty>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11fd <pretty+0x4d>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   10b0 <group@plt>
jmp    1384 <pretty+0x1d4>
mov    $0x0,%al
call   10c0 <getlogin@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1223 <pretty+0x73>
mov    $0x1,%edi
lea    0xdea(%rip),%rsi
call   10a0 <err@plt>
mov    $0x0,%al
call   1040 <getuid@plt>
mov    %eax,%edi
mov    %edi,-0x18(%rbp)
call   1030 <getpwuid@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     125d <pretty+0xad>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     126f <pretty+0xbf>
mov    -0x20(%rbp),%rsi
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x8(%rbp)
je     1294 <pretty+0xe4>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12a5 <pretty+0xf5>
mov    -0x18(%rbp),%esi
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <geteuid@plt>
mov    %eax,-0x14(%rbp)
cmp    -0x18(%rbp),%eax
je     12fe <pretty+0x14e>
mov    -0x14(%rbp),%edi
call   1030 <getpwuid@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     12e8 <pretty+0x138>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12f9 <pretty+0x149>
mov    -0x14(%rbp),%esi
lea    0xd32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12fe <pretty+0x14e>
mov    $0x0,%al
call   1090 <getgid@plt>
mov    %eax,-0x24(%rbp)
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   10d0 <getegid@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
mov    %ecx,-0x14(%rbp)
cmp    %ecx,%eax
je     1368 <pretty+0x1b8>
mov    -0x18(%rbp),%edi
call   1060 <getgrgid@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1352 <pretty+0x1a2>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xce7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1363 <pretty+0x1b3>
mov    -0x18(%rbp),%esi
lea    0xcda(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1368 <pretty+0x1b8>
lea    0xc91(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
mov    $0x1,%esi
call   10b0 <group@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pretty>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     11e3 <pretty+0x33>
mov    %rdi,%rbx
mov    (%rdi),%rsi
lea    0xe56(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe2c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
jmp    1303 <pretty+0x153>
xor    %eax,%eax
call   10c0 <getlogin@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1203 <pretty+0x53>
lea    0xe0f(%rip),%rsi
mov    $0x1,%edi
call   10a0 <err@plt>
xor    %eax,%eax
call   1040 <getuid@plt>
mov    %eax,%r14d
mov    %eax,%edi
call   1030 <getpwuid@plt>
test   %rax,%rax
je     1251 <pretty+0xa1>
mov    %rax,%rbp
mov    (%rax),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     123d <pretty+0x8d>
lea    0xdde(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%rbp),%rsi
lea    0xdd4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1273 <pretty+0xc3>
lea    0xdb9(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdbc(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <geteuid@plt>
cmp    %r14d,%eax
je     12b0 <pretty+0x100>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <getpwuid@plt>
test   %rax,%rax
je     12a0 <pretty+0xf0>
mov    (%rax),%rsi
lea    0xd84(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12b0 <pretty+0x100>
lea    0xd7d(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <getgid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   10d0 <getegid@plt>
cmp    %eax,%ebx
je     12f3 <pretty+0x143>
mov    %ebx,%edi
call   1060 <getgrgid@plt>
test   %rax,%rax
je     12e3 <pretty+0x133>
mov    (%rax),%rsi
lea    0xd53(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12f3 <pretty+0x143>
lea    0xd4c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd06(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
mov    $0x1,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    10b0 <group@plt>

LLVM IR (-O0):
%struct.passwd = type { i8* }
%struct.group = type { i8* }
@.str = [8 x i8] c"uid\09%s\0A\00"
@.str.1 = [8 x i8] c"groups\09\00"
@.str.2 = [9 x i8] c"getlogin\00"
@.str.3 = [10 x i8] c"login\09%s\0A\00"
@.str.4 = [8 x i8] c"uid\09%u\0A\00"
@.str.5 = [9 x i8] c"euid\09%s\0A\00"
@.str.6 = [9 x i8] c"euid\09%u\0A\00"
@.str.7 = [9 x i8] c"rgid\09%s\0A\00"
@.str.8 = [9 x i8] c"rgid\09%u\0A\00"
define void @pretty(%struct.passwd* %0) {
%2 = alloca %struct.passwd*
%3 = alloca %struct.group*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store %struct.passwd* %0, %struct.passwd** %2
%7 = load %struct.passwd*, %struct.passwd** %2
%8 = icmp ne %struct.passwd* %7, null
br i1 %8, label %9, label %17
9: ; preds = %1
%10 = load %struct.passwd*, %struct.passwd** %2
%11 = getelementptr inbounds %struct.passwd, %struct.passwd* %10, i32 0, i32 0
%12 = load i8*, i8** %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%15 = load %struct.passwd*, %struct.passwd** %2
%16 = call i32 @group(%struct.passwd* %15, i32 1)
br label %85
17: ; preds = %1
%18 = call i8* (...) @getlogin()
store i8* %18, i8** %6
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @err(i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = call i32 (...) @getuid()
store i32 %23, i32* %5
%24 = call %struct.passwd* @getpwuid(i32 %23)
store %struct.passwd* %24, %struct.passwd** %2
%25 = load %struct.passwd*, %struct.passwd** %2
%26 = icmp eq %struct.passwd* %25, null
br i1 %26, label %34, label %27
27: ; preds = %22
%28 = load i8*, i8** %6
%29 = load %struct.passwd*, %struct.passwd** %2
%30 = getelementptr inbounds %struct.passwd, %struct.passwd* %29, i32 0, i32 0
%31 = load i8*, i8** %30
%32 = call i64 @strcmp(i8* %28, i8* %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %27, %22
%35 = load i8*, i8** %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %34, %27
%38 = load %struct.passwd*, %struct.passwd** %2
%39 = icmp ne %struct.passwd* %38, null
br i1 %39, label %40, label %45
40: ; preds = %37
%41 = load %struct.passwd*, %struct.passwd** %2
%42 = getelementptr inbounds %struct.passwd, %struct.passwd* %41, i32 0, i32 0
%43 = load i8*, i8** %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %43)
br label %48
45: ; preds = %37
%46 = load i32, i32* %5
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %45, %40
%49 = call i32 (...) @geteuid()
store i32 %49, i32* %4
%50 = load i32, i32* %5
%51 = icmp ne i32 %49, %50
br i1 %51, label %52, label %65
52: ; preds = %48
%53 = load i32, i32* %4
%54 = call %struct.passwd* @getpwuid(i32 %53)
store %struct.passwd* %54, %struct.passwd** %2
%55 = icmp ne %struct.passwd* %54, null
br i1 %55, label %56, label %61
56: ; preds = %52
%57 = load %struct.passwd*, %struct.passwd** %2
%58 = getelementptr inbounds %struct.passwd, %struct.passwd* %57, i32 0, i32 0
%59 = load i8*, i8** %58
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %59)
br label %64
61: ; preds = %52
%62 = load i32, i32* %4
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %61, %56
br label %65
65: ; preds = %64, %48
%66 = call i32 (...) @getgid()
store i32 %66, i32* %5
%67 = call i32 (...) @getegid()
store i32 %67, i32* %4
%68 = icmp ne i32 %66, %67
br i1 %68, label %69, label %82
69: ; preds = %65
%70 = load i32, i32* %5
%71 = call %struct.group* @getgrgid(i32 %70)
store %struct.group* %71, %struct.group** %3
%72 = icmp ne %struct.group* %71, null
br i1 %72, label %73, label %78
73: ; preds = %69
%74 = load %struct.group*, %struct.group** %3
%75 = getelementptr inbounds %struct.group, %struct.group* %74, i32 0, i32 0
%76 = load i8*, i8** %75
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %76)
br label %81
78: ; preds = %69
%79 = load i32, i32* %5
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 %79)
br label %81
81: ; preds = %78, %73
br label %82
82: ; preds = %81, %65
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%84 = call i32 @group(%struct.passwd* null, i32 1)
br label %85
85: ; preds = %82, %9
ret void
}

LLVM IR (-O2):
%struct.passwd = type { i8* }
%struct.group = type { i8* }
@.str = [8 x i8] c"uid\09%s\0A\00"
@.str.1 = [8 x i8] c"groups\09\00"
@.str.2 = [9 x i8] c"getlogin\00"
@.str.3 = [10 x i8] c"login\09%s\0A\00"
@.str.4 = [8 x i8] c"uid\09%u\0A\00"
@.str.5 = [9 x i8] c"euid\09%s\0A\00"
@.str.6 = [9 x i8] c"euid\09%u\0A\00"
@.str.7 = [9 x i8] c"rgid\09%s\0A\00"
@.str.8 = [9 x i8] c"rgid\09%u\0A\00"
define void @pretty(%struct.passwd* %0) {
%2 = icmp eq %struct.passwd* %0, null
br i1 %2, label %9, label %3
3: ; preds = %1
%4 = getelementptr inbounds %struct.passwd, %struct.passwd* %0, i64 0, i32 0
%5 = load i8*, i8** %4
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @group(%struct.passwd* %0, i32 1)
br label %59
9: ; preds = %1
%10 = tail call i8* (...) @getlogin()
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
%15 = tail call i32 (...) @getuid()
%16 = tail call %struct.passwd* @getpwuid(i32 %15)
%17 = icmp eq %struct.passwd* %16, null
br i1 %17, label %28, label %18
18: ; preds = %14
%19 = getelementptr inbounds %struct.passwd, %struct.passwd* %16, i64 0, i32 0
%20 = load i8*, i8** %19
%21 = tail call i64 @strcmp(i8* %10, i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %18
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %10)
br label %25
25: ; preds = %18, %23
%26 = load i8*, i8** %19
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %26)
br label %31
28: ; preds = %14
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %15)
br label %31
31: ; preds = %28, %25
%32 = tail call i32 (...) @geteuid()
%33 = icmp eq i32 %32, %15
br i1 %33, label %43, label %34
34: ; preds = %31
%35 = tail call %struct.passwd* @getpwuid(i32 %32)
%36 = icmp eq %struct.passwd* %35, null
br i1 %36, label %41, label %37
37: ; preds = %34
%38 = getelementptr inbounds %struct.passwd, %struct.passwd* %35, i64 0, i32 0
%39 = load i8*, i8** %38
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %39)
br label %43
41: ; preds = %34
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %32)
br label %43
43: ; preds = %37, %41, %31
%44 = tail call i32 (...) @getgid()
%45 = tail call i32 (...) @getegid()
%46 = icmp eq i32 %44, %45
br i1 %46, label %56, label %47
47: ; preds = %43
%48 = tail call %struct.group* @getgrgid(i32 %44)
%49 = icmp eq %struct.group* %48, null
br i1 %49, label %54, label %50
50: ; preds = %47
%51 = getelementptr inbounds %struct.group, %struct.group* %48, i64 0, i32 0
%52 = load i8*, i8** %51
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %52)
br label %56
54: ; preds = %47
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 %44)
br label %56
56: ; preds = %50, %54, %43
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%58 = tail call i32 @group(%struct.passwd* null, i32 1)
br label %59
59: ; preds = %56, %3
ret void
}