#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 */

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ O_RDONLY;
int STDIN_FILENO;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
long long get_size(int);
int getopt(int, char **, char *);
int open(char *, int /*<<< orphan*/);
int optind;
int /*<<< orphan*/ perror(char *);
int print_help(char *);
int /*<<< orphan*/ print_size(unsigned long long, char);
int print_version();
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  int fd, should_close;
  long long fsize;
  unsigned long long size;
  int optch;
  extern int opterr;
  char human_readable_flag = 0;
  opterr = 1;
  while ((optch = getopt(argc, argv, "hHv")) != -1) {
    switch (optch) {
    case 'h':
      return print_help(argv[0]);
    case 'H':
      human_readable_flag = 1;
      break;
    case 'v':
      return print_version();
    case '?':
      print_help(argv[0]);
      exit(EXIT_FAILURE);
    }
  }
  if (optind == argc) {
    return print_help(argv[0]);
  }
  size = 0;
  for (int i = optind; i < argc; ++i) {
    should_close = 1;
    if (strcmp(argv[i], "-") == 0) {
      fd = STDIN_FILENO;
      should_close = 0;
    } else {
      fd = open(argv[i], O_RDONLY);
      if (fd == -1) {
        perror("open");
        return -1;
      }
    }
    fsize = get_size(fd);
    if (should_close) {
      close(fd);
    }
    if (fsize < 0) {
      return fsize;
    }
    size += fsize;
  }
  print_size(size, human_readable_flag);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x2d(%rbp)
mov    0x2e37(%rip),%rax
movl   $0x1,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe2b(%rip),%rdx
call   10a0 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     1278 <main+0xd8>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x38(%rbp)
sub    $0x3f,%eax
je     1259 <main+0xb9>
jmp    11fa <main+0x5a>
mov    -0x38(%rbp),%eax
sub    $0x48,%eax
je     1241 <main+0xa1>
jmp    120b <main+0x6b>
mov    -0x38(%rbp),%eax
sub    $0x68,%eax
je     122d <main+0x8d>
jmp    121c <main+0x7c>
mov    -0x38(%rbp),%eax
sub    $0x76,%eax
je     124a <main+0xaa>
jmp    1273 <main+0xd3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <print_help@plt>
mov    %eax,-0x4(%rbp)
jmp    13a6 <main+0x206>
movb   $0x1,-0x2d(%rbp)
jmp    1273 <main+0xd3>
mov    $0x0,%al
call   1050 <print_version@plt>
mov    %eax,-0x4(%rbp)
jmp    13a6 <main+0x206>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <print_help@plt>
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
jmp    11c7 <main+0x27>
mov    0x2d59(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    129e <main+0xfe>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <print_help@plt>
mov    %eax,-0x4(%rbp)
jmp    13a6 <main+0x206>
movq   $0x0,-0x28(%rbp)
mov    0x2d2b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1392 <main+0x1f2>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd2c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12ff <main+0x15f>
mov    0x2cd2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    1343 <main+0x1a3>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2cce(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    133e <main+0x19e>
lea    0xcd9(%rip),%rdi
call   1090 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a6 <main+0x206>
jmp    1343 <main+0x1a3>
mov    -0x14(%rbp),%edi
call   1030 <get_size@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1361 <main+0x1c1>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
cmpq   $0x0,-0x20(%rbp)
jge    1378 <main+0x1d8>
mov    -0x20(%rbp),%rax
mov    %eax,-0x4(%rbp)
jmp    13a6 <main+0x206>
mov    -0x20(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12b2 <main+0x112>
mov    -0x28(%rbp),%rdi
movsbl -0x2d(%rbp),%esi
call   1040 <print_size@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%ebp
mov    0x2e41(%rip),%rax
movl   $0x1,(%rax)
xor    %r14d,%r14d
lea    0xe39(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r13,%rsi
mov    %rbx,%rdx
call   10a0 <getopt@plt>
cmp    $0x67,%eax
jg     1200 <main+0x60>
cmp    $0xffffffff,%eax
je     1211 <main+0x71>
cmp    $0x48,%eax
je     120c <main+0x6c>
cmp    $0x3f,%eax
jne    11d0 <main+0x30>
jmp    130c <main+0x16c>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x76,%eax
je     1237 <main+0x97>
cmp    $0x68,%eax
jne    11d0 <main+0x30>
jmp    1220 <main+0x80>
mov    $0x1,%r14b
jmp    11d0 <main+0x30>
mov    0x2dc0(%rip),%rax
movslq (%rax),%r12
cmp    %ebp,%r12d
jne    124c <main+0xac>
mov    0x0(%r13),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10b0 <print_help@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <print_version@plt>
mov    %r14d,0x4(%rsp)
cmp    %ebp,%r12d
jge    12d4 <main+0x134>
movslq %ebp,%r14
xor    %r15d,%r15d
mov    0x0(%r13,%r12,8),%rdi
lea    0xd98(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12b0 <main+0x110>
mov    0x0(%r13,%r12,8),%rdi
mov    0x2d5e(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
cmp    $0xffffffff,%eax
je     12f9 <main+0x159>
mov    %eax,%ebp
mov    %eax,%edi
call   1030 <get_size@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1060 <close@plt>
test   %rbx,%rbx
jns    12c6 <main+0x126>
jmp    12e8 <main+0x148>
nopl   0x0(%rax,%rax,1)
mov    0x2d09(%rip),%rax
mov    (%rax),%edi
call   1030 <get_size@plt>
mov    %rax,%rbx
test   %rbx,%rbx
js     12e8 <main+0x148>
add    %rbx,%r15
add    $0x1,%r12
cmp    %r12,%r14
jne    1260 <main+0xc0>
jmp    12d7 <main+0x137>
xor    %r15d,%r15d
movsbl 0x4(%rsp),%esi
mov    %r15,%rdi
call   1040 <print_size@plt>
xor    %eax,%eax
jmp    12ea <main+0x14a>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd06(%rip),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%eax
jmp    12ea <main+0x14a>
mov    0x0(%r13),%rdi
call   10b0 <print_help@plt>
mov    0x2cac(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@opterr = external global i32
@.str = [4 x i8] c"hHv\00"
@EXIT_FAILURE = global i32 0
@optind = global i32 0
@.str.1 = [2 x i8] c"-\00"
@STDIN_FILENO = global i32 0
@O_RDONLY = global i32 0
@.str.2 = [5 x i8] c"open\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i8
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 0, i8* %11
store i32 1, i32* @opterr
br label %13
13: ; preds = %35, %2
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i32 @getopt(i32 %14, i8** %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %16, i32* %10
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %36
18: ; preds = %13
%19 = load i32, i32* %10
switch i32 %19, label %35 [
i32 104, label %20
i32 72, label %25
i32 118, label %26
i32 63, label %28
]
20: ; preds = %18
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 @print_help(i8* %23)
store i32 %24, i32* %3
br label %99
25: ; preds = %18
store i8 1, i8* %11
br label %35
26: ; preds = %18
%27 = call i32 (...) @print_version()
store i32 %27, i32* %3
br label %99
28: ; preds = %18
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = call i32 @print_help(i8* %31)
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %18, %25
br label %13
36: ; preds = %13
%37 = load i32, i32* @optind
%38 = load i32, i32* %4
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = call i32 @print_help(i8* %43)
store i32 %44, i32* %3
br label %99
45: ; preds = %36
store i64 0, i64* %9
%46 = load i32, i32* @optind
store i32 %46, i32* %12
br label %47
47: ; preds = %92, %45
%48 = load i32, i32* %12
%49 = load i32, i32* %4
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %95
51: ; preds = %47
store i32 1, i32* %7
%52 = load i8**, i8*** %5
%53 = load i32, i32* %12
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8*, i8** %52, i64 %54
%56 = load i8*, i8** %55
%57 = call i64 @strcmp(i8* %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %51
%60 = load i32, i32* @STDIN_FILENO
store i32 %60, i32* %6
store i32 0, i32* %7
br label %74
61: ; preds = %51
%62 = load i8**, i8*** %5
%63 = load i32, i32* %12
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8*, i8** %62, i64 %64
%66 = load i8*, i8** %65
%67 = load i32, i32* @O_RDONLY
%68 = call i32 @open(i8* %66, i32 %67)
store i32 %68, i32* %6
%69 = load i32, i32* %6
%70 = icmp eq i32 %69, -1
br i1 %70, label %71, label %73
71: ; preds = %61
%72 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %99
73: ; preds = %61
br label %74
74: ; preds = %73, %59
%75 = load i32, i32* %6
%76 = call i64 @get_size(i32 %75)
store i64 %76, i64* %8
%77 = load i32, i32* %7
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %74
%80 = load i32, i32* %6
%81 = call i32 @close(i32 %80)
br label %82
82: ; preds = %79, %74
%83 = load i64, i64* %8
%84 = icmp slt i64 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %82
%86 = load i64, i64* %8
%87 = trunc i64 %86 to i32
store i32 %87, i32* %3
br label %99
88: ; preds = %82
%89 = load i64, i64* %8
%90 = load i64, i64* %9
%91 = add i64 %90, %89
store i64 %91, i64* %9
br label %92
92: ; preds = %88
%93 = load i32, i32* %12
%94 = add nsw i32 %93, 1
store i32 %94, i32* %12
br label %47
95: ; preds = %47
%96 = load i64, i64* %9
%97 = load i8, i8* %11
%98 = call i32 @print_size(i64 %96, i8 signext %97)
store i32 0, i32* %3
br label %99
99: ; preds = %95, %85, %71, %40, %26, %20
%100 = load i32, i32* %3
ret i32 %100
}

LLVM IR (-O2):
@opterr = external global i32
@.str = [4 x i8] c"hHv\00"
@EXIT_FAILURE = global i32 0
@optind = global i32 0
@.str.1 = [2 x i8] c"-\00"
@STDIN_FILENO = global i32 0
@O_RDONLY = global i32 0
@.str.2 = [5 x i8] c"open\00"
define i32 @main(i32 %0, i8** %1) {
store i32 1, i32* @opterr
br label %3
3: ; preds = %5, %2
%4 = phi i8 [ 0, %2 ], [ 1, %5 ]
br label %5
5: ; preds = %3, %5
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %5 [
i32 -1, label %17
i32 104, label %7
i32 72, label %3
i32 118, label %10
i32 63, label %12
]
7: ; preds = %5
%8 = load i8*, i8** %1
%9 = tail call i32 @print_help(i8* %8)
br label %60
10: ; preds = %5
%11 = tail call i32 (...) @print_version()
br label %60
12: ; preds = %5
%13 = load i8*, i8** %1
%14 = tail call i32 @print_help(i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %5
%18 = load i32, i32* @optind
%19 = icmp eq i32 %18, %0
br i1 %19, label %25, label %20
20: ; preds = %17
%21 = icmp slt i32 %18, %0
br i1 %21, label %22, label %57
22: ; preds = %20
%23 = sext i32 %18 to i64
%24 = sext i32 %0 to i64
br label %28
25: ; preds = %17
%26 = load i8*, i8** %1
%27 = tail call i32 @print_help(i8* %26)
br label %60
28: ; preds = %22, %53
%29 = phi i64 [ %23, %22 ], [ %55, %53 ]
%30 = phi i64 [ 0, %22 ], [ %54, %53 ]
%31 = getelementptr inbounds i8*, i8** %1, i64 %29
%32 = load i8*, i8** %31
%33 = tail call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %28
%36 = load i32, i32* @STDIN_FILENO
%37 = tail call i64 @get_size(i32 %36)
br label %48
38: ; preds = %28
%39 = load i8*, i8** %31
%40 = load i32, i32* @O_RDONLY
%41 = tail call i32 @open(i8* %39, i32 %40)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %45
43: ; preds = %38
%44 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %60
45: ; preds = %38
%46 = tail call i64 @get_size(i32 %41)
%47 = tail call i32 @close(i32 %41)
br label %48
48: ; preds = %35, %45
%49 = phi i64 [ %37, %35 ], [ %46, %45 ]
%50 = icmp slt i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = trunc i64 %49 to i32
br label %60
53: ; preds = %48
%54 = add i64 %49, %30
%55 = add nsw i64 %29, 1
%56 = icmp eq i64 %55, %24
br i1 %56, label %57, label %28
57: ; preds = %53, %20
%58 = phi i64 [ 0, %20 ], [ %54, %53 ]
%59 = tail call i32 @print_size(i64 %58, i8 signext %4)
br label %60
60: ; preds = %43, %51, %57, %25, %10, %7
%61 = phi i32 [ %11, %10 ], [ %9, %7 ], [ %27, %25 ], [ 0, %57 ], [ -1, %43 ], [ %52, %51 ]
ret i32 %61
}