#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 dummy;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ lstat(char *, struct stat *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintstatf(char *, char *, struct stat *);
int main(int argc, char *argv[]) {
  char *outbuf = (char *)malloc(2048 * sizeof(char));
  struct stat stbuf;
  char *fmt = "st_atime (decimal) = \"%a\"\n"
              "st_atime (string)  = \"%A\"\n"
              "st_ctime (decimal) = \"%c\"\n"
              "st_ctime (string)  = \"%C\"\n"
              "st_gid   (decimal) = \"%g\"\n"
              "st_gid   (string)  = \"%G\"\n"
              "st_ino             = \"%i\"\n"
              "st_mtime (decimal) = \"%m\"\n"
              "st_mtime (string)  = \"%M\"\n"
              "st_nlink           = \"%n\"\n"
              "st_mode  (octal)   = \"%p\"\n"
              "st_mode  (string)  = \"%P\"\n"
              "st_size            = \"%s\"\n"
              "st_uid             = \"%u\"\n"
              "st_uid             = \"%U\"\n";
  lstat(argv[1], &stbuf);
  sprintstatf(outbuf, fmt, &stbuf);
  printf("%s", outbuf);
  free(outbuf);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x800,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xe75(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <lstat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1060 <sprintstatf@plt>
mov    -0x18(%rbp),%rsi
lea    0xfcb(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    $0x800,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    0x8(%r14),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1050 <lstat@plt>
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1060 <sprintstatf@plt>
lea    0xfeb(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [391 x i8] c"st_atime (decimal) = \22%a\22\0Ast_atime (string) = \22%A\22\0Ast_ctime (decimal) = \22%c\22\0Ast_ctime (string) = \22%C\22\0Ast_gid (decimal) = \22%g\22\0Ast_gid (string) = \22%G\22\0Ast_ino = \22%i\22\0Ast_mtime (decimal) = \22%m\22\0Ast_mtime (string) = \22%M\22\0Ast_nlink = \22%n\22\0Ast_mode (octal) = \22%p\22\0Ast_mode (string) = \22%P\22\0Ast_size = \22%s\22\0Ast_uid = \22%u\22\0Ast_uid = \22%U\22\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca %struct.stat
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i64 @malloc(i32 2048)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %6
store i8* getelementptr inbounds ([391 x i8], [391 x i8]* @.str, i64 0, i64 0), i8** %8
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @lstat(i8* %13, %struct.stat* %7)
%15 = load i8*, i8** %6
%16 = load i8*, i8** %8
%17 = call i32 @sprintstatf(i8* %15, i8* %16, %struct.stat* %7)
%18 = load i8*, i8** %6
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %6
%21 = call i32 @free(i8* %20)
%22 = load i32, i32* @EXIT_SUCCESS
%23 = call i32 @exit(i32 %22)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [391 x i8] c"st_atime (decimal) = \22%a\22\0Ast_atime (string) = \22%A\22\0Ast_ctime (decimal) = \22%c\22\0Ast_ctime (string) = \22%C\22\0Ast_gid (decimal) = \22%g\22\0Ast_gid (string) = \22%G\22\0Ast_ino = \22%i\22\0Ast_mtime (decimal) = \22%m\22\0Ast_mtime (string) = \22%M\22\0Ast_nlink = \22%n\22\0Ast_mode (octal) = \22%p\22\0Ast_mode (string) = \22%P\22\0Ast_size = \22%s\22\0Ast_uid = \22%u\22\0Ast_uid = \22%U\22\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = tail call i64 @malloc(i32 2048)
%5 = inttoptr i64 %4 to i8*
%6 = bitcast %struct.stat* %3 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i32 @lstat(i8* %8, %struct.stat* %3)
%10 = call i32 @sprintstatf(i8* %5, i8* getelementptr inbounds ([391 x i8], [391 x i8]* @.str, i64 0, i64 0), %struct.stat* %3)
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%12 = call i32 @free(i8* %5)
%13 = load i32, i32* @EXIT_SUCCESS
%14 = call i32 @exit(i32 %13)
unreachable
}