#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*/ memcpy(unsigned char *, unsigned int *, int);
int sha2_exec(unsigned int *, unsigned char *, int);
int sha2_init(unsigned int *);
int sha2_double_round(unsigned int *Hi, unsigned char *data, int len) {
  unsigned char round2[32];
  do {
    int _x = (sha2_init(Hi));
    if ((_x)) {
      return (_x);
    }
  } while (0);
  do {
    int _x = (sha2_exec(Hi, data, len));
    if ((_x)) {
      return (_x);
    }
  } while (0);
  memcpy(round2, Hi, 32);
  do {
    int _x = (sha2_init(Hi));
    if ((_x)) {
      return (_x);
    }
  } while (0);
  do {
    int _x = (sha2_exec(Hi, round2, 32));
    if ((_x)) {
      return (_x);
    }
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<sha2_double_round>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <sha2_init@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
je     1164 <sha2_double_round+0x34>
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    120e <sha2_double_round+0xde>
jmp    1169 <sha2_double_round+0x39>
jmp    116e <sha2_double_round+0x3e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <sha2_exec@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
je     1196 <sha2_double_round+0x66>
mov    -0x48(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    120e <sha2_double_round+0xde>
jmp    119b <sha2_double_round+0x6b>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x20,%edx
call   1040 <memcpy@plt>
mov    -0x10(%rbp),%rdi
call   1050 <sha2_init@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     11ce <sha2_double_round+0x9e>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    120e <sha2_double_round+0xde>
jmp    11d3 <sha2_double_round+0xa3>
jmp    11d8 <sha2_double_round+0xa8>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x20,%edx
call   1030 <sha2_exec@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
je     1202 <sha2_double_round+0xd2>
mov    -0x50(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    120e <sha2_double_round+0xde>
jmp    1207 <sha2_double_round+0xd7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sha2_double_round>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%rbx
call   1050 <sha2_init@plt>
test   %eax,%eax
jne    1188 <sha2_double_round+0x58>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1030 <sha2_exec@plt>
test   %eax,%eax
jne    1188 <sha2_double_round+0x58>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    $0x20,%edx
call   1040 <memcpy@plt>
mov    %rbx,%rdi
call   1050 <sha2_init@plt>
test   %eax,%eax
jne    1188 <sha2_double_round+0x58>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x20,%edx
call   1030 <sha2_exec@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @sha2_double_round(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [32 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
br label %13
13: ; preds = %3
%14 = load i32*, i32** %5
%15 = call i32 @sha2_init(i32* %14)
store i32 %15, i32* %9
%16 = load i32, i32* %9
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = load i32, i32* %9
store i32 %19, i32* %4
br label %55
20: ; preds = %13
br label %21
21: ; preds = %20
br label %22
22: ; preds = %21
%23 = load i32*, i32** %5
%24 = load i8*, i8** %6
%25 = load i32, i32* %7
%26 = call i32 @sha2_exec(i32* %23, i8* %24, i32 %25)
store i32 %26, i32* %10
%27 = load i32, i32* %10
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %22
%30 = load i32, i32* %10
store i32 %30, i32* %4
br label %55
31: ; preds = %22
br label %32
32: ; preds = %31
%33 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%34 = load i32*, i32** %5
%35 = call i32 @memcpy(i8* %33, i32* %34, i32 32)
br label %36
36: ; preds = %32
%37 = load i32*, i32** %5
%38 = call i32 @sha2_init(i32* %37)
store i32 %38, i32* %11
%39 = load i32, i32* %11
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = load i32, i32* %11
store i32 %42, i32* %4
br label %55
43: ; preds = %36
br label %44
44: ; preds = %43
br label %45
45: ; preds = %44
%46 = load i32*, i32** %5
%47 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%48 = call i32 @sha2_exec(i32* %46, i8* %47, i32 32)
store i32 %48, i32* %12
%49 = load i32, i32* %12
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %45
%52 = load i32, i32* %12
store i32 %52, i32* %4
br label %55
53: ; preds = %45
br label %54
54: ; preds = %53
store i32 0, i32* %4
br label %55
55: ; preds = %54, %51, %41, %29, %18
%56 = load i32, i32* %4
ret i32 %56
}

LLVM IR (-O2):
define i32 @sha2_double_round(i32* %0, i8* %1, i32 %2) {
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @sha2_init(i32* %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %3
%9 = tail call i32 @sha2_exec(i32* %0, i8* %1, i32 %2)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = call i32 @memcpy(i8* %5, i32* %0, i32 32)
%13 = call i32 @sha2_init(i32* %0)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @sha2_exec(i32* %0, i8* %5, i32 32)
br label %17
17: ; preds = %15, %11, %8, %3
%18 = phi i32 [ %13, %11 ], [ %9, %8 ], [ %6, %3 ], [ %16, %15 ]
ret i32 %18
}