#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 */

/* Variables and functions */
int /*<<< orphan*/ SHA512(unsigned char *, int /*<<< orphan*/, unsigned char *);
int SHA512_DIGEST_LENGTH;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strlen(char *);
int main() {
  char data[] = "lore ipsum\n";
  char hash[SHA512_DIGEST_LENGTH];
  SHA512((unsigned char *)data, strlen(data), (unsigned char *)hash);
  printf("%i\n", SHA512_DIGEST_LENGTH);
  puts(data);
  for (size_t i = 0; i < SHA512_DIGEST_LENGTH; ++i) {
    printf("%02x", (unsigned char)hash[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movabs $0x7370692065726f6c,%rax
69 70 73
mov    %rax,-0x10(%rbp)
movl   $0xa6d75,-0x8(%rbp)
mov    0x2e7d(%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,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    %eax,%esi
call   1060 <SHA512@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%esi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1030 <puts@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2e05(%rip),%rcx
movslq (%rcx),%rcx
cmp    %rcx,%rax
jae    121a <main+0xda>
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11d8 <main+0x98>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%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    $0x18,%rsp
mov    %rsp,%r15
movabs $0x7370692065726f6c,%rax
69 70 73
mov    %rax,-0x38(%rbp)
movl   $0xa6d75,-0x30(%rbp)
mov    0x2e68(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
lea    -0x38(%rbp),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %r13,%rdx
call   1070 <SHA512@plt>
mov    (%r12),%esi
lea    0xe53(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
cmpl   $0x0,(%r12)
je     11fd <main+0xad>
lea    0xe3a(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl 0x0(%r13,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
movslq (%r12),%rax
cmp    %rax,%rbx
jb     11e0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.data = [12 x i8] c"lore ipsum\0A\00"
@SHA512_DIGEST_LENGTH = global i32 0
@.str = [4 x i8] c"%i\0A\00"
@.str.1 = [5 x i8] c"%02x\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [12 x i8]
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
%6 = bitcast [12 x i8]* %2 to i8*
%7 = load i32, i32* @SHA512_DIGEST_LENGTH
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %3
%10 = alloca i8, i64 %8
store i64 %8, i64* %4
%11 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = call i32 @SHA512(i8* %11, i32 %13, i8* %10)
%15 = load i32, i32* @SHA512_DIGEST_LENGTH
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%18 = call i32 @puts(i8* %17)
store i64 0, i64* %5
br label %19
19: ; preds = %30, %0
%20 = load i64, i64* %5
%21 = load i32, i32* @SHA512_DIGEST_LENGTH
%22 = sext i32 %21 to i64
%23 = icmp ult i64 %20, %22
br i1 %23, label %24, label %33
24: ; preds = %19
%25 = load i64, i64* %5
%26 = getelementptr inbounds i8, i8* %10, i64 %25
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %24
%31 = load i64, i64* %5
%32 = add i64 %31, 1
store i64 %32, i64* %5
br label %19
33: ; preds = %19
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%35 = load i8*, i8** %3
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@__const.main.data = [12 x i8] c"lore ipsum\0A\00"
@SHA512_DIGEST_LENGTH = global i32 0
@.str = [4 x i8] c"%i\0A\00"
@.str.1 = [5 x i8] c"%02x\00"
define i32 @main() {
%1 = alloca [12 x i8]
%2 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @SHA512_DIGEST_LENGTH
%4 = zext i32 %3 to i64
%5 = tail call i8* @llvm.stacksave()
%6 = alloca i8, i64 %4
%7 = call i32 @strlen(i8* %2)
%8 = call i32 @SHA512(i8* %2, i32 %7, i8* %6)
%9 = load i32, i32* @SHA512_DIGEST_LENGTH
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @puts(i8* %2)
%12 = load i32, i32* @SHA512_DIGEST_LENGTH
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %16, %0
%15 = call i32 @putchar(i32 10)
ret i32 0
16: ; preds = %0, %16
%17 = phi i64 [ %22, %16 ], [ 0, %0 ]
%18 = getelementptr inbounds i8, i8* %6, i64 %17
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = add nuw i64 %17, 1
%23 = load i32, i32* @SHA512_DIGEST_LENGTH
%24 = sext i32 %23 to i64
%25 = icmp ult i64 %22, %24
br i1 %25, label %16, label %14
}