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

/* Variables and functions */
int SHA256_DIGEST_LENGTH;
int /*<<< orphan*/ SHA256_Final(unsigned char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ SHA256_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ SHA256_Update(int /*<<< orphan*/ *, unsigned char *, int);
int /*<<< orphan*/ STDIN_FILENO;
int close(int);
unsigned char *malloc(int);
int mkstemp(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int /*<<< orphan*/, unsigned char *, int);
int rename(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strncat(char *, char *, int);
int write(int, unsigned char *, int);
int main(int argc, char **argv) {
  unsigned char *buf = malloc(4194304);
  if (buf == NULL) {
    printf("Could not allocate buffer.\n");
    return 1;
  }
  int outf;
  char outf_name[] = "temp_hashname_XXXXXX";
  outf = mkstemp(outf_name);
  if (outf == -1) {
    perror("Creating temporary file");
    return 1;
  }
  SHA256_CTX ctx;
  SHA256_Init(&ctx);
  ssize_t rret = 0;
  ssize_t rcount = 0;
  for (;;) {
    rret = read(STDIN_FILENO, buf + rcount, 4096);
    if (rret == -1) {
      perror("Reading from stdin");
      return 1;
    }
    rcount += rret;
    if ((rcount > (4194304 - 8192)) || (rret == 0)) {
      int wret = 0;
      int wcount = 0;
      do {
        wret = write(outf, buf + wcount, rcount - wcount);
        if (wret == -1) {
          perror("Writing output file");
          return 1;
        }
        wcount += wret;
      } while (wcount < rcount);
      SHA256_Update(&ctx, buf, rcount);
      rcount = 0;
    }
    if (rret == 0) {
      break;
    }
  }
  unsigned char hash[SHA256_DIGEST_LENGTH];
  unsigned char *h = hash;
  char hash_name[1024];
  char *p = hash_name;
  SHA256_Final(hash, &ctx);
  int i;
  for (i = 0; i < SHA256_DIGEST_LENGTH; i++) {
    sprintf(p, "%02x", *h++);
    p += 2;
  }
  hash_name[32] = '\0';
  printf("%s\n", hash_name);
  if (argc > 1) {
    strncat(hash_name, argv[1], 128);
  }
  int ret = rename(outf_name, hash_name);
  if (ret == -1) {
    perror("Renaming temp file");
  }
  ret = close(outf);
  if (ret == -1) {
    perror("Closing output file");
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x480,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x400000,%edi
call   1090 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    121c <main+0x4c>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ca <main+0x2fa>
mov    0xe6d(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe6a(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe68(%rip),%eax
mov    %eax,-0x30(%rbp)
mov    0xe63(%rip),%al
mov    %al,-0x2c(%rbp)
lea    -0x40(%rbp),%rdi
call   10a0 <mkstemp@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1272 <main+0xa2>
lea    0xdbb(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ca <main+0x2fa>
lea    -0x44(%rbp),%rdi
call   1070 <SHA256_Init@plt>
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
movslq -0x4c(%rbp),%rax
add    %rax,%rsi
mov    $0x1000,%edx
call   1080 <read@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0xffffffff,-0x48(%rbp)
jne    12cc <main+0xfc>
lea    0xd79(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ca <main+0x2fa>
mov    -0x48(%rbp),%eax
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
cmpl   $0x3fe000,-0x4c(%rbp)
jg     12ec <main+0x11c>
cmpl   $0x0,-0x48(%rbp)
jne    1364 <main+0x194>
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
movslq -0x54(%rbp),%rax
add    %rax,%rsi
mov    -0x4c(%rbp),%edx
sub    -0x54(%rbp),%edx
call   1030 <write@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0xffffffff,-0x50(%rbp)
jne    1338 <main+0x168>
lea    0xd20(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ca <main+0x2fa>
mov    -0x50(%rbp),%eax
add    -0x54(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jl     12fa <main+0x12a>
mov    -0x18(%rbp),%rsi
mov    -0x4c(%rbp),%edx
lea    -0x44(%rbp),%rdi
call   10e0 <SHA256_Update@plt>
movl   $0x0,-0x4c(%rbp)
cmpl   $0x0,-0x48(%rbp)
jne    1373 <main+0x1a3>
jmp    1378 <main+0x1a8>
jmp    1289 <main+0xb9>
mov    0x2c61(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,%rsp
mov    %rax,-0x68(%rbp)
mov    %rdi,-0x70(%rbp)
lea    -0x470(%rbp),%rax
mov    %rax,-0x478(%rbp)
lea    -0x44(%rbp),%rsi
call   10b0 <SHA256_Final@plt>
movl   $0x0,-0x47c(%rbp)
mov    -0x47c(%rbp),%eax
mov    0x2c0e(%rip),%rcx
cmp    (%rcx),%eax
jge    1425 <main+0x255>
mov    -0x478(%rbp),%rdi
mov    -0x70(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x70(%rbp)
movzbl (%rax),%edx
lea    0xc61(%rip),%rsi
call   10f0 <sprintf@plt>
mov    -0x478(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x478(%rbp)
mov    -0x47c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x47c(%rbp)
jmp    13c5 <main+0x1f5>
movb   $0x0,-0x450(%rbp)
lea    -0x470(%rbp),%rsi
lea    0xc26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1464 <main+0x294>
lea    -0x470(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0x80,%edx
call   1050 <strncat@plt>
lea    -0x40(%rbp),%rdi
lea    -0x470(%rbp),%rsi
call   10d0 <rename@plt>
mov    %eax,-0x480(%rbp)
cmpl   $0xffffffff,-0x480(%rbp)
jne    1493 <main+0x2c3>
lea    0xbd6(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    %eax,-0x480(%rbp)
cmpl   $0xffffffff,-0x480(%rbp)
jne    14ba <main+0x2ea>
lea    0xbc2(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x480(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
mov    $0x400000,%edi
call   1090 <malloc@plt>
test   %rax,%rax
je     12d0 <main+0x100>
mov    %rax,%rbx
movaps 0xdf9(%rip),%xmm0
movaps %xmm0,-0x60(%rbp)
movabs $0x5858585858585f,%rax
mov    %rax,-0x53(%rbp)
lea    -0x60(%rbp),%rdi
call   10a0 <mkstemp@plt>
cmp    $0xffffffff,%eax
je     13bf <main+0x1ef>
mov    %eax,%r12d
mov    %r15d,-0x30(%rbp)
mov    %r14,-0x40(%rbp)
lea    -0x2c(%rbp),%rdi
call   1070 <SHA256_Init@plt>
xor    %r14d,%r14d
mov    0x2d8f(%rip),%r13
jmp    1259 <main+0x89>
nopl   0x0(%rax,%rax,1)
test   %r15d,%r15d
je     12e1 <main+0x111>
mov    0x0(%r13),%edi
movslq %r14d,%rsi
add    %rbx,%rsi
mov    $0x1000,%edx
call   1080 <read@plt>
cmp    $0xffffffff,%eax
je     13c8 <main+0x1f8>
mov    %eax,%r15d
add    %eax,%r14d
test   %eax,%eax
je     1289 <main+0xb9>
cmp    $0x3fe001,%r14d
jl     1250 <main+0x80>
xor    %r13d,%r13d
nopl   0x0(%rax)
movslq %r13d,%rax
lea    (%rbx,%rax,1),%rsi
mov    %r14d,%edx
sub    %eax,%edx
mov    %r12d,%edi
call   1040 <write@plt>
cmp    $0xffffffff,%eax
je     139d <main+0x1cd>
add    %eax,%r13d
cmp    %r14d,%r13d
jl     1290 <main+0xc0>
lea    -0x2c(%rbp),%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   10e0 <SHA256_Update@plt>
xor    %r14d,%r14d
mov    0x2d0a(%rip),%r13
jmp    1250 <main+0x80>
lea    0xda9(%rip),%rdi
call   1030 <puts@plt>
jmp    13a9 <main+0x1d9>
mov    %rsp,-0x38(%rbp)
mov    0x2cf4(%rip),%r15
mov    (%r15),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
lea    -0x2c(%rbp),%rsi
mov    %r14,%rdi
call   10b0 <SHA256_Final@plt>
cmpl   $0x0,(%r15)
jle    1341 <main+0x171>
lea    -0x460(%rbp),%rbx
xor    %r13d,%r13d
nopl   0x0(%rax)
movzbl (%r14,%r13,1),%edx
mov    %rbx,%rdi
lea    0xd25(%rip),%rsi
call   10f0 <sprintf@plt>
add    $0x2,%rbx
add    $0x1,%r13
cmp    (%r15),%r13d
jl     1320 <main+0x150>
movb   $0x0,-0x440(%rbp)
lea    -0x460(%rbp),%rdi
call   1030 <puts@plt>
cmpl   $0x2,-0x30(%rbp)
jl     1373 <main+0x1a3>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x460(%rbp),%rdi
mov    $0x80,%edx
call   1050 <strncat@plt>
lea    -0x60(%rbp),%rdi
lea    -0x460(%rbp),%rsi
call   10d0 <rename@plt>
cmp    $0xffffffff,%eax
je     13d1 <main+0x201>
mov    %r12d,%edi
call   1060 <close@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     13df <main+0x20f>
mov    -0x38(%rbp),%rsp
jmp    13ae <main+0x1de>
lea    0xc9c(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc4f(%rip),%rdi
jmp    13a4 <main+0x1d4>
lea    0xc5e(%rip),%rdi
jmp    13a4 <main+0x1d4>
lea    0xc81(%rip),%rdi
call   10c0 <perror@plt>
jmp    1388 <main+0x1b8>
lea    0xc86(%rip),%rdi
call   10c0 <perror@plt>
jmp    1397 <main+0x1c7>

LLVM IR (-O0):
@.str = [28 x i8] c"Could not allocate buffer.\0A\00"
@__const.main.outf_name = [21 x i8] c"temp_hashname_XXXXXX\00"
@.str.1 = [24 x i8] c"Creating temporary file\00"
@STDIN_FILENO = global i32 0
@.str.2 = [19 x i8] c"Reading from stdin\00"
@.str.3 = [20 x i8] c"Writing output file\00"
@SHA256_DIGEST_LENGTH = global i32 0
@.str.4 = [5 x i8] c"%02x\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [19 x i8] c"Renaming temp file\00"
@.str.7 = [20 x i8] c"Closing output file\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [21 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i8*
%17 = alloca [1024 x i8]
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = call i8* @malloc(i32 4194304)
store i8* %21, i8** %6
%22 = load i8*, i8** %6
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %26
24: ; preds = %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %141
26: ; preds = %2
%27 = bitcast [21 x i8]* %8 to i8*
%28 = getelementptr inbounds [21 x i8], [21 x i8]* %8, i64 0, i64 0
%29 = call i32 @mkstemp(i8* %28)
store i32 %29, i32* %7
%30 = load i32, i32* %7
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %34
32: ; preds = %26
%33 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %141
34: ; preds = %26
%35 = call i32 @SHA256_Init(i32* %9)
store i32 0, i32* %10
store i32 0, i32* %11
br label %36
36: ; preds = %87, %34
%37 = load i32, i32* @STDIN_FILENO
%38 = load i8*, i8** %6
%39 = load i32, i32* %11
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = call i32 @read(i32 %37, i8* %41, i32 4096)
store i32 %42, i32* %10
%43 = load i32, i32* %10
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %47
45: ; preds = %36
%46 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %141
47: ; preds = %36
%48 = load i32, i32* %10
%49 = load i32, i32* %11
%50 = add nsw i32 %49, %48
store i32 %50, i32* %11
%51 = load i32, i32* %11
%52 = icmp sgt i32 %51, 4186112
br i1 %52, label %56, label %53
53: ; preds = %47
%54 = load i32, i32* %10
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %83
56: ; preds = %53, %47
store i32 0, i32* %12
store i32 0, i32* %13
br label %57
57: ; preds = %75, %56
%58 = load i32, i32* %7
%59 = load i8*, i8** %6
%60 = load i32, i32* %13
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
%63 = load i32, i32* %11
%64 = load i32, i32* %13
%65 = sub nsw i32 %63, %64
%66 = call i32 @write(i32 %58, i8* %62, i32 %65)
store i32 %66, i32* %12
%67 = load i32, i32* %12
%68 = icmp eq i32 %67, -1
br i1 %68, label %69, label %71
69: ; preds = %57
%70 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %141
71: ; preds = %57
%72 = load i32, i32* %12
%73 = load i32, i32* %13
%74 = add nsw i32 %73, %72
store i32 %74, i32* %13
br label %75
75: ; preds = %71
%76 = load i32, i32* %13
%77 = load i32, i32* %11
%78 = icmp slt i32 %76, %77
br i1 %78, label %57, label %79
79: ; preds = %75
%80 = load i8*, i8** %6
%81 = load i32, i32* %11
%82 = call i32 @SHA256_Update(i32* %9, i8* %80, i32 %81)
store i32 0, i32* %11
br label %83
83: ; preds = %79, %53
%84 = load i32, i32* %10
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %87
86: ; preds = %83
br label %88
87: ; preds = %83
br label %36
88: ; preds = %86
%89 = load i32, i32* @SHA256_DIGEST_LENGTH
%90 = zext i32 %89 to i64
%91 = call i8* @llvm.stacksave()
store i8* %91, i8** %14
%92 = alloca i8, i64 %90
store i64 %90, i64* %15
store i8* %92, i8** %16
%93 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
store i8* %93, i8** %18
%94 = call i32 @SHA256_Final(i8* %92, i32* %9)
store i32 0, i32* %19
br label %95
95: ; preds = %108, %88
%96 = load i32, i32* %19
%97 = load i32, i32* @SHA256_DIGEST_LENGTH
%98 = icmp slt i32 %96, %97
br i1 %98, label %99, label %111
99: ; preds = %95
%100 = load i8*, i8** %18
%101 = load i8*, i8** %16
%102 = getelementptr inbounds i8, i8* %101, i32 1
store i8* %102, i8** %16
%103 = load i8, i8* %101
%104 = zext i8 %103 to i32
%105 = call i32 @sprintf(i8* %100, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %104)
%106 = load i8*, i8** %18
%107 = getelementptr inbounds i8, i8* %106, i64 2
store i8* %107, i8** %18
br label %108
108: ; preds = %99
%109 = load i32, i32* %19
%110 = add nsw i32 %109, 1
store i32 %110, i32* %19
br label %95
111: ; preds = %95
%112 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 32
store i8 0, i8* %112
%113 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %113)
%115 = load i32, i32* %4
%116 = icmp sgt i32 %115, 1
br i1 %116, label %117, label %123
117: ; preds = %111
%118 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%119 = load i8**, i8*** %5
%120 = getelementptr inbounds i8*, i8** %119, i64 1
%121 = load i8*, i8** %120
%122 = call i32 @strncat(i8* %118, i8* %121, i32 128)
br label %123
123: ; preds = %117, %111
%124 = getelementptr inbounds [21 x i8], [21 x i8]* %8, i64 0, i64 0
%125 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%126 = call i32 @rename(i8* %124, i8* %125)
store i32 %126, i32* %20
%127 = load i32, i32* %20
%128 = icmp eq i32 %127, -1
br i1 %128, label %129, label %131
129: ; preds = %123
%130 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %131
131: ; preds = %129, %123
%132 = load i32, i32* %7
%133 = call i32 @close(i32 %132)
store i32 %133, i32* %20
%134 = load i32, i32* %20
%135 = icmp eq i32 %134, -1
br i1 %135, label %136, label %138
136: ; preds = %131
%137 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
br label %138
138: ; preds = %136, %131
%139 = load i32, i32* %20
store i32 %139, i32* %3
%140 = load i8*, i8** %14
br label %141
141: ; preds = %138, %69, %45, %32, %24
%142 = load i32, i32* %3
ret i32 %142
}

LLVM IR (-O2):
@__const.main.outf_name = [21 x i8] c"temp_hashname_XXXXXX\00"
@.str.1 = [24 x i8] c"Creating temporary file\00"
@STDIN_FILENO = global i32 0
@.str.2 = [19 x i8] c"Reading from stdin\00"
@.str.3 = [20 x i8] c"Writing output file\00"
@SHA256_DIGEST_LENGTH = global i32 0
@.str.4 = [5 x i8] c"%02x\00"
@.str.6 = [19 x i8] c"Renaming temp file\00"
@.str.7 = [20 x i8] c"Closing output file\00"
@str = [27 x i8] c"Could not allocate buffer.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [21 x i8]
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = tail call dereferenceable_or_null(4194304) i8* @malloc(i32 4194304)
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %93
10: ; preds = %2
%11 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%12 = call i32 @mkstemp(i8* %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %91
16: ; preds = %10
%17 = bitcast i32* %4 to i8*
%18 = call i32 @SHA256_Init(i32* %4)
br label %19
19: ; preds = %47, %16
%20 = phi i32 [ 0, %16 ], [ %48, %47 ]
%21 = load i32, i32* @STDIN_FILENO
%22 = sext i32 %20 to i64
%23 = getelementptr inbounds i8, i8* %6, i64 %22
%24 = call i32 @read(i32 %21, i8* %23, i32 4096)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %89
28: ; preds = %19
%29 = add nsw i32 %24, %20
%30 = icmp sgt i32 %29, 4186112
%31 = icmp eq i32 %24, 0
%32 = or i1 %31, %30
br i1 %32, label %33, label %47
33: ; preds = %28, %42
%34 = phi i32 [ %43, %42 ], [ 0, %28 ]
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %6, i64 %35
%37 = sub nsw i32 %29, %34
%38 = call i32 @write(i32 %12, i8* %36, i32 %37)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %42
40: ; preds = %33
%41 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %89
42: ; preds = %33
%43 = add nsw i32 %38, %34
%44 = icmp slt i32 %43, %29
br i1 %44, label %33, label %45
45: ; preds = %42
%46 = call i32 @SHA256_Update(i32* %4, i8* %6, i32 %29)
br label %47
47: ; preds = %45, %28
%48 = phi i32 [ 0, %45 ], [ %29, %28 ]
br i1 %31, label %49, label %19
49: ; preds = %47
%50 = load i32, i32* @SHA256_DIGEST_LENGTH
%51 = zext i32 %50 to i64
%52 = call i8* @llvm.stacksave()
%53 = alloca i8, i64 %51
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%55 = call i32 @SHA256_Final(i8* %53, i32* %4)
%56 = load i32, i32* @SHA256_DIGEST_LENGTH
%57 = icmp sgt i32 %56, 0
br i1 %57, label %58, label %70
58: ; preds = %49, %58
%59 = phi i32 [ %67, %58 ], [ 0, %49 ]
%60 = phi i8* [ %66, %58 ], [ %54, %49 ]
%61 = phi i8* [ %62, %58 ], [ %53, %49 ]
%62 = getelementptr inbounds i8, i8* %61, i64 1
%63 = load i8, i8* %61
%64 = zext i8 %63 to i32
%65 = call i32 @sprintf(i8* dereferenceable(1) %60, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %64)
%66 = getelementptr inbounds i8, i8* %60, i64 2
%67 = add nuw nsw i32 %59, 1
%68 = load i32, i32* @SHA256_DIGEST_LENGTH
%69 = icmp slt i32 %67, %68
br i1 %69, label %58, label %70
70: ; preds = %58, %49
%71 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 32
store i8 0, i8* %71
%72 = call i32 @puts(i8* %54)
%73 = icmp sgt i32 %0, 1
br i1 %73, label %74, label %78
74: ; preds = %70
%75 = getelementptr inbounds i8*, i8** %1, i64 1
%76 = load i8*, i8** %75
%77 = call i32 @strncat(i8* %54, i8* %76, i32 128)
br label %78
78: ; preds = %74, %70
%79 = call i32 @rename(i8* %11, i8* %54)
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %83
81: ; preds = %78
%82 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %83
83: ; preds = %81, %78
%84 = call i32 @close(i32 %12)
%85 = icmp eq i32 %84, -1
br i1 %85, label %86, label %88
86: ; preds = %83
%87 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
br label %88
88: ; preds = %86, %83
br label %89
89: ; preds = %40, %88, %26
%90 = phi i32 [ 1, %26 ], [ %84, %88 ], [ 1, %40 ]
br label %91
91: ; preds = %89, %14
%92 = phi i32 [ 1, %14 ], [ %90, %89 ]
br label %93
93: ; preds = %91, %8
%94 = phi i32 [ 1, %8 ], [ %92, %91 ]
ret i32 %94
}