#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*/ uint8_t;
struct crypt_ops {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ cryptsum(struct crypt_ops *, int /*<<< orphan*/ *, char *,
                    int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fshut(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ mdprint(int /*<<< orphan*/ *, char *, size_t);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ weprintf(char *, char *);
int cryptmain(int argc, char *argv[], struct crypt_ops *ops, uint8_t *md,
              size_t sz) {
  FILE *fp;
  int ret = 0;
  if (argc == 0) {
    cryptsum(ops, stdin, "<stdin>", md);
    mdprint(md, "<stdin>", sz);
  } else {
    for (; *argv; argc--, argv++) {
      if ((*argv)[0] == '-' && !(*argv)[1]) {
        *argv = "<stdin>";
        fp = stdin;
      } else if (!(fp = fopen(*argv, "r"))) {
        weprintf("fopen %s:", *argv);
        ret = 1;
        continue;
      }
      if (cryptsum(ops, fp, *argv, md)) {
        ret = 1;
      } else {
        mdprint(md, *argv, sz);
      }
      if (fp != stdin && fshut(fp, *argv))
        ret = 1;
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<cryptmain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11b3 <cryptmain+0x63>
mov    -0x18(%rbp),%rdi
mov    0x2e61(%rip),%rax
mov    (%rax),%rsi
mov    -0x20(%rbp),%rcx
lea    0xe6b(%rip),%rdx
call   1050 <cryptsum@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe57(%rip),%rsi
call   1040 <mdprint@plt>
jmp    12eb <cryptmain+0x19b>
jmp    11b8 <cryptmain+0x68>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     12e6 <cryptmain+0x196>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    120b <cryptmain+0xbb>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmpb   $0x0,0x1(%rax)
jne    120b <cryptmain+0xbb>
mov    -0x10(%rbp),%rax
lea    0xe0b(%rip),%rcx
mov    %rcx,(%rax)
mov    0x2de9(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    1250 <cryptmain+0x100>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xdef(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    124b <cryptmain+0xfb>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdd0(%rip),%rdi
call   1060 <weprintf@plt>
movl   $0x1,-0x34(%rbp)
jmp    12cc <cryptmain+0x17c>
jmp    1250 <cryptmain+0x100>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%rcx
call   1050 <cryptsum@plt>
cmp    $0x0,%rax
je     127e <cryptmain+0x12e>
movl   $0x1,-0x34(%rbp)
jmp    1292 <cryptmain+0x142>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <mdprint@plt>
mov    -0x30(%rbp),%rax
mov    0x2d4b(%rip),%rcx
cmp    (%rcx),%rax
je     12c7 <cryptmain+0x177>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1030 <fshut@plt>
cmp    $0x0,%rax
je     12c7 <cryptmain+0x177>
movl   $0x1,-0x34(%rbp)
jmp    12cc <cryptmain+0x17c>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    11b8 <cryptmain+0x68>
jmp    12eb <cryptmain+0x19b>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cryptmain>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%rbp
mov    %rcx,%r12
mov    %rdx,%r15
test   %edi,%edi
je     1245 <cryptmain+0xf5>
mov    %rsi,%rbx
mov    (%rsi),%rdi
test   %rdi,%rdi
je     1272 <cryptmain+0x122>
mov    %rbp,(%rsp)
xor    %r13d,%r13d
jmp    11b8 <cryptmain+0x68>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe73(%rip),%rdi
mov    %rdx,%rsi
call   1060 <weprintf@plt>
mov    $0x1,%ebp
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
mov    %ebp,%r13d
test   %rdi,%rdi
je     1274 <cryptmain+0x124>
cmpb   $0x2d,(%rdi)
jne    11c3 <cryptmain+0x73>
cmpb   $0x0,0x1(%rdi)
je     11dc <cryptmain+0x8c>
lea    0xe3e(%rip),%rsi
call   1070 <fopen@plt>
mov    (%rbx),%rdx
test   %rax,%rax
je     1190 <cryptmain+0x40>
mov    %rax,%r14
jmp    11f0 <cryptmain+0xa0>
lea    0xe1d(%rip),%rdx
mov    %rdx,(%rbx)
mov    0x2dfb(%rip),%rax
mov    (%rax),%r14
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rcx
call   1050 <cryptsum@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    121a <cryptmain+0xca>
mov    (%rbx),%rsi
mov    %r12,%rdi
mov    (%rsp),%rdx
call   1040 <mdprint@plt>
mov    %r13d,%ebp
mov    0x2dc7(%rip),%rax
cmp    (%rax),%r14
je     11a4 <cryptmain+0x54>
mov    (%rbx),%rsi
mov    %r14,%rdi
call   1030 <fshut@plt>
test   %rax,%rax
mov    $0x1,%eax
cmovne %eax,%ebp
jmp    11a4 <cryptmain+0x54>
mov    0x2d9c(%rip),%rax
mov    (%rax),%rsi
lea    0xdaa(%rip),%rbx
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r12,%rcx
call   1050 <cryptsum@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1040 <mdprint@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.crypt_ops = type { i32 }
@stdin = global i32* null
@.str = [8 x i8] c"<stdin>\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"fopen %s:\00"
define i32 @cryptmain(i32 %0, i8** %1, %struct.crypt_ops* %2, i32* %3, i64 %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca %struct.crypt_ops*
%9 = alloca i32*
%10 = alloca i64
%11 = alloca i32*
%12 = alloca i32
store i32 %0, i32* %6
store i8** %1, i8*** %7
store %struct.crypt_ops* %2, %struct.crypt_ops** %8
store i32* %3, i32** %9
store i64 %4, i64* %10
store i32 0, i32* %12
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %5
%16 = load %struct.crypt_ops*, %struct.crypt_ops** %8
%17 = load i32*, i32** @stdin
%18 = load i32*, i32** %9
%19 = call i64 @cryptsum(%struct.crypt_ops* %16, i32* %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %18)
%20 = load i32*, i32** %9
%21 = load i64, i64* %10
%22 = call i32 @mdprint(i32* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %21)
br label %87
23: ; preds = %5
br label %24
24: ; preds = %81, %23
%25 = load i8**, i8*** %7
%26 = load i8*, i8** %25
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %86
28: ; preds = %24
%29 = load i8**, i8*** %7
%30 = load i8*, i8** %29
%31 = getelementptr inbounds i8, i8* %30, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 45
br i1 %34, label %35, label %44
35: ; preds = %28
%36 = load i8**, i8*** %7
%37 = load i8*, i8** %36
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = icmp ne i8 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %35
%42 = load i8**, i8*** %7
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %42
%43 = load i32*, i32** @stdin
store i32* %43, i32** %11
br label %54
44: ; preds = %35, %28
%45 = load i8**, i8*** %7
%46 = load i8*, i8** %45
%47 = call i32* @fopen(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %47, i32** %11
%48 = icmp ne i32* %47, null
br i1 %48, label %53, label %49
49: ; preds = %44
%50 = load i8**, i8*** %7
%51 = load i8*, i8** %50
%52 = call i32 @weprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %51)
store i32 1, i32* %12
br label %81
53: ; preds = %44
br label %54
54: ; preds = %53, %41
%55 = load %struct.crypt_ops*, %struct.crypt_ops** %8
%56 = load i32*, i32** %11
%57 = load i8**, i8*** %7
%58 = load i8*, i8** %57
%59 = load i32*, i32** %9
%60 = call i64 @cryptsum(%struct.crypt_ops* %55, i32* %56, i8* %58, i32* %59)
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %54
store i32 1, i32* %12
br label %69
63: ; preds = %54
%64 = load i32*, i32** %9
%65 = load i8**, i8*** %7
%66 = load i8*, i8** %65
%67 = load i64, i64* %10
%68 = call i32 @mdprint(i32* %64, i8* %66, i64 %67)
br label %69
69: ; preds = %63, %62
%70 = load i32*, i32** %11
%71 = load i32*, i32** @stdin
%72 = icmp ne i32* %70, %71
br i1 %72, label %73, label %80
73: ; preds = %69
%74 = load i32*, i32** %11
%75 = load i8**, i8*** %7
%76 = load i8*, i8** %75
%77 = call i64 @fshut(i32* %74, i8* %76)
%78 = icmp ne i64 %77, 0
br i1 %78, label %79, label %80
79: ; preds = %73
store i32 1, i32* %12
br label %80
80: ; preds = %79, %73, %69
br label %81
81: ; preds = %80, %49
%82 = load i32, i32* %6
%83 = add nsw i32 %82, -1
store i32 %83, i32* %6
%84 = load i8**, i8*** %7
%85 = getelementptr inbounds i8*, i8** %84, i32 1
store i8** %85, i8*** %7
br label %24
86: ; preds = %24
br label %87
87: ; preds = %86, %15
%88 = load i32, i32* %12
ret i32 %88
}

LLVM IR (-O2):
%struct.crypt_ops = type { i32 }
@stdin = global i32* null
@.str = [8 x i8] c"<stdin>\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"fopen %s:\00"
define i32 @cryptmain(i32 %0, i8** nocapture %1, %struct.crypt_ops* %2, i32* %3, i64 %4) {
%6 = icmp eq i32 %0, 0
br i1 %6, label %10, label %7
7: ; preds = %5
%8 = load i8*, i8** %1
%9 = icmp eq i8* %8, null
br i1 %9, label %54, label %14
10: ; preds = %5
%11 = load i32*, i32** @stdin
%12 = tail call i64 @cryptsum(%struct.crypt_ops* %2, i32* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %3)
%13 = tail call i32 @mdprint(i32* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %4)
br label %54
14: ; preds = %7, %49
%15 = phi i8* [ %52, %49 ], [ %8, %7 ]
%16 = phi i32 [ %50, %49 ], [ 0, %7 ]
%17 = phi i8** [ %51, %49 ], [ %1, %7 ]
%18 = load i8, i8* %15
%19 = icmp eq i8 %18, 45
br i1 %19, label %20, label %26
20: ; preds = %14
%21 = getelementptr inbounds i8, i8* %15, i64 1
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %17
%25 = load i32*, i32** @stdin
br label %32
26: ; preds = %20, %14
%27 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i32* %27, null
%29 = load i8*, i8** %17
br i1 %28, label %30, label %32
30: ; preds = %26
%31 = tail call i32 @weprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %29)
br label %49
32: ; preds = %26, %24
%33 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %24 ], [ %29, %26 ]
%34 = phi i32* [ %25, %24 ], [ %27, %26 ]
%35 = tail call i64 @cryptsum(%struct.crypt_ops* %2, i32* %34, i8* %33, i32* %3)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = load i8*, i8** %17
%39 = tail call i32 @mdprint(i32* %3, i8* %38, i64 %4)
br label %40
40: ; preds = %32, %37
%41 = phi i32 [ %16, %37 ], [ 1, %32 ]
%42 = load i32*, i32** @stdin
%43 = icmp eq i32* %34, %42
br i1 %43, label %49, label %44
44: ; preds = %40
%45 = load i8*, i8** %17
%46 = tail call i64 @fshut(i32* %34, i8* %45)
%47 = icmp eq i64 %46, 0
%48 = select i1 %47, i32 %41, i32 1
br label %49
49: ; preds = %44, %40, %30
%50 = phi i32 [ %41, %40 ], [ 1, %30 ], [ %48, %44 ]
%51 = getelementptr inbounds i8*, i8** %17, i64 1
%52 = load i8*, i8** %51
%53 = icmp eq i8* %52, null
br i1 %53, label %54, label %14
54: ; preds = %49, %7, %10
%55 = phi i32 [ 0, %10 ], [ 0, %7 ], [ %50, %49 ]
ret i32 %55
}