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

/* Variables and functions */
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ const *,
                          int);
int /*<<< orphan*/ mrtd_crypto_encrypt_3des(int /*<<< orphan*/ *,
                                            int /*<<< orphan*/ *, int,
                                            int /*<<< orphan*/ const *);
int /*<<< orphan*/ mrtd_crypto_mac_padding(int /*<<< orphan*/ *,
                                           int /*<<< orphan*/ *, int,
                                           int /*<<< orphan*/ const *);
void mrtd_bac_eifd_mifd(const uint8_t *rnd_ifd, const uint8_t *kifd,
                        const uint8_t *remote_challenge, const uint8_t *kenc,
                        const uint8_t *kmac, uint8_t *eifd, uint8_t *mifd) {
  uint8_t S[32];
  memcpy(S, rnd_ifd, 8);
  memcpy(S + 8, remote_challenge, 8);
  memcpy(S + 16, kifd, 16);
  mrtd_crypto_encrypt_3des(S, eifd, 32, kenc);
  mrtd_crypto_mac_padding(eifd, mifd, 32, kmac);
}


x86 assembly (clang, -O0):
<mrtd_bac_eifd_mifd>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
lea    -0xb0(%rbp),%rdi
add    $0x20,%rdi
mov    -0x18(%rbp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
lea    -0xb0(%rbp),%rdi
add    $0x40,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x10,%edx
call   1030 <memcpy@plt>
lea    -0xb0(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    $0x20,%edx
call   1050 <mrtd_crypto_encrypt_3des@plt>
mov    -0x30(%rbp),%rdi
mov    0x10(%rbp),%rsi
mov    -0x28(%rbp),%rcx
mov    $0x20,%edx
call   1040 <mrtd_crypto_mac_padding@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mrtd_bac_eifd_mifd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r9,%r13
mov    %r8,%r14
mov    %rcx,%r12
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rdi,%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x8,%edx
call   1030 <memcpy@plt>
lea    0x20(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
lea    0x40(%rsp),%rdi
mov    %rbp,%rsi
mov    $0x10,%edx
call   1030 <memcpy@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x20,%edx
mov    %r12,%rcx
call   1050 <mrtd_crypto_encrypt_3des@plt>
mov    %r13,%rdi
mov    0xc0(%rsp),%rsi
mov    $0x20,%edx
mov    %r14,%rcx
call   1040 <mrtd_crypto_mac_padding@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @mrtd_bac_eifd_mifd(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca [32 x i32]
store i32* %0, i32** %8
store i32* %1, i32** %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32* %6, i32** %14
%16 = getelementptr inbounds [32 x i32], [32 x i32]* %15, i64 0, i64 0
%17 = load i32*, i32** %8
%18 = call i32 @memcpy(i32* %16, i32* %17, i32 8)
%19 = getelementptr inbounds [32 x i32], [32 x i32]* %15, i64 0, i64 0
%20 = getelementptr inbounds i32, i32* %19, i64 8
%21 = load i32*, i32** %10
%22 = call i32 @memcpy(i32* %20, i32* %21, i32 8)
%23 = getelementptr inbounds [32 x i32], [32 x i32]* %15, i64 0, i64 0
%24 = getelementptr inbounds i32, i32* %23, i64 16
%25 = load i32*, i32** %9
%26 = call i32 @memcpy(i32* %24, i32* %25, i32 16)
%27 = getelementptr inbounds [32 x i32], [32 x i32]* %15, i64 0, i64 0
%28 = load i32*, i32** %13
%29 = load i32*, i32** %11
%30 = call i32 @mrtd_crypto_encrypt_3des(i32* %27, i32* %28, i32 32, i32* %29)
%31 = load i32*, i32** %13
%32 = load i32*, i32** %14
%33 = load i32*, i32** %12
%34 = call i32 @mrtd_crypto_mac_padding(i32* %31, i32* %32, i32 32, i32* %33)
ret void
}

LLVM IR (-O2):
define void @mrtd_bac_eifd_mifd(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca [32 x i32]
%9 = bitcast [32 x i32]* %8 to i8*
%10 = getelementptr inbounds [32 x i32], [32 x i32]* %8, i64 0, i64 0
%11 = call i32 @memcpy(i32* %10, i32* %0, i32 8)
%12 = getelementptr inbounds [32 x i32], [32 x i32]* %8, i64 0, i64 8
%13 = call i32 @memcpy(i32* %12, i32* %2, i32 8)
%14 = getelementptr inbounds [32 x i32], [32 x i32]* %8, i64 0, i64 16
%15 = call i32 @memcpy(i32* %14, i32* %1, i32 16)
%16 = call i32 @mrtd_crypto_encrypt_3des(i32* %10, i32* %5, i32 32, i32* %3)
%17 = call i32 @mrtd_crypto_mac_padding(i32* %5, i32* %6, i32 32, i32* %4)
ret void
}