#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 /*<<< orphan*/ st_mtime;
  scalar_t__ st_size;
  int /*<<< orphan*/ st_gid;
  int /*<<< orphan*/ st_uid;
  scalar_t__ st_nlink;
  int /*<<< orphan*/ st_mode;
};

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
char *gid_to_name(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
void show_file_info(char *filename, struct stat *info_p) {
  char *uid_to_name(), *ctime(), *gid_to_name(), *filemode();
  void mode_to_letters();
  char modestr[11];
  mode_to_letters(info_p->st_mode, modestr);
  printf("%s", modestr);
  printf("%4d ", (int)info_p->st_nlink);
  printf("%-8s ", uid_to_name(info_p->st_uid));
  printf("%-8s ", gid_to_name(info_p->st_gid));
  printf("%8ld ", (long)info_p->st_size);
  printf("%.12s ", 4 + ctime(&info_p->st_mtime));
  printf("%s\n", filename);
}


x86 assembly (clang, -O0):
<show_file_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%edi
lea    -0x1b(%rbp),%rsi
mov    $0x0,%al
call   1070 <mode_to_letters@plt>
lea    -0x1b(%rbp),%rsi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %eax,%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%edi
mov    $0x0,%al
call   1060 <uid_to_name@plt>
mov    %rax,%rsi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%edi
call   1050 <gid_to_name@plt>
mov    %rax,%rsi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,%rsi
add    $0x4,%rsi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_file_info>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x20(%rsi),%edi
lea    0x5(%rsp),%r15
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <mode_to_letters@plt>
lea    0xe78(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rbx),%esi
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rbx),%edi
xor    %eax,%eax
call   1070 <uid_to_name@plt>
lea    0xe54(%rip),%r15
mov    %r15,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rbx),%edi
call   1060 <gid_to_name@plt>
mov    %r15,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%rsi
lea    0xe2d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <ctime@plt>
lea    0x4(%rax),%rsi
lea    0xe19(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.stat = type { i32, i64, i32, i32, i64, i32 }
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"%4d \00"
@.str.2 = [6 x i8] c"%-8s \00"
@.str.3 = [6 x i8] c"%8ld \00"
@.str.4 = [7 x i8] c"%.12s \00"
@.str.5 = [4 x i8] c"%s\0A\00"
define void @show_file_info(i8* %0, %struct.stat* %1) {
%3 = alloca i8*
%4 = alloca %struct.stat*
%5 = alloca [11 x i8]
store i8* %0, i8** %3
store %struct.stat* %1, %struct.stat** %4
%6 = load %struct.stat*, %struct.stat** %4
%7 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 5
%8 = load i32, i32* %7
%9 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load %struct.stat*, %struct.stat** %4
%13 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 4
%14 = load i64, i64* %13
%15 = trunc i64 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load %struct.stat*, %struct.stat** %4
%18 = getelementptr inbounds %struct.stat, %struct.stat* %17, i32 0, i32 3
%19 = load i32, i32* %18
%20 = call i8* (i32, ...) bitcast (i8* (...)* @uid_to_name to i8* (i32, ...)*)(i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = load %struct.stat*, %struct.stat** %4
%23 = getelementptr inbounds %struct.stat, %struct.stat* %22, i32 0, i32 2
%24 = load i32, i32* %23
%25 = call i8* @gid_to_name(i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load %struct.stat*, %struct.stat** %4
%28 = getelementptr inbounds %struct.stat, %struct.stat* %27, i32 0, i32 1
%29 = load i64, i64* %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %29)
%31 = load %struct.stat*, %struct.stat** %4
%32 = getelementptr inbounds %struct.stat, %struct.stat* %31, i32 0, i32 0
%33 = call i8* @ctime(i32* %32)
%34 = getelementptr inbounds i8, i8* %33, i64 4
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %34)
%36 = load i8*, i8** %3
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %36)
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32, i64, i32, i32, i64, i32 }
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"%4d \00"
@.str.2 = [6 x i8] c"%-8s \00"
@.str.3 = [6 x i8] c"%8ld \00"
@.str.4 = [7 x i8] c"%.12s \00"
define void @show_file_info(i8* nocapture %0, %struct.stat* %1) {
%3 = alloca [11 x i8]
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 5
%6 = load i32, i32* %5
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%8 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 4
%9 = load i64, i64* %8
%10 = trunc i64 %9 to i32
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 3
%13 = load i32, i32* %12
%14 = call i8* (i32, ...) bitcast (i8* (...)* @uid_to_name to i8* (i32, ...)*)(i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 2
%17 = load i32, i32* %16
%18 = call i8* @gid_to_name(i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 1
%21 = load i64, i64* %20
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %21)
%23 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%24 = call i8* @ctime(i32* %23)
%25 = getelementptr inbounds i8, i8* %24, i64 4
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %25)
%27 = call i32 @puts(i8* dereferenceable(1) %0)
ret void
}