#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;
  scalar_t__ st_size;
  int /*<<< orphan*/ st_mode;
};
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 /*<<< orphan*/ strmode(int /*<<< orphan*/, char *);
void print_stat_info(char *name, struct stat *sb) {
  struct passwd *passwd;
  struct group *group;
  char filemode[11 + 1];
  passwd = getpwuid(sb->st_uid);
  group = getgrgid(sb->st_gid);
  strmode(sb->st_mode, filemode);
  printf("%s  ", filemode);
  if (passwd)
    printf("%s  ", passwd->pw_name);
  else
    printf("%d  ", sb->st_uid);
  if (group)
    printf("%s  ", group->gr_name);
  else
    printf("%d  ", sb->st_gid);
  printf("%u %s\n", (unsigned int)sb->st_size, name);
}


x86 assembly (clang, -O0):
<print_stat_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1030 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
call   1050 <getgrgid@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%edi
lea    -0x2c(%rbp),%rsi
call   1060 <strmode@plt>
lea    -0x2c(%rbp),%rsi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x18(%rbp)
je     11b6 <print_stat_info+0x76>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ca <print_stat_info+0x8a>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
je     11ef <print_stat_info+0xaf>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1204 <print_stat_info+0xc4>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %eax,%esi
mov    -0x8(%rbp),%rdx
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_stat_info>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%edi
call   1030 <getpwuid@plt>
mov    %rax,%r12
mov    0x4(%rbx),%edi
call   1050 <getgrgid@plt>
mov    %rax,%r15
mov    0x10(%rbx),%edi
lea    0x4(%rsp),%r13
mov    %r13,%rsi
call   1060 <strmode@plt>
lea    0xe81(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r12,%r12
je     11b8 <print_stat_info+0x78>
mov    (%r12),%rsi
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r15,%r15
je     11cd <print_stat_info+0x8d>
mov    (%r15),%rsi
lea    0xe51(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11de <print_stat_info+0x9e>
mov    (%rbx),%esi
lea    0xe44(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r15,%r15
jne    11a5 <print_stat_info+0x65>
mov    0x4(%rbx),%esi
lea    0xe2e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%esi
lea    0xe22(%rip),%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.stat = type { i32, i32, i64, i32 }
%struct.passwd = type { i8* }
%struct.group = type { i8* }
@.str = [5 x i8] c"%s \00"
@.str.1 = [5 x i8] c"%d \00"
@.str.2 = [7 x i8] c"%u %s\0A\00"
define void @print_stat_info(i8* %0, %struct.stat* %1) {
%3 = alloca i8*
%4 = alloca %struct.stat*
%5 = alloca %struct.passwd*
%6 = alloca %struct.group*
%7 = alloca [12 x i8]
store i8* %0, i8** %3
store %struct.stat* %1, %struct.stat** %4
%8 = load %struct.stat*, %struct.stat** %4
%9 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = call %struct.passwd* @getpwuid(i32 %10)
store %struct.passwd* %11, %struct.passwd** %5
%12 = load %struct.stat*, %struct.stat** %4
%13 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 1
%14 = load i32, i32* %13
%15 = call %struct.group* @getgrgid(i32 %14)
store %struct.group* %15, %struct.group** %6
%16 = load %struct.stat*, %struct.stat** %4
%17 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 3
%18 = load i32, i32* %17
%19 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%20 = call i32 @strmode(i32 %18, i8* %19)
%21 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = load %struct.passwd*, %struct.passwd** %5
%24 = icmp ne %struct.passwd* %23, null
br i1 %24, label %25, label %30
25: ; preds = %2
%26 = load %struct.passwd*, %struct.passwd** %5
%27 = getelementptr inbounds %struct.passwd, %struct.passwd* %26, i32 0, i32 0
%28 = load i8*, i8** %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %28)
br label %35
30: ; preds = %2
%31 = load %struct.stat*, %struct.stat** %4
%32 = getelementptr inbounds %struct.stat, %struct.stat* %31, i32 0, i32 0
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %30, %25
%36 = load %struct.group*, %struct.group** %6
%37 = icmp ne %struct.group* %36, null
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load %struct.group*, %struct.group** %6
%40 = getelementptr inbounds %struct.group, %struct.group* %39, i32 0, i32 0
%41 = load i8*, i8** %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %41)
br label %48
43: ; preds = %35
%44 = load %struct.stat*, %struct.stat** %4
%45 = getelementptr inbounds %struct.stat, %struct.stat* %44, i32 0, i32 1
%46 = load i32, i32* %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %43, %38
%49 = load %struct.stat*, %struct.stat** %4
%50 = getelementptr inbounds %struct.stat, %struct.stat* %49, i32 0, i32 2
%51 = load i64, i64* %50
%52 = trunc i64 %51 to i32
%53 = load i8*, i8** %3
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %52, i8* %53)
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i64, i32 }
%struct.passwd = type { i8* }
%struct.group = type { i8* }
@.str = [5 x i8] c"%s \00"
@.str.1 = [5 x i8] c"%d \00"
@.str.2 = [7 x i8] c"%u %s\0A\00"
define void @print_stat_info(i8* %0, %struct.stat* nocapture %1) {
%3 = alloca [12 x i8]
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%6 = load i32, i32* %5
%7 = tail call %struct.passwd* @getpwuid(i32 %6)
%8 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 1
%9 = load i32, i32* %8
%10 = tail call %struct.group* @getgrgid(i32 %9)
%11 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 3
%12 = load i32, i32* %11
%13 = call i32 @strmode(i32 %12, i8* %4)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %4)
%15 = icmp eq %struct.passwd* %7, null
br i1 %15, label %20, label %16
16: ; preds = %2
%17 = getelementptr inbounds %struct.passwd, %struct.passwd* %7, i64 0, i32 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %23
20: ; preds = %2
%21 = load i32, i32* %5
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %16
%24 = icmp eq %struct.group* %10, null
br i1 %24, label %29, label %25
25: ; preds = %23
%26 = getelementptr inbounds %struct.group, %struct.group* %10, i64 0, i32 0
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %27)
br label %32
29: ; preds = %23
%30 = load i32, i32* %8
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %29, %25
%33 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 2
%34 = load i64, i64* %33
%35 = trunc i64 %34 to i32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %35, i8* %0)
ret void
}