#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read_one_file(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int main(int argc, char **argv) {
  int err = 0;
  printf("/* adler32, crc32, MD5[16], intent, date, length, file-name */\n");
  if (argc > 1) {
    int i;
    for (i = 1; i < argc; ++i) {
      FILE *ip = fopen(argv[i], "rb");
      if (ip == NULL || !read_one_file(ip, argv[i])) {
        err = 1;
        perror(argv[i]);
        fprintf(stderr, "%s: read error\n", argv[i]);
        printf("/* ERROR: %s */\n", argv[i]);
      }
      (void)fclose(ip);
    }
  } else {
    if (!read_one_file(stdin, "-")) {
      err = 1;
      perror("stdin");
      fprintf(stderr, "stdin: read error\n");
      printf("/* ERROR: stdin */\n");
    }
  }
  return err;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jle    125e <main+0xfe>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1259 <main+0xf9>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe85(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ed <main+0x8d>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1060 <read_one_file@plt>
cmp    $0x0,%eax
jne    1242 <main+0xe2>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <perror@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe22(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119c <main+0x3c>
jmp    12ba <main+0x15a>
mov    0x2d83(%rip),%rax
mov    (%rax),%rdi
lea    0xdf5(%rip),%rsi
call   1060 <read_one_file@plt>
cmp    $0x0,%eax
jne    12b5 <main+0x155>
movl   $0x1,-0x14(%rbp)
lea    0xddb(%rip),%rdi
call   1080 <perror@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12ba <main+0x15a>
mov    -0x14(%rbp),%eax
add    $0x20,%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,%rbx
mov    %edi,%ebp
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x2,%ebp
jl     122a <main+0xba>
mov    %ebp,%r15d
mov    $0x1,%r12d
lea    0xe5b(%rip),%r14
xor    %r13d,%r13d
jmp    1201 <main+0x91>
mov    (%rbx,%r12,8),%rdi
call   1090 <perror@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%r12,8),%rdx
lea    0xe3c(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx,%r12,8),%rsi
lea    0xe3a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r13d
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1040 <fclose@plt>
add    $0x1,%r12
cmp    %r12,%r15
je     1247 <main+0xd7>
mov    (%rbx,%r12,8),%rdi
mov    %r14,%rsi
call   1080 <fopen@plt>
mov    %rax,%rbp
test   %rax,%rax
je     11aa <main+0x3a>
mov    (%rbx,%r12,8),%rsi
mov    %rbp,%rdi
call   1070 <read_one_file@plt>
test   %eax,%eax
jne    11f0 <main+0x80>
jmp    11aa <main+0x3a>
mov    0x2db7(%rip),%rax
mov    (%rax),%rdi
lea    0xde9(%rip),%rsi
call   1070 <read_one_file@plt>
xor    %r13d,%r13d
test   %eax,%eax
je     1259 <main+0xe9>
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdc6(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
lea    0xdb7(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xdfb(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r13d
jmp    1247 <main+0xd7>

LLVM IR (-O0):
@.str = [64 x i8] c"/* adler32, crc32, MD5[16], intent, date, length, file-name */\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [16 x i8] c"%s: read error\0A\00"
@.str.3 = [17 x i8] c"/* ERROR: %s */\0A\00"
@stdin = global i32* null
@.str.4 = [2 x i8] c"-\00"
@.str.5 = [6 x i8] c"stdin\00"
@.str.6 = [19 x i8] c"stdin: read error\0A\00"
@.str.7 = [20 x i8] c"/* ERROR: stdin */\0A\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 i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %62
12: ; preds = %2
store i32 1, i32* %7
br label %13
13: ; preds = %58, %12
%14 = load i32, i32* %7
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %61
17: ; preds = %13
%18 = load i8**, i8*** %5
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %8
%24 = load i32*, i32** %8
%25 = icmp eq i32* %24, null
br i1 %25, label %35, label %26
26: ; preds = %17
%27 = load i32*, i32** %8
%28 = load i8**, i8*** %5
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @read_one_file(i32* %27, i8* %32)
%34 = icmp ne i32 %33, 0
br i1 %34, label %55, label %35
35: ; preds = %26, %17
store i32 1, i32* %6
%36 = load i8**, i8*** %5
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = call i32 @perror(i8* %40)
%42 = load i32, i32* @stderr
%43 = load i8**, i8*** %5
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %47)
%49 = load i8**, i8*** %5
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %53)
br label %55
55: ; preds = %35, %26
%56 = load i32*, i32** %8
%57 = call i32 @fclose(i32* %56)
br label %58
58: ; preds = %55
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %13
61: ; preds = %13
br label %72
62: ; preds = %2
%63 = load i32*, i32** @stdin
%64 = call i32 @read_one_file(i32* %63, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%65 = icmp ne i32 %64, 0
br i1 %65, label %71, label %66
66: ; preds = %62
store i32 1, i32* %6
%67 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%68 = load i32, i32* @stderr
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
br label %71
71: ; preds = %66, %62
br label %72
72: ; preds = %71, %61
%73 = load i32, i32* %6
ret i32 %73
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [16 x i8] c"%s: read error\0A\00"
@.str.3 = [17 x i8] c"/* ERROR: %s */\0A\00"
@stdin = global i32* null
@.str.4 = [2 x i8] c"-\00"
@.str.5 = [6 x i8] c"stdin\00"
@.str.6 = [19 x i8] c"stdin: read error\0A\00"
@str = [63 x i8] c"/* adler32, crc32, MD5[16], intent, date, length, file-name */\00"
@str.8 = [19 x i8] c"/* ERROR: stdin */\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str, i64 0, i64 0))
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %31
5: ; preds = %2
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %5, %26
%8 = phi i64 [ 1, %5 ], [ %29, %26 ]
%9 = phi i32 [ 0, %5 ], [ %27, %26 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %8
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %18, label %14
14: ; preds = %7
%15 = load i8*, i8** %10
%16 = tail call i32 @read_one_file(i32* %12, i8* %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %14, %7
%19 = load i8*, i8** %10
%20 = tail call i32 @perror(i8* %19)
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %10
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = load i8*, i8** %10
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %18, %14
%27 = phi i32 [ 1, %18 ], [ %9, %14 ]
%28 = tail call i32 @fclose(i32* %12)
%29 = add nuw nsw i64 %8, 1
%30 = icmp eq i64 %29, %6
br i1 %30, label %40, label %7
31: ; preds = %2
%32 = load i32*, i32** @stdin
%33 = tail call i32 @read_one_file(i32* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%37 = load i32, i32* @stderr
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.8, i64 0, i64 0))
br label %40
40: ; preds = %26, %31, %35
%41 = phi i32 [ 0, %31 ], [ 1, %35 ], [ %27, %26 ]
ret i32 %41
}