#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*/ exit(int);
unsigned char *malloc(int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memset(unsigned char *, int, int);
unsigned char *get_padblock(unsigned char *hash) {
  unsigned char *pblock;
  unsigned char *ptr;
  pblock = malloc(2048 / 8);
  if (!pblock)
    exit(1);
  ptr = pblock;
  *ptr++ = 0x00;
  *ptr++ = 0x01;
  memset(ptr, 0xff, (2048 / 8 - 160 / 8 - 3));
  ptr += (2048 / 8 - 160 / 8 - 3);
  *ptr++ = 0x00;
  memcpy(ptr, hash, 160 / 8);
  return pblock;
}


x86 assembly (clang, -O0):
<get_padblock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x100,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116f <get_padblock+0x2f>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x1,(%rax)
mov    -0x18(%rbp),%rdi
mov    $0xff,%esi
mov    $0xe9,%edx
call   1030 <memset@plt>
mov    -0x18(%rbp),%rax
add    $0xe9,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x14,%edx
call   1040 <memcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_padblock>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x100,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     119a <get_padblock+0x5a>
mov    %rax,%rbx
movw   $0x100,(%rax)
lea    0x2(%rax),%rdi
mov    $0xff,%esi
mov    $0xe9,%edx
call   1030 <memset@plt>
mov    %rbx,%rdi
add    $0xec,%rdi
movb   $0x0,0xeb(%rbx)
mov    %r14,%rsi
mov    $0x14,%edx
call   1040 <memcpy@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
define i8* @get_padblock(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = call i8* @malloc(i32 256)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %1
%11 = load i8*, i8** %3
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %4
store i8 0, i8* %12
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %4
store i8 1, i8* %14
%16 = load i8*, i8** %4
%17 = call i32 @memset(i8* %16, i32 255, i32 233)
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 233
store i8* %19, i8** %4
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %4
store i8 0, i8* %20
%22 = load i8*, i8** %4
%23 = load i8*, i8** %2
%24 = call i32 @memcpy(i8* %22, i8* %23, i32 20)
%25 = load i8*, i8** %3
ret i8* %25
}

LLVM IR (-O2):
define i8* @get_padblock(i8* %0) {
%2 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %2, i64 1
store i8 0, i8* %2
%8 = getelementptr inbounds i8, i8* %2, i64 2
store i8 1, i8* %7
%9 = tail call i32 @memset(i8* %8, i32 255, i32 233)
%10 = getelementptr inbounds i8, i8* %2, i64 235
%11 = getelementptr inbounds i8, i8* %2, i64 236
store i8 0, i8* %10
%12 = tail call i32 @memcpy(i8* %11, i8* %0, i32 20)
ret i8* %2
}