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

/* Variables and functions */
int MD5_DIGEST_LENGTH;
int /*<<< orphan*/ MD5_Final(unsigned char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Update(int /*<<< orphan*/ *, char *, scalar_t__);
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int /*<<< orphan*/, char *, int);
int main() {
  int n;
  MD5_CTX c;
  char buf[512];
  ssize_t bytes;
  unsigned char out[MD5_DIGEST_LENGTH];
  MD5_Init(&c);
  bytes = read(STDIN_FILENO, buf, 512);
  while (bytes > 0) {
    MD5_Update(&c, buf, bytes);
    bytes = read(STDIN_FILENO, buf, 512);
  }
  MD5_Final(out, &c);
  for (n = 0; n < MD5_DIGEST_LENGTH; n++)
    printf("%02x", out[n]);
  printf("\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e77(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x220(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x230(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x228(%rbp)
lea    -0xc(%rbp),%rdi
call   1060 <MD5_Init@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    -0x210(%rbp),%rsi
mov    $0x200,%edx
call   1050 <read@plt>
mov    %rax,-0x218(%rbp)
cmpq   $0x0,-0x218(%rbp)
jle    120c <main+0xbc>
lea    -0x210(%rbp),%rsi
mov    -0x218(%rbp),%rdx
lea    -0xc(%rbp),%rdi
call   1070 <MD5_Update@plt>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
lea    -0x210(%rbp),%rsi
mov    $0x200,%edx
call   1050 <read@plt>
mov    %rax,-0x218(%rbp)
jmp    11c1 <main+0x71>
mov    -0x230(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1030 <MD5_Final@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2db3(%rip),%rcx
cmp    (%rcx),%eax
jge    1260 <main+0x110>
mov    -0x230(%rbp),%rax
movslq -0x8(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1223 <main+0xd3>
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x220(%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    $0x218,%rsp
mov    %rsp,-0x38(%rbp)
mov    0x2e61(%rip),%r13
mov    0x0(%r13),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    -0x2c(%rbp),%rdi
call   1070 <MD5_Init@plt>
mov    0x2e34(%rip),%r12
mov    (%r12),%edi
lea    -0x240(%rbp),%rsi
mov    $0x200,%edx
call   1060 <read@plt>
test   %rax,%rax
jle    11f4 <main+0x94>
lea    -0x2c(%rbp),%r14
lea    -0x240(%rbp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1080 <MD5_Update@plt>
mov    (%r12),%edi
mov    %rbx,%rsi
mov    $0x200,%edx
call   1060 <read@plt>
test   %rax,%rax
jg     11d0 <main+0x70>
lea    -0x2c(%rbp),%rsi
mov    %r15,%rdi
call   1040 <MD5_Final@plt>
cmpl   $0x0,0x0(%r13)
jle    122c <main+0xcc>
lea    0xdf2(%rip),%r14
xor    %ebx,%ebx
movzbl (%r15,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0x0(%r13),%rax
cmp    %rax,%rbx
jl     1210 <main+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x38(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@MD5_DIGEST_LENGTH = global i32 0
@STDIN_FILENO = global i32 0
@.str = [5 x i8] c"%02x\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [512 x i8]
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
store i32 0, i32* %1
%8 = load i32, i32* @MD5_DIGEST_LENGTH
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %6
%11 = alloca i8, i64 %9
store i64 %9, i64* %7
%12 = call i32 @MD5_Init(i32* %3)
%13 = load i32, i32* @STDIN_FILENO
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%15 = call i64 @read(i32 %13, i8* %14, i32 512)
store i64 %15, i64* %5
br label %16
16: ; preds = %19, %0
%17 = load i64, i64* %5
%18 = icmp sgt i64 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%21 = load i64, i64* %5
%22 = call i32 @MD5_Update(i32* %3, i8* %20, i64 %21)
%23 = load i32, i32* @STDIN_FILENO
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%25 = call i64 @read(i32 %23, i8* %24, i32 512)
store i64 %25, i64* %5
br label %16
26: ; preds = %16
%27 = call i32 @MD5_Final(i8* %11, i32* %3)
store i32 0, i32* %2
br label %28
28: ; preds = %39, %26
%29 = load i32, i32* %2
%30 = load i32, i32* @MD5_DIGEST_LENGTH
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %42
32: ; preds = %28
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %11, i64 %34
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %32
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
store i32 %41, i32* %2
br label %28
42: ; preds = %28
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
%44 = load i8*, i8** %6
%45 = load i32, i32* %1
ret i32 %45
}

LLVM IR (-O2):
@MD5_DIGEST_LENGTH = global i32 0
@STDIN_FILENO = global i32 0
@.str = [5 x i8] c"%02x\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [512 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @MD5_DIGEST_LENGTH
%6 = zext i32 %5 to i64
%7 = tail call i8* @llvm.stacksave()
%8 = alloca i8, i64 %6
%9 = call i32 @MD5_Init(i32* %1)
%10 = load i32, i32* @STDIN_FILENO
%11 = call i64 @read(i32 %10, i8* %4, i32 512)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %0, %13
%14 = phi i64 [ %17, %13 ], [ %11, %0 ]
%15 = call i32 @MD5_Update(i32* %1, i8* %4, i64 %14)
%16 = load i32, i32* @STDIN_FILENO
%17 = call i64 @read(i32 %16, i8* %4, i32 512)
%18 = icmp sgt i64 %17, 0
br i1 %18, label %13, label %19
19: ; preds = %13, %0
%20 = call i32 @MD5_Final(i8* %8, i32* %1)
%21 = load i32, i32* @MD5_DIGEST_LENGTH
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %19, %23
%24 = phi i64 [ %29, %23 ], [ 0, %19 ]
%25 = getelementptr inbounds i8, i8* %8, i64 %24
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = add nuw nsw i64 %24, 1
%30 = load i32, i32* @MD5_DIGEST_LENGTH
%31 = sext i32 %30 to i64
%32 = icmp slt i64 %29, %31
br i1 %32, label %23, label %33
33: ; preds = %23, %19
%34 = call i32 @putchar(i32 10)
ret i32 0
}