#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*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ count(int, size_t *, size_t *, size_t *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, size_t, size_t, size_t, ...);
int main(int argc, char **argv) {
  size_t line = 0;
  size_t word = 0;
  size_t symb = 0;
  if (argc == 1) {
    count(0, &line, &word, &symb);
    printf("\t%lu\t%lu\t%lu\n", line, word, symb);
  } else {
    size_t ind;
    size_t totline = 0;
    size_t totword = 0;
    size_t totsymb = 0;
    for (ind = 1; ind < argc; ++ind) {
      int file = open(argv[ind], O_RDONLY);
      if (file == -1) {
        perror(NULL);
      } else {
        count(file, &line, &word, &symb);
        printf("\t%lu\t%lu\t%lu\t%s\n", line, word, symb, argv[ind]);
        totline += line;
        totword += word;
        totsymb += symb;
        line = word = symb = 0;
        close(file);
      }
    }
    if (argc > 2) {
      printf("\t%lu\t%lu\t%lu\tитого\n", totline, totword, totsymb);
    }
  }
  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)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11ba <main+0x6a>
xor    %edi,%edi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1030 <count@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12dd <main+0x18d>
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    12b4 <main+0x164>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2dea(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0xffffffff,-0x4c(%rbp)
jne    1220 <main+0xd0>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <perror@plt>
jmp    129e <main+0x14e>
mov    -0x4c(%rbp),%edi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1030 <count@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rdi
mov    (%rax,%rdi,8),%r8
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x4c(%rbp),%edi
call   1050 <close@plt>
jmp    12a3 <main+0x153>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11da <main+0x8a>
cmpl   $0x2,-0x8(%rbp)
jle    12d8 <main+0x188>
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
lea    0xd4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12dd <main+0x18d>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
test   %edi,%edi
je     1286 <main+0x136>
cmp    $0x1,%edi
jne    11b3 <main+0x63>
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
xor    %edi,%edi
call   1030 <count@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    (%rsp),%rcx
lea    0xe52(%rip),%rdi
jmp    127f <main+0x12f>
mov    %rsi,%r15
mov    %edi,0x1c(%rsp)
movslq %edi,%rax
mov    %rax,0x20(%rsp)
mov    $0x1,%r14d
xor    %r12d,%r12d
xor    %ebx,%ebx
xor    %ebp,%ebp
nop
mov    (%r15,%r14,8),%rdi
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
cmp    $0xffffffff,%eax
je     125f <main+0x10f>
mov    %eax,%r13d
mov    %eax,%edi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
call   1030 <count@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    (%rsp),%rcx
mov    (%r15,%r14,8),%r8
lea    0xdf7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    0x10(%rsp),%rbp
add    0x8(%rsp),%rbx
add    (%rsp),%r12
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    %r13d,%edi
call   1050 <close@plt>
add    $0x1,%r14
cmp    %r14,0x20(%rsp)
jne    11d0 <main+0x80>
jmp    1268 <main+0x118>
xor    %edi,%edi
call   1070 <perror@plt>
jmp    124e <main+0xfe>
cmpl   $0x3,0x1c(%rsp)
jl     1286 <main+0x136>
lea    0xda9(%rip),%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"\09%lu\09%lu\09%lu\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [17 x i8] c"\09%lu\09%lu\09%lu\09%s\0A\00"
@.str.2 = [25 x i8] c"\09%lu\09%lu\09%lu\09\D0\B8\D1\82\D0\BE\D0\B3\D0\BE\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
store i64 0, i64* %7
store i64 0, i64* %8
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = call i32 @count(i32 0, i64* %6, i64* %7, i64* %8)
%18 = load i64, i64* %6
%19 = load i64, i64* %7
%20 = load i64, i64* %8
%21 = call i32 (i8*, i64, i64, i64, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 %18, i64 %19, i64 %20)
br label %74
22: ; preds = %2
store i64 0, i64* %10
store i64 0, i64* %11
store i64 0, i64* %12
store i64 1, i64* %9
br label %23
23: ; preds = %62, %22
%24 = load i64, i64* %9
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = icmp ult i64 %24, %26
br i1 %27, label %28, label %65
28: ; preds = %23
%29 = load i8**, i8*** %5
%30 = load i64, i64* %9
%31 = getelementptr inbounds i8*, i8** %29, i64 %30
%32 = load i8*, i8** %31
%33 = load i32, i32* @O_RDONLY
%34 = call i32 @open(i8* %32, i32 %33)
store i32 %34, i32* %13
%35 = load i32, i32* %13
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %39
37: ; preds = %28
%38 = call i32 @perror(i32* null)
br label %61
39: ; preds = %28
%40 = load i32, i32* %13
%41 = call i32 @count(i32 %40, i64* %6, i64* %7, i64* %8)
%42 = load i64, i64* %6
%43 = load i64, i64* %7
%44 = load i64, i64* %8
%45 = load i8**, i8*** %5
%46 = load i64, i64* %9
%47 = getelementptr inbounds i8*, i8** %45, i64 %46
%48 = load i8*, i8** %47
%49 = call i32 (i8*, i64, i64, i64, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i64 %42, i64 %43, i64 %44, i8* %48)
%50 = load i64, i64* %6
%51 = load i64, i64* %10
%52 = add i64 %51, %50
store i64 %52, i64* %10
%53 = load i64, i64* %7
%54 = load i64, i64* %11
%55 = add i64 %54, %53
store i64 %55, i64* %11
%56 = load i64, i64* %8
%57 = load i64, i64* %12
%58 = add i64 %57, %56
store i64 %58, i64* %12
store i64 0, i64* %8
store i64 0, i64* %7
store i64 0, i64* %6
%59 = load i32, i32* %13
%60 = call i32 @close(i32 %59)
br label %61
61: ; preds = %39, %37
br label %62
62: ; preds = %61
%63 = load i64, i64* %9
%64 = add i64 %63, 1
store i64 %64, i64* %9
br label %23
65: ; preds = %23
%66 = load i32, i32* %4
%67 = icmp sgt i32 %66, 2
br i1 %67, label %68, label %73
68: ; preds = %65
%69 = load i64, i64* %10
%70 = load i64, i64* %11
%71 = load i64, i64* %12
%72 = call i32 (i8*, i64, i64, i64, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i64 %69, i64 %70, i64 %71)
br label %73
73: ; preds = %68, %65
br label %74
74: ; preds = %73, %16
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"\09%lu\09%lu\09%lu\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [17 x i8] c"\09%lu\09%lu\09%lu\09%s\0A\00"
@.str.2 = [25 x i8] c"\09%lu\09%lu\09%lu\09\D0\B8\D1\82\D0\BE\D0\B3\D0\BE\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%7 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%8 = bitcast i64* %5 to i8*
store i64 0, i64* %5
switch i32 %0, label %9 [
i32 1, label %11
i32 0, label %53
]
9: ; preds = %2
%10 = sext i32 %0 to i64
br label %17
11: ; preds = %2
%12 = call i32 @count(i32 0, i64* %3, i64* %4, i64* %5)
%13 = load i64, i64* %3
%14 = load i64, i64* %4
%15 = load i64, i64* %5
%16 = call i32 (i8*, i64, i64, i64, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 %13, i64 %14, i64 %15)
br label %53
17: ; preds = %9, %43
%18 = phi i64 [ %47, %43 ], [ 1, %9 ]
%19 = phi i64 [ %46, %43 ], [ 0, %9 ]
%20 = phi i64 [ %45, %43 ], [ 0, %9 ]
%21 = phi i64 [ %44, %43 ], [ 0, %9 ]
%22 = getelementptr inbounds i8*, i8** %1, i64 %18
%23 = load i8*, i8** %22
%24 = load i32, i32* @O_RDONLY
%25 = call i32 @open(i8* %23, i32 %24)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %29
27: ; preds = %17
%28 = call i32 @perror(i32* null)
br label %43
29: ; preds = %17
%30 = call i32 @count(i32 %25, i64* %3, i64* %4, i64* %5)
%31 = load i64, i64* %3
%32 = load i64, i64* %4
%33 = load i64, i64* %5
%34 = load i8*, i8** %22
%35 = call i32 (i8*, i64, i64, i64, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i64 %31, i64 %32, i64 %33, i8* %34)
%36 = load i64, i64* %3
%37 = add i64 %36, %21
%38 = load i64, i64* %4
%39 = add i64 %38, %20
%40 = load i64, i64* %5
%41 = add i64 %40, %19
store i64 0, i64* %5
store i64 0, i64* %4
store i64 0, i64* %3
%42 = call i32 @close(i32 %25)
br label %43
43: ; preds = %29, %27
%44 = phi i64 [ %21, %27 ], [ %37, %29 ]
%45 = phi i64 [ %20, %27 ], [ %39, %29 ]
%46 = phi i64 [ %19, %27 ], [ %41, %29 ]
%47 = add nuw i64 %18, 1
%48 = icmp eq i64 %47, %10
br i1 %48, label %49, label %17
49: ; preds = %43
%50 = icmp sgt i32 %0, 2
br i1 %50, label %51, label %53
51: ; preds = %49
%52 = call i32 (i8*, i64, i64, i64, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i64 %44, i64 %45, i64 %46)
br label %53
53: ; preds = %2, %49, %51, %11
ret i32 0
}