#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*/ call_hash(char *, char *, int);
int get32_le(char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
void calc_response(char *result, char *field) {
  char buf1[128];
  char buf2[128];
  unsigned int i;
  memset(buf1, 0, 64);
  *buf1 = 128;
  memcpy(buf2, field + 16, 8);
  i = (get32_le((buf2)) >> 3) & 0x3f;
  if (i < 56) {
    i = 56 - i;
  } else {
    i = 120 - i;
  }
  call_hash(field, buf1, i);
  call_hash(field, buf2, 8);
  memcpy(result, field, 16);
}


x86 assembly (clang, -O0):
<calc_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
movb   $0x80,-0x90(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x10,%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
lea    -0x110(%rbp),%rdi
call   1060 <get32_le@plt>
sar    $0x3,%eax
and    $0x3f,%eax
mov    %eax,-0x114(%rbp)
cmpl   $0x38,-0x114(%rbp)
jae    11c1 <calc_response+0x81>
mov    $0x38,%eax
sub    -0x114(%rbp),%eax
mov    %eax,-0x114(%rbp)
jmp    11d2 <calc_response+0x92>
mov    $0x78,%eax
sub    -0x114(%rbp),%eax
mov    %eax,-0x114(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    -0x114(%rbp),%edx
call   1050 <call_hash@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    $0x8,%edx
call   1050 <call_hash@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_response>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
movb   $0x80,(%rsp)
lea    0x10(%rbx),%rsi
lea    0x80(%rsp),%r12
mov    %r12,%rdi
mov    $0x8,%edx
call   1040 <memcpy@plt>
mov    %r12,%rdi
call   1060 <get32_le@plt>
shr    $0x3,%eax
and    $0x3f,%eax
xor    %edx,%edx
cmp    $0x38,%eax
setae  %dl
shl    $0x6,%edx
sub    %eax,%edx
add    $0x38,%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <call_hash@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x8,%edx
call   1050 <call_hash@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @calc_response(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [128 x i8]
%6 = alloca [128 x i8]
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 64)
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
store i8 -128, i8* %10
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 16
%14 = call i32 @memcpy(i8* %11, i8* %13, i32 8)
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%16 = call i32 @get32_le(i8* %15)
%17 = ashr i32 %16, 3
%18 = and i32 %17, 63
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = icmp ult i32 %19, 56
br i1 %20, label %21, label %24
21: ; preds = %2
%22 = load i32, i32* %7
%23 = sub i32 56, %22
store i32 %23, i32* %7
br label %27
24: ; preds = %2
%25 = load i32, i32* %7
%26 = sub i32 120, %25
store i32 %26, i32* %7
br label %27
27: ; preds = %24, %21
%28 = load i8*, i8** %4
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%30 = load i32, i32* %7
%31 = call i32 @call_hash(i8* %28, i8* %29, i32 %30)
%32 = load i8*, i8** %4
%33 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%34 = call i32 @call_hash(i8* %32, i8* %33, i32 8)
%35 = load i8*, i8** %3
%36 = load i8*, i8** %4
%37 = call i32 @memcpy(i8* %35, i8* %36, i32 16)
ret void
}

LLVM IR (-O2):
define void @calc_response(i8* %0, i8* %1) {
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%7 = call i32 @memset(i8* %5, i32 0, i32 64)
store i8 -128, i8* %5
%8 = getelementptr inbounds i8, i8* %1, i64 16
%9 = call i32 @memcpy(i8* %6, i8* %8, i32 8)
%10 = call i32 @get32_le(i8* %6)
%11 = lshr i32 %10, 3
%12 = and i32 %11, 63
%13 = icmp ult i32 %12, 56
%14 = select i1 %13, i32 56, i32 120
%15 = sub nsw i32 %14, %12
%16 = call i32 @call_hash(i8* %1, i8* %5, i32 %15)
%17 = call i32 @call_hash(i8* %1, i8* %6, i32 8)
%18 = call i32 @memcpy(i8* %0, i8* %1, i32 16)
ret void
}