#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 {
  scalar_t__ st_size;
  int /*<<< orphan*/ st_mode;
};

/* Variables and functions */
scalar_t__ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ chdir(char *);
scalar_t__ lstat(char *, struct stat *);
int /*<<< orphan*/ printf(char *, int);
int scanf(char *, char *);
int main(int argc, char **argv) {
  int size = 0;
  char fn[512];
  struct stat st;
  if (argc > 1)
    chdir(argv[1]);
  while (scanf("%*s %s", fn) == 1) {
    if (lstat(fn, &st))
      continue;
    if (S_ISREG(st.st_mode))
      size += st.st_size;
    size += 512;
  }
  printf("%.2f MB\n", size / 1048576.0 + 0.01);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1187 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <chdir@plt>
jmp    118c <main+0x3c>
lea    -0x220(%rbp),%rsi
lea    0xe76(%rip),%rdi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    1200 <main+0xb0>
lea    -0x220(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1050 <lstat@plt>
cmp    $0x0,%rax
je     11ca <main+0x7a>
jmp    118c <main+0x3c>
mov    -0x228(%rbp),%edi
call   1060 <S_ISREG@plt>
cmp    $0x0,%rax
je     11f0 <main+0xa0>
mov    -0x230(%rbp),%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x200,%eax
mov    %eax,-0x14(%rbp)
jmp    118c <main+0x3c>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xdfb(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xde7(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xdef(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x218,%rsp
cmp    $0x2,%edi
jl     116c <main+0x1c>
mov    0x8(%rsi),%rdi
call   1030 <chdir@plt>
xor    %r12d,%r12d
lea    0xe9a(%rip),%r14
lea    0x10(%rsp),%rbx
mov    %rsp,%r15
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    11bf <main+0x6f>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <lstat@plt>
test   %rax,%rax
jne    1180 <main+0x30>
mov    0x8(%rsp),%edi
call   1060 <S_ISREG@plt>
xor    %ecx,%ecx
test   %rax,%rax
je     11b3 <main+0x63>
mov    (%rsp),%ecx
add    %ecx,%r12d
add    $0x200,%r12d
jmp    1180 <main+0x30>
cvtsi2sd %r12d,%xmm0
mulsd  0xe34(%rip),%xmm0
addsd  0xe34(%rip),%xmm0
cvttsd2si %xmm0,%esi
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.stat = type { i64, i32 }
@.str = [7 x i8] c"%*s %s\00"
@.str.1 = [9 x i8] c"%.2f MB\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [512 x i8]
%8 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @chdir(i8* %14)
br label %16
16: ; preds = %11, %2
br label %17
17: ; preds = %38, %25, %16
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%19 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %41
21: ; preds = %17
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%23 = call i64 @lstat(i8* %22, %struct.stat* %8)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21
br label %17
26: ; preds = %21
%27 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 1
%28 = load i32, i32* %27
%29 = call i64 @S_ISREG(i32 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %38
31: ; preds = %26
%32 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%33 = load i64, i64* %32
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = add nsw i64 %35, %33
%37 = trunc i64 %36 to i32
store i32 %37, i32* %6
br label %38
38: ; preds = %31, %26
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 512
store i32 %40, i32* %6
br label %17
41: ; preds = %17
%42 = load i32, i32* %6
%43 = sitofp i32 %42 to double
%44 = fdiv double %43, 0x4130000000000000
%45 = fadd double %44, 1.000000e-02
%46 = fptosi double %45 to i32
%47 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %46)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i64, i32 }
@.str = [7 x i8] c"%*s %s\00"
@.str.1 = [9 x i8] c"%.2f MB\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = alloca %struct.stat
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.stat* %4 to i8*
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @chdir(i8* %10)
br label %12
12: ; preds = %8, %2
%13 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%14 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
br label %15
15: ; preds = %23, %12
%16 = phi i32 [ %31, %23 ], [ 0, %12 ]
br label %17
17: ; preds = %15, %20
%18 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %5)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %32
20: ; preds = %17
%21 = call i64 @lstat(i8* %5, %struct.stat* %4)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %17
23: ; preds = %20
%24 = load i32, i32* %13
%25 = call i64 @S_ISREG(i32 %24)
%26 = icmp eq i64 %25, 0
%27 = load i64, i64* %14
%28 = trunc i64 %27 to i32
%29 = select i1 %26, i32 0, i32 %28
%30 = add i32 %16, 512
%31 = add i32 %30, %29
br label %15
32: ; preds = %17
%33 = sitofp i32 %16 to double
%34 = fmul double %33, 0x3EB0000000000000
%35 = fadd double %34, 1.000000e-02
%36 = fptosi double %35 to i32
%37 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %36)
ret i32 0
}