#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;
struct passwd {
  char *pw_gecos;
  char *pw_name;
  char *pw_dir;
  char *pw_shell;
  scalar_t__ pw_gid;
  scalar_t__ pw_uid;
};
struct group {
  char *gr_name;
  char **gr_mem;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
struct group *getgrgid(scalar_t__);
struct passwd *getpwuid(scalar_t__);
scalar_t__ getuid();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  uid_t me;
  struct passwd *my_passwd;
  struct group *my_group;
  char **members;
  me = getuid();
  my_passwd = getpwuid(me);
  if (!my_passwd) {
    printf("Couldn't find out about user %d.\n", (int)me);
    exit(EXIT_FAILURE);
  }
  printf("I am %s.\n", my_passwd->pw_gecos);
  printf("My login name is %s.\n", my_passwd->pw_name);
  printf("My uid is %d.\n", (int)(my_passwd->pw_uid));
  printf("My home directory is %s.\n", my_passwd->pw_dir);
  printf("My default shell is %s.\n", my_passwd->pw_shell);
  my_group = getgrgid(my_passwd->pw_gid);
  if (!my_group) {
    printf("Couldn't find out about group %d.\n", (int)my_passwd->pw_gid);
    exit(EXIT_FAILURE);
  }
  printf("My default group is %s (%d).\n", my_group->gr_name,
         (int)(my_passwd->pw_gid));
  printf("The members of this group are:\n");
  members = my_group->gr_mem;
  while (*members) {
    printf("  %s\n", *(members));
    members++;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getuid@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a4 <main+0x54>
mov    -0x10(%rbp),%rax
mov    %eax,%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%rax
mov    %eax,%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rdi
call   1060 <getgrgid@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1255 <main+0x105>
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rax
mov    %eax,%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rax
mov    %eax,%edx
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
je     12c2 <main+0x172>
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
jmp    128e <main+0x13e>
mov    0x2d0f(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getuid@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1040 <getpwuid@plt>
test   %rax,%rax
je     1257 <main+0xf7>
mov    %rax,%rbx
mov    (%rax),%rsi
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rbx),%rsi
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x28(%rbx),%esi
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rbx),%rsi
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rbx),%rsi
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rbx),%rdi
call   1070 <getgrgid@plt>
test   %rax,%rax
je     1263 <main+0x103>
mov    %rax,%r14
mov    (%rax),%rsi
mov    0x20(%rbx),%edx
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%r14),%rbx
mov    (%rbx),%rsi
test   %rsi,%rsi
je     1246 <main+0xe6>
add    $0x8,%rbx
lea    0xea3(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1230 <main+0xd0>
mov    0x2d8b(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xda2(%rip),%rdi
mov    %r14d,%esi
jmp    126d <main+0x10d>
mov    0x20(%rbx),%esi
lea    0xe17(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.passwd = type { i8*, i8*, i8*, i8*, i64, i64 }
%struct.group = type { i8*, i8** }
@.str = [34 x i8] c"Couldn't find out about user %d.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [10 x i8] c"I am %s.\0A\00"
@.str.2 = [22 x i8] c"My login name is %s.\0A\00"
@.str.3 = [15 x i8] c"My uid is %d.\0A\00"
@.str.4 = [26 x i8] c"My home directory is %s.\0A\00"
@.str.5 = [25 x i8] c"My default shell is %s.\0A\00"
@.str.6 = [35 x i8] c"Couldn't find out about group %d.\0A\00"
@.str.7 = [30 x i8] c"My default group is %s (%d).\0A\00"
@.str.8 = [32 x i8] c"The members of this group are:\0A\00"
@.str.9 = [6 x i8] c" %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca %struct.passwd*
%4 = alloca %struct.group*
%5 = alloca i8**
store i32 0, i32* %1
%6 = call i64 (...) @getuid()
store i64 %6, i64* %2
%7 = load i64, i64* %2
%8 = call %struct.passwd* @getpwuid(i64 %7)
store %struct.passwd* %8, %struct.passwd** %3
%9 = load %struct.passwd*, %struct.passwd** %3
%10 = icmp ne %struct.passwd* %9, null
br i1 %10, label %17, label %11
11: ; preds = %0
%12 = load i64, i64* %2
%13 = trunc i64 %12 to i32
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %0
%18 = load %struct.passwd*, %struct.passwd** %3
%19 = getelementptr inbounds %struct.passwd, %struct.passwd* %18, i32 0, i32 0
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load %struct.passwd*, %struct.passwd** %3
%23 = getelementptr inbounds %struct.passwd, %struct.passwd* %22, i32 0, i32 1
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = load %struct.passwd*, %struct.passwd** %3
%27 = getelementptr inbounds %struct.passwd, %struct.passwd* %26, i32 0, i32 5
%28 = load i64, i64* %27
%29 = trunc i64 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = load %struct.passwd*, %struct.passwd** %3
%32 = getelementptr inbounds %struct.passwd, %struct.passwd* %31, i32 0, i32 2
%33 = load i8*, i8** %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %33)
%35 = load %struct.passwd*, %struct.passwd** %3
%36 = getelementptr inbounds %struct.passwd, %struct.passwd* %35, i32 0, i32 3
%37 = load i8*, i8** %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %37)
%39 = load %struct.passwd*, %struct.passwd** %3
%40 = getelementptr inbounds %struct.passwd, %struct.passwd* %39, i32 0, i32 4
%41 = load i64, i64* %40
%42 = call %struct.group* @getgrgid(i64 %41)
store %struct.group* %42, %struct.group** %4
%43 = load %struct.group*, %struct.group** %4
%44 = icmp ne %struct.group* %43, null
br i1 %44, label %53, label %45
45: ; preds = %17
%46 = load %struct.passwd*, %struct.passwd** %3
%47 = getelementptr inbounds %struct.passwd, %struct.passwd* %46, i32 0, i32 4
%48 = load i64, i64* %47
%49 = trunc i64 %48 to i32
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i32 %49)
%51 = load i32, i32* @EXIT_FAILURE
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %17
%54 = load %struct.group*, %struct.group** %4
%55 = getelementptr inbounds %struct.group, %struct.group* %54, i32 0, i32 0
%56 = load i8*, i8** %55
%57 = load %struct.passwd*, %struct.passwd** %3
%58 = getelementptr inbounds %struct.passwd, %struct.passwd* %57, i32 0, i32 4
%59 = load i64, i64* %58
%60 = trunc i64 %59 to i32
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* %56, i32 %60)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%63 = load %struct.group*, %struct.group** %4
%64 = getelementptr inbounds %struct.group, %struct.group* %63, i32 0, i32 1
%65 = load i8**, i8*** %64
store i8** %65, i8*** %5
br label %66
66: ; preds = %70, %53
%67 = load i8**, i8*** %5
%68 = load i8*, i8** %67
%69 = icmp ne i8* %68, null
br i1 %69, label %70, label %76
70: ; preds = %66
%71 = load i8**, i8*** %5
%72 = load i8*, i8** %71
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8* %72)
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i32 1
store i8** %75, i8*** %5
br label %66
76: ; preds = %66
%77 = load i32, i32* @EXIT_SUCCESS
ret i32 %77
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i8*, i8*, i8*, i64, i64 }
%struct.group = type { i8*, i8** }
@.str = [34 x i8] c"Couldn't find out about user %d.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [10 x i8] c"I am %s.\0A\00"
@.str.2 = [22 x i8] c"My login name is %s.\0A\00"
@.str.3 = [15 x i8] c"My uid is %d.\0A\00"
@.str.4 = [26 x i8] c"My home directory is %s.\0A\00"
@.str.5 = [25 x i8] c"My default shell is %s.\0A\00"
@.str.6 = [35 x i8] c"Couldn't find out about group %d.\0A\00"
@.str.7 = [30 x i8] c"My default group is %s (%d).\0A\00"
@.str.9 = [6 x i8] c" %s\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [31 x i8] c"The members of this group are:\00"
define i32 @main() {
%1 = tail call i64 (...) @getuid()
%2 = tail call %struct.passwd* @getpwuid(i64 %1)
%3 = icmp eq %struct.passwd* %2, null
br i1 %3, label %4, label %9
4: ; preds = %0
%5 = trunc i64 %1 to i32
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %0
%10 = getelementptr inbounds %struct.passwd, %struct.passwd* %2, i64 0, i32 0
%11 = load i8*, i8** %10
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds %struct.passwd, %struct.passwd* %2, i64 0, i32 1
%14 = load i8*, i8** %13
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds %struct.passwd, %struct.passwd* %2, i64 0, i32 5
%17 = load i64, i64* %16
%18 = trunc i64 %17 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds %struct.passwd, %struct.passwd* %2, i64 0, i32 2
%21 = load i8*, i8** %20
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds %struct.passwd, %struct.passwd* %2, i64 0, i32 3
%24 = load i8*, i8** %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds %struct.passwd, %struct.passwd* %2, i64 0, i32 4
%27 = load i64, i64* %26
%28 = tail call %struct.group* @getgrgid(i64 %27)
%29 = icmp eq %struct.group* %28, null
br i1 %29, label %30, label %36
30: ; preds = %9
%31 = load i64, i64* %26
%32 = trunc i64 %31 to i32
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i32 %32)
%34 = load i32, i32* @EXIT_FAILURE
%35 = tail call i32 @exit(i32 %34)
unreachable
36: ; preds = %9
%37 = getelementptr inbounds %struct.group, %struct.group* %28, i64 0, i32 0
%38 = load i8*, i8** %37
%39 = load i64, i64* %26
%40 = trunc i64 %39 to i32
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* %38, i32 %40)
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%43 = getelementptr inbounds %struct.group, %struct.group* %28, i64 0, i32 1
%44 = load i8**, i8*** %43
%45 = load i8*, i8** %44
%46 = icmp eq i8* %45, null
br i1 %46, label %54, label %47
47: ; preds = %36, %47
%48 = phi i8* [ %52, %47 ], [ %45, %36 ]
%49 = phi i8** [ %51, %47 ], [ %44, %36 ]
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8* %48)
%51 = getelementptr inbounds i8*, i8** %49, i64 1
%52 = load i8*, i8** %51
%53 = icmp eq i8* %52, null
br i1 %53, label %54, label %47
54: ; preds = %47, %36
%55 = load i32, i32* @EXIT_SUCCESS
ret i32 %55
}