#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 uint8_t;

/* Variables and functions */
int /*<<< orphan*/ Flap(int *, int const, int, int const *, int const, int *);
int /*<<< orphan*/ __Hash2(int *, int, int *, int, int *);
int /*<<< orphan*/ memcpy(int *, int const *, int const);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int const);
void CI_Update(const uint8_t *old_hash, const uint8_t lambda,
               const uint8_t *salt, const uint8_t saltlen,
               const uint8_t old_garlic, const uint8_t new_garlic,
               const uint8_t hashlen, uint8_t *new_hash) {
  uint8_t c;
  uint8_t x[64];
  memcpy(x, old_hash, hashlen);
  memset(x + hashlen, 0, 64 - hashlen);
  for (c = old_garlic + 1; c <= new_garlic; c++) {
    Flap(x, lambda, c, salt, saltlen, x);
    __Hash2(&c, 1, x, 64, x);
    memset(x + hashlen, 0, 64 - hashlen);
  }
  memcpy(new_hash, x, hashlen);
}


x86 assembly (clang, -O0):
<CI_Update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    0x10(%rbp),%edx
call   1050 <memcpy@plt>
lea    -0x130(%rbp),%rdi
movslq 0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    $0x40,%edx
sub    0x10(%rbp),%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     1222 <CI_Update+0xe2>
lea    -0x130(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
lea    -0x130(%rbp),%r9
call   1030 <Flap@plt>
lea    -0x130(%rbp),%rdx
lea    -0x130(%rbp),%r8
lea    -0x28(%rbp),%rdi
mov    $0x1,%esi
mov    $0x40,%ecx
call   1060 <__Hash2@plt>
lea    -0x130(%rbp),%rdi
movslq 0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    $0x40,%edx
sub    0x10(%rbp),%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11a5 <CI_Update+0x65>
mov    0x18(%rbp),%rdi
lea    -0x130(%rbp),%rsi
mov    0x10(%rbp),%edx
call   1050 <memcpy@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CI_Update>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %r9d,%ebx
mov    %r8,0x10(%rsp)
mov    %ecx,0xc(%rsp)
mov    %rdx,%r12
mov    %esi,%ebp
mov    %rdi,%rsi
movslq 0x160(%rsp),%r15
lea    0x20(%rsp),%rdi
mov    %r15d,%edx
call   1050 <memcpy@plt>
lea    (%rsp,%r15,4),%r13
add    $0x20,%r13
mov    $0x40,%r14d
mov    %r15,0x18(%rsp)
sub    %r15d,%r14d
mov    %r13,%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1040 <memset@plt>
mov    0x10(%rsp),%rax
lea    0x1(%rax),%edx
mov    %edx,0x8(%rsp)
cmp    %ebx,%eax
jge    120b <CI_Update+0xcb>
lea    0x20(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r12,%rcx
mov    0xc(%rsp),%r8d
mov    %r15,%r9
call   1030 <Flap@plt>
lea    0x8(%rsp),%rdi
mov    $0x1,%esi
mov    %r15,%rdx
mov    $0x40,%ecx
mov    %r15,%r8
call   1060 <__Hash2@plt>
mov    %r13,%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1040 <memset@plt>
mov    0x8(%rsp),%eax
lea    0x1(%rax),%edx
mov    %edx,0x8(%rsp)
cmp    %ebx,%eax
jl     11c0 <CI_Update+0x80>
lea    0x20(%rsp),%rsi
mov    0x168(%rsp),%rdi
mov    0x18(%rsp),%rdx
call   1050 <memcpy@plt>
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @CI_Update(i32* %0, i32 %1, i32* %2, i32 %3, i32 %4, i32 %5, i32 %6, i32* %7) {
%9 = alloca i32
%10 = alloca [64 x i32]
%11 = bitcast i32* %9 to i8*
%12 = bitcast [64 x i32]* %10 to i8*
%13 = getelementptr inbounds [64 x i32], [64 x i32]* %10, i64 0, i64 0
%14 = call i32 @memcpy(i32* %13, i32* %0, i32 %6)
%15 = sext i32 %6 to i64
%16 = getelementptr inbounds [64 x i32], [64 x i32]* %10, i64 0, i64 %15
%17 = sub nsw i32 64, %6
%18 = call i32 @memset(i32* %16, i32 0, i32 %17)
%19 = add nsw i32 %4, 1
store i32 %19, i32* %9
%20 = icmp slt i32 %4, %5
br i1 %20, label %21, label %29
21: ; preds = %8, %21
%22 = phi i32 [ %27, %21 ], [ %19, %8 ]
%23 = call i32 @Flap(i32* %13, i32 %1, i32 %22, i32* %2, i32 %3, i32* %13)
%24 = call i32 @__Hash2(i32* %9, i32 1, i32* %13, i32 64, i32* %13)
%25 = call i32 @memset(i32* %16, i32 0, i32 %17)
%26 = load i32, i32* %9
%27 = add nsw i32 %26, 1
store i32 %27, i32* %9
%28 = icmp slt i32 %26, %5
br i1 %28, label %21, label %29
29: ; preds = %21, %8
%30 = call i32 @memcpy(i32* %7, i32* %13, i32 %6)
ret void
}