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

/* Variables and functions */
int S_IFMT;
char *asctime(int /*<<< orphan*/);
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ stat(char *, struct stat *);
int main(int argc, char **argv, char **env) {
  char *filename = argv[0];
  if (argc > 1)
    filename = argv[1];
  struct stat st;
  if (stat(filename, &st) != 0) {
    printf("Can't get file info\n");
    return -1;
  }
  printf("uid: %d\n", (int)st.st_uid);
  printf("gid: %d\n", (int)st.st_gid);
  printf("size: %d\n", (int)st.st_size);
  printf("Access: %04o/", (~S_IFMT) & st.st_mode);
  for (int i = 8; i >= 0; i--)
    if ((st.st_mode >> i) & 1) {
      if (i % 3 == 2)
        printf("r");
      else if (i % 3 == 1)
        printf("w");
      else
        printf("x");
    } else {
      printf("-");
    }
  printf("\n");
  printf("Last access: %s", asctime(localtime(&st.st_atime)));
  printf("Last modification: %s", asctime(localtime(&st.st_mtime)));
  printf("Last status change: %s", asctime(localtime(&st.st_ctime)));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    117b <main+0x3b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
je     11ac <main+0x6c>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1335 <main+0x1f5>
mov    -0x28(%rbp),%rax
mov    %eax,%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%rax
mov    %eax,%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rax
mov    %eax,%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2df1(%rip),%rax
mov    (%rax),%esi
xor    $0xffffffff,%esi
and    -0x48(%rbp),%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x8,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
jl     12b1 <main+0x171>
mov    -0x48(%rbp),%eax
mov    -0x4c(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1290 <main+0x150>
mov    -0x4c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x2,%edx
jne    1251 <main+0x111>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    128b <main+0x14b>
mov    -0x4c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1278 <main+0x138>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1286 <main+0x146>
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    128b <main+0x14b>
jmp    129e <main+0x15e>
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12a3 <main+0x163>
mov    -0x4c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4c(%rbp)
jmp    120c <main+0xcc>
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x48(%rbp),%rdi
add    $0xc,%rdi
call   1030 <localtime@plt>
mov    %eax,%edi
call   1040 <asctime@plt>
mov    %rax,%rsi
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x48(%rbp),%rdi
add    $0x8,%rdi
call   1030 <localtime@plt>
mov    %eax,%edi
call   1040 <asctime@plt>
mov    %rax,%rsi
lea    0xd55(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x48(%rbp),%rdi
add    $0x4,%rdi
call   1030 <localtime@plt>
mov    %eax,%edi
call   1040 <asctime@plt>
mov    %rax,%rsi
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
xor    %eax,%eax
cmp    $0x2,%edi
setge  %al
mov    (%rsi,%rax,8),%rdi
mov    %rsp,%rsi
call   1080 <stat@plt>
test   %rax,%rax
je     1199 <main+0x39>
lea    0xedd(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%ebx
jmp    12be <main+0x15e>
mov    0x20(%rsp),%esi
lea    0xe5c(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x18(%rsp),%esi
lea    0xe51(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%esi
not    %esi
and    (%rsp),%esi
lea    0xe36(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x8,%ebp
mov    $0xaaaaaaab,%r14d
mov    $0x72,%r15d
jmp    1237 <main+0xd7>
mov    %ebp,%eax
imul   %r14,%rax
shr    $0x21,%rax
lea    (%rax,%rax,2),%eax
add    $0xfffffff9,%eax
lea    0x1(%rax),%ecx
xor    %edx,%edx
cmp    %ebx,%eax
sete   %dl
mov    $0x78,%edi
sub    %edx,%edi
cmp    %ebx,%ecx
cmove  %r15d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
add    $0xffffffff,%ebx
cmp    $0xfffffff7,%ebx
je     124c <main+0xec>
mov    (%rsp),%eax
lea    0x8(%rbx),%ecx
movzbl %cl,%ecx
bt     %ecx,%eax
jb     1200 <main+0xa0>
mov    $0x2d,%edi
jmp    1227 <main+0xc7>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xc(%rsp),%rdi
call   1040 <localtime@plt>
mov    %eax,%edi
call   1060 <asctime@plt>
lea    0xdbc(%rip),%rdi
xor    %ebx,%ebx
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x8(%rsp),%rdi
call   1040 <localtime@plt>
mov    %eax,%edi
call   1060 <asctime@plt>
lea    0xda8(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x4(%rsp),%rdi
call   1040 <localtime@plt>
mov    %eax,%edi
call   1060 <asctime@plt>
lea    0xd9c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32, i32, i64, i64, i64 }
@.str = [21 x i8] c"Can't get file info\0A\00"
@.str.1 = [9 x i8] c"uid: %d\0A\00"
@.str.2 = [9 x i8] c"gid: %d\0A\00"
@.str.3 = [10 x i8] c"size: %d\0A\00"
@.str.4 = [14 x i8] c"Access: %04o/\00"
@S_IFMT = global i32 0
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [2 x i8] c"x\00"
@.str.8 = [2 x i8] c"-\00"
@.str.9 = [2 x i8] c"\0A\00"
@.str.10 = [16 x i8] c"Last access: %s\00"
@.str.11 = [22 x i8] c"Last modification: %s\00"
@.str.12 = [23 x i8] c"Last status change: %s\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca %struct.stat
%10 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%11 = load i8**, i8*** %6
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
store i8* %13, i8** %8
%14 = load i32, i32* %5
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %20
16: ; preds = %3
%17 = load i8**, i8*** %6
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
store i8* %19, i8** %8
br label %20
20: ; preds = %16, %3
%21 = load i8*, i8** %8
%22 = call i64 @stat(i8* %21, %struct.stat* %9)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %91
26: ; preds = %20
%27 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 6
%28 = load i64, i64* %27
%29 = trunc i64 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 5
%32 = load i64, i64* %31
%33 = trunc i64 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 4
%36 = load i64, i64* %35
%37 = trunc i64 %36 to i32
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = load i32, i32* @S_IFMT
%40 = xor i32 %39, -1
%41 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%42 = load i32, i32* %41
%43 = and i32 %40, %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %43)
store i32 8, i32* %10
br label %45
45: ; preds = %74, %26
%46 = load i32, i32* %10
%47 = icmp sge i32 %46, 0
br i1 %47, label %48, label %77
48: ; preds = %45
%49 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%50 = load i32, i32* %49
%51 = load i32, i32* %10
%52 = ashr i32 %50, %51
%53 = and i32 %52, 1
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %71
55: ; preds = %48
%56 = load i32, i32* %10
%57 = srem i32 %56, 3
%58 = icmp eq i32 %57, 2
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %70
61: ; preds = %55
%62 = load i32, i32* %10
%63 = srem i32 %62, 3
%64 = icmp eq i32 %63, 1
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %69
67: ; preds = %61
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %69
69: ; preds = %67, %65
br label %70
70: ; preds = %69, %59
br label %73
71: ; preds = %48
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %73
73: ; preds = %71, %70
br label %74
74: ; preds = %73
%75 = load i32, i32* %10
%76 = add nsw i32 %75, -1
store i32 %76, i32* %10
br label %45
77: ; preds = %45
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%79 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 3
%80 = call i32 @localtime(i32* %79)
%81 = call i8* @asctime(i32 %80)
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %81)
%83 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 2
%84 = call i32 @localtime(i32* %83)
%85 = call i8* @asctime(i32 %84)
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i8* %85)
%87 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 1
%88 = call i32 @localtime(i32* %87)
%89 = call i8* @asctime(i32 %88)
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.12, i64 0, i64 0), i8* %89)
store i32 0, i32* %4
br label %91
91: ; preds = %77, %24
%92 = load i32, i32* %4
ret i32 %92
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32, i32, i64, i64, i64 }
@.str.1 = [9 x i8] c"uid: %d\0A\00"
@.str.2 = [9 x i8] c"gid: %d\0A\00"
@.str.3 = [10 x i8] c"size: %d\0A\00"
@.str.4 = [14 x i8] c"Access: %04o/\00"
@S_IFMT = global i32 0
@.str.10 = [16 x i8] c"Last access: %s\00"
@.str.11 = [22 x i8] c"Last modification: %s\00"
@.str.12 = [23 x i8] c"Last status change: %s\00"
@str = [20 x i8] c"Can't get file info\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture readnone %2) {
%4 = alloca %struct.stat
%5 = icmp sgt i32 %0, 1
%6 = zext i1 %5 to i64
%7 = getelementptr i8*, i8** %1, i64 %6
%8 = load i8*, i8** %7
%9 = bitcast %struct.stat* %4 to i8*
%10 = call i64 @stat(i8* %8, %struct.stat* %4)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %3
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %64
14: ; preds = %3
%15 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 6
%16 = load i64, i64* %15
%17 = trunc i64 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 5
%20 = load i64, i64* %19
%21 = trunc i64 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 4
%24 = load i64, i64* %23
%25 = trunc i64 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load i32, i32* @S_IFMT
%28 = xor i32 %27, -1
%29 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%30 = load i32, i32* %29
%31 = and i32 %30, %28
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %31)
br label %47
33: ; preds = %59
%34 = call i32 @putchar(i32 10)
%35 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 3
%36 = call i32 @localtime(i32* %35)
%37 = call i8* @asctime(i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %37)
%39 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 2
%40 = call i32 @localtime(i32* %39)
%41 = call i8* @asctime(i32 %40)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i8* %41)
%43 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%44 = call i32 @localtime(i32* %43)
%45 = call i8* @asctime(i32 %44)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.12, i64 0, i64 0), i8* %45)
br label %64
47: ; preds = %14, %59
%48 = phi i32 [ 8, %14 ], [ %62, %59 ]
%49 = load i32, i32* %29
%50 = shl nuw i32 1, %48
%51 = and i32 %49, %50
%52 = icmp eq i32 %51, 0
br i1 %52, label %59, label %53
53: ; preds = %47
%54 = urem i32 %48, 3
%55 = icmp eq i32 %54, 1
%56 = select i1 %55, i32 119, i32 120
%57 = icmp eq i32 %54, 2
%58 = select i1 %57, i32 114, i32 %56
br label %59
59: ; preds = %47, %53
%60 = phi i32 [ %58, %53 ], [ 45, %47 ]
%61 = call i32 @putchar(i32 %60)
%62 = add nsw i32 %48, -1
%63 = icmp eq i32 %48, 0
br i1 %63, label %33, label %47
64: ; preds = %33, %12
%65 = phi i32 [ -1, %12 ], [ 0, %33 ]
ret i32 %65
}