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

/* Variables and functions */
int /*<<< orphan*/ *EVP_MD_CTX_create();
int /*<<< orphan*/ EVP_MD_CTX_destroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ do_step_G(int /*<<< orphan*/ *, unsigned char *,
                             unsigned char const *, unsigned char *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ log2(int);
int /*<<< orphan*/ printf(char *);
void oaep_G(const unsigned char *macro, unsigned char *gout,
            unsigned char *buffer) {
  int step;
  EVP_MD_CTX *ctx = EVP_MD_CTX_create();
  if (NULL == ctx) {
    printf("Cannot allocate needed memory\n");
    exit(EXIT_FAILURE);
  }
  for (step = 0; step < ((int)log2(4096)) / ((int)log2((64 / 4))); ++step) {
    do_step_G(ctx, buffer, macro, gout, step);
    macro = gout;
  }
  EVP_MD_CTX_destroy(ctx);
}


x86 assembly (clang, -O0):
<oaep_G>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1080 <EVP_MD_CTX_create@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
jne    11a5 <oaep_G+0x45>
lea    0xe6e(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    $0x1000,%edi
call   1030 <log2@plt>
mov    %eax,-0x30(%rbp)
mov    $0x10,%edi
call   1030 <log2@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jge    120e <oaep_G+0xae>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
call   1040 <do_step_G@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ac <oaep_G+0x4c>
mov    -0x28(%rbp),%rdi
call   1060 <EVP_MD_CTX_destroy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oaep_G>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%r12
xor    %eax,%eax
call   1080 <EVP_MD_CTX_create@plt>
test   %rax,%rax
je     1240 <oaep_G+0xe0>
mov    %rax,%r15
mov    $0x1000,%edi
call   1030 <log2@plt>
mov    %rax,%rbp
mov    $0x10,%edi
call   1030 <log2@plt>
mov    %rax,%rcx
mov    %ebp,%eax
cltd
idiv   %ecx
test   %eax,%eax
jle    122a <oaep_G+0xca>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %r8d,%r8d
call   1050 <do_step_G@plt>
mov    $0x1000,%edi
call   1030 <log2@plt>
mov    %rax,%rbp
mov    $0x10,%edi
call   1030 <log2@plt>
mov    %rax,%rcx
mov    %ebp,%eax
cltd
idiv   %ecx
cmp    $0x2,%eax
jl     122a <oaep_G+0xca>
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
mov    %r13,%rcx
mov    %ebp,%r8d
call   1050 <do_step_G@plt>
add    $0x1,%ebp
mov    $0x1000,%edi
call   1030 <log2@plt>
mov    %rax,%rbx
mov    $0x10,%edi
call   1030 <log2@plt>
mov    %rax,%rcx
mov    %ebx,%eax
cltd
idiv   %ecx
cmp    %eax,%ebp
jl     11f0 <oaep_G+0x90>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <EVP_MD_CTX_destroy@plt>
lea    0xdb9(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"Cannot allocate needed memory\0A\00"
@EXIT_FAILURE = global i32 0
define void @oaep_G(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = call i32* (...) @EVP_MD_CTX_create()
store i32* %9, i32** %8
%10 = load i32*, i32** %8
%11 = icmp eq i32* null, %10
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %3
store i32 0, i32* %7
br label %17
17: ; preds = %33, %16
%18 = load i32, i32* %7
%19 = call i64 @log2(i32 4096)
%20 = trunc i64 %19 to i32
%21 = call i64 @log2(i32 16)
%22 = trunc i64 %21 to i32
%23 = sdiv i32 %20, %22
%24 = icmp slt i32 %18, %23
br i1 %24, label %25, label %36
25: ; preds = %17
%26 = load i32*, i32** %8
%27 = load i8*, i8** %6
%28 = load i8*, i8** %4
%29 = load i8*, i8** %5
%30 = load i32, i32* %7
%31 = call i32 @do_step_G(i32* %26, i8* %27, i8* %28, i8* %29, i32 %30)
%32 = load i8*, i8** %5
store i8* %32, i8** %4
br label %33
33: ; preds = %25
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %17
36: ; preds = %17
%37 = load i32*, i32** %8
%38 = call i32 @EVP_MD_CTX_destroy(i32* %37)
ret void
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@str = [30 x i8] c"Cannot allocate needed memory\00"
define void @oaep_G(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32* (...) @EVP_MD_CTX_create()
%5 = icmp eq i32* %4, null
br i1 %5, label %21, label %6
6: ; preds = %3
%7 = tail call i64 @log2(i32 4096)
%8 = trunc i64 %7 to i32
%9 = tail call i64 @log2(i32 16)
%10 = trunc i64 %9 to i32
%11 = sdiv i32 %8, %10
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %35
13: ; preds = %6
%14 = tail call i32 @do_step_G(i32* %4, i8* %2, i8* %0, i8* %1, i32 0)
%15 = tail call i64 @log2(i32 4096)
%16 = trunc i64 %15 to i32
%17 = tail call i64 @log2(i32 16)
%18 = trunc i64 %17 to i32
%19 = sdiv i32 %16, %18
%20 = icmp sgt i32 %19, 1
br i1 %20, label %25, label %35
21: ; preds = %3
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %13, %25
%26 = phi i32 [ %28, %25 ], [ 1, %13 ]
%27 = tail call i32 @do_step_G(i32* %4, i8* %2, i8* %1, i8* %1, i32 %26)
%28 = add nuw nsw i32 %26, 1
%29 = tail call i64 @log2(i32 4096)
%30 = trunc i64 %29 to i32
%31 = tail call i64 @log2(i32 16)
%32 = trunc i64 %31 to i32
%33 = sdiv i32 %30, %32
%34 = icmp slt i32 %28, %33
br i1 %34, label %25, label %35
35: ; preds = %25, %13, %6
%36 = tail call i32 @EVP_MD_CTX_destroy(i32* %4)
ret void
}