#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 */
struct stat {
  int st_uid;
  int st_gid;
};
struct passwd {
  char *pw_name;
};
struct group {
  char *gr_name;
};

/* Variables and functions */
struct group *getgrgid(int);
struct passwd *getpwuid(int);
int /*<<< orphan*/ printf(char *, int, char *);
void Print_UserAndGroup(struct stat *pststat) {
  struct passwd *pstpwd;
  struct group *pstgrp;
  pstpwd = getpwuid(pststat->st_uid);
  pstgrp = getgrgid(pststat->st_gid);
  printf("\tUID: %d Name: %s\n", pststat->st_uid, pstpwd->pw_name);
  printf("\tGID: %d Name: %s\n", pststat->st_gid, pstgrp->gr_name);
  return;
}


x86 assembly (clang, -O0):
<Print_UserAndGroup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <getpwuid@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
call   1050 <getgrgid@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Print_UserAndGroup>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%edi
call   1030 <getpwuid@plt>
mov    %rax,%r14
mov    0x4(%rbx),%edi
call   1050 <getgrgid@plt>
mov    %rax,%r15
mov    (%rbx),%esi
mov    (%r14),%rdx
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
mov    0x4(%rbx),%esi
mov    (%r15),%rdx
lea    0xea8(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i32 }
%struct.passwd = type { i8* }
%struct.group = type { i8* }
@.str = [19 x i8] c"\09UID: %d Name: %s\0A\00"
@.str.1 = [19 x i8] c"\09GID: %d Name: %s\0A\00"
define void @Print_UserAndGroup(%struct.stat* %0) {
%2 = alloca %struct.stat*
%3 = alloca %struct.passwd*
%4 = alloca %struct.group*
store %struct.stat* %0, %struct.stat** %2
%5 = load %struct.stat*, %struct.stat** %2
%6 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%7 = load i32, i32* %6
%8 = call %struct.passwd* @getpwuid(i32 %7)
store %struct.passwd* %8, %struct.passwd** %3
%9 = load %struct.stat*, %struct.stat** %2
%10 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 1
%11 = load i32, i32* %10
%12 = call %struct.group* @getgrgid(i32 %11)
store %struct.group* %12, %struct.group** %4
%13 = load %struct.stat*, %struct.stat** %2
%14 = getelementptr inbounds %struct.stat, %struct.stat* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = load %struct.passwd*, %struct.passwd** %3
%17 = getelementptr inbounds %struct.passwd, %struct.passwd* %16, i32 0, i32 0
%18 = load i8*, i8** %17
%19 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %15, i8* %18)
%20 = load %struct.stat*, %struct.stat** %2
%21 = getelementptr inbounds %struct.stat, %struct.stat* %20, i32 0, i32 1
%22 = load i32, i32* %21
%23 = load %struct.group*, %struct.group** %4
%24 = getelementptr inbounds %struct.group, %struct.group* %23, i32 0, i32 0
%25 = load i8*, i8** %24
%26 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %22, i8* %25)
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32, i32 }
%struct.passwd = type { i8* }
%struct.group = type { i8* }
@.str = [19 x i8] c"\09UID: %d Name: %s\0A\00"
@.str.1 = [19 x i8] c"\09GID: %d Name: %s\0A\00"
define void @Print_UserAndGroup(%struct.stat* nocapture %0) {
%2 = getelementptr inbounds %struct.stat, %struct.stat* %0, i64 0, i32 0
%3 = load i32, i32* %2
%4 = tail call %struct.passwd* @getpwuid(i32 %3)
%5 = getelementptr inbounds %struct.stat, %struct.stat* %0, i64 0, i32 1
%6 = load i32, i32* %5
%7 = tail call %struct.group* @getgrgid(i32 %6)
%8 = load i32, i32* %2
%9 = getelementptr inbounds %struct.passwd, %struct.passwd* %4, i64 0, i32 0
%10 = load i8*, i8** %9
%11 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %8, i8* %10)
%12 = load i32, i32* %5
%13 = getelementptr inbounds %struct.group, %struct.group* %7, i64 0, i32 0
%14 = load i8*, i8** %13
%15 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %12, i8* %14)
ret void
}