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

/* Variables and functions */
int SHA_DIGEST_LENGTH;
int /*<<< orphan*/ SHA_Final(unsigned char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ SHA_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ SHA_Update(int /*<<< orphan*/ *, unsigned char *,
                              unsigned long);
int fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ pt(unsigned char *);
int read(int, unsigned char *, int);
void do_fp(FILE *f) {
  SHA_CTX c;
  unsigned char md[SHA_DIGEST_LENGTH];
  int fd;
  int i;
  unsigned char buf[1024 * 16];
  fd = fileno(f);
  SHA_Init(&c);
  for (;;) {
    i = read(fd, buf, 1024 * 16);
    if (i <= 0)
      break;
    SHA_Update(&c, buf, (unsigned long)i);
  }
  SHA_Final(&(md[0]), &c);
  pt(md);
}


x86 assembly (clang, -O0):
<do_fp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4040,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x4038(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <fileno@plt>
mov    %eax,-0x24(%rbp)
lea    -0xc(%rbp),%rdi
call   1060 <SHA_Init@plt>
mov    -0x24(%rbp),%edi
lea    -0x4030(%rbp),%rsi
mov    $0x4000,%edx
call   1050 <read@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jg     11d9 <do_fp+0x79>
jmp    11f2 <do_fp+0x92>
lea    -0x4030(%rbp),%rsi
movslq -0x28(%rbp),%rdx
lea    -0xc(%rbp),%rdi
call   1030 <SHA_Update@plt>
jmp    11b3 <do_fp+0x53>
mov    -0x4038(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1080 <SHA_Final@plt>
mov    -0x4038(%rbp),%rdi
call   1040 <pt@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_fp>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4008,%rsp
mov    %rsp,%r13
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
call   1070 <fileno@plt>
mov    %eax,%r12d
lea    -0x2c(%rbp),%rdi
call   1060 <SHA_Init@plt>
lea    -0x4030(%rbp),%rsi
mov    %r12d,%edi
mov    $0x4000,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    11f1 <do_fp+0x91>
lea    -0x2c(%rbp),%r15
lea    -0x4030(%rbp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <SHA_Update@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x4000,%edx
call   1050 <read@plt>
test   %eax,%eax
jg     11d0 <do_fp+0x70>
lea    -0x2c(%rbp),%rsi
mov    %r14,%rdi
call   1080 <SHA_Final@plt>
mov    %r14,%rdi
call   1040 <pt@plt>
mov    %r13,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SHA_DIGEST_LENGTH = global i32 0
define void @do_fp(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca [16384 x i8]
store i32* %0, i32** %2
%9 = load i32, i32* @SHA_DIGEST_LENGTH
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %4
%12 = alloca i8, i64 %10
store i64 %10, i64* %5
%13 = load i32*, i32** %2
%14 = call i32 @fileno(i32* %13)
store i32 %14, i32* %6
%15 = call i32 @SHA_Init(i32* %3)
br label %16
16: ; preds = %23, %1
%17 = load i32, i32* %6
%18 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 0
%19 = call i32 @read(i32 %17, i8* %18, i32 16384)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp sle i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %16
br label %28
23: ; preds = %16
%24 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 0
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = call i32 @SHA_Update(i32* %3, i8* %24, i64 %26)
br label %16
28: ; preds = %22
%29 = getelementptr inbounds i8, i8* %12, i64 0
%30 = call i32 @SHA_Final(i8* %29, i32* %3)
%31 = call i32 @pt(i8* %12)
%32 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
@SHA_DIGEST_LENGTH = global i32 0
define void @do_fp(i32* nocapture %0) {
%2 = alloca i32
%3 = alloca [16384 x i8]
%4 = bitcast i32* %2 to i8*
%5 = load i32, i32* @SHA_DIGEST_LENGTH
%6 = zext i32 %5 to i64
%7 = tail call i8* @llvm.stacksave()
%8 = alloca i8, i64 %6
%9 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 0
%10 = tail call i32 @fileno(i32* %0)
%11 = call i32 @SHA_Init(i32* %2)
%12 = call i32 @read(i32 %10, i8* %9, i32 16384)
%13 = icmp slt i32 %12, 1
br i1 %13, label %20, label %14
14: ; preds = %1, %14
%15 = phi i32 [ %18, %14 ], [ %12, %1 ]
%16 = zext i32 %15 to i64
%17 = call i32 @SHA_Update(i32* %2, i8* %9, i64 %16)
%18 = call i32 @read(i32 %10, i8* %9, i32 16384)
%19 = icmp slt i32 %18, 1
br i1 %19, label %20, label %14
20: ; preds = %14, %1
%21 = call i32 @SHA_Final(i8* %8, i32* %2)
%22 = call i32 @pt(i8* %8)
ret void
}