#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*/ hmsg;
typedef int /*<<< orphan*/ cmsg;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ ciphersaber_1_dec(unsigned char *, unsigned char *, int,
                                     char *);
int hex2raw(char const *, unsigned char *);
int /*<<< orphan*/ memcmp(unsigned char *, char *, int);
void ciphersaber_1_test() {
  const char hmsg[] = "6f6d0babf3aa6719031530edb677ca74e0089dd0e7b8854356bb1448"
                      "e37cdbefe7f3a84f4f5fb3fd";
  unsigned char cmsg[(sizeof(hmsg) - 1) / 2];
  assert(hex2raw(hmsg, cmsg) == sizeof cmsg);
  unsigned char plainmsg[sizeof(cmsg) - 10];
  ciphersaber_1_dec(plainmsg, cmsg, sizeof(cmsg), "asdfg");
  assert(!memcmp(plainmsg, "This is a test of CipherSaber.",
                 sizeof("This is a test of CipherSaber.") - 1));
}


x86 assembly (clang, -O0):
<ciphersaber_1_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
lea    -0x60(%rbp),%rdi
lea    0xe9a(%rip),%rsi
mov    $0x51,%edx
call   1070 <memcpy@plt>
lea    -0x60(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1040 <hex2raw@plt>
cltq
cmp    $0x28,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0xb0(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    $0x28,%edx
lea    0xea4(%rip),%rcx
call   1030 <ciphersaber_1_dec@plt>
lea    -0xb0(%rbp),%rdi
lea    0xe97(%rip),%rsi
mov    $0x1e,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ciphersaber_1_test>:
push   %r14
push   %rbx
sub    $0xa8,%rsp
movaps 0xeef(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xed3(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeb7(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe9b(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe7f(%rip),%xmm0
movaps %xmm0,(%rsp)
movb   $0x0,0x50(%rsp)
mov    %rsp,%rdi
lea    0x80(%rsp),%r14
mov    %r14,%rsi
call   1040 <hex2raw@plt>
xor    %edi,%edi
cmp    $0x28,%eax
sete   %dil
call   1060 <assert@plt>
lea    0xe9f(%rip),%rcx
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x28,%edx
call   1030 <ciphersaber_1_dec@plt>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1e,%edx
call   1050 <memcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
add    $0xa8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.ciphersaber_1_test.hmsg = [81 x i8] c"6f6d0babf3aa6719031530edb677ca74e0089dd0e7b8854356bb1448e37cdbefe7f3a84f4f5fb3fd\00"
@.str = [6 x i8] c"asdfg\00"
@.str.1 = [31 x i8] c"This is a test of CipherSaber.\00"
define void @ciphersaber_1_test() {
%1 = alloca [81 x i8]
%2 = alloca [40 x i8]
%3 = alloca [30 x i8]
%4 = bitcast [81 x i8]* %1 to i8*
%5 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%7 = call i32 @hex2raw(i8* %5, i8* %6)
%8 = sext i32 %7 to i64
%9 = icmp eq i64 %8, 40
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%14 = call i32 @ciphersaber_1_dec(i8* %12, i8* %13, i32 40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%15 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%16 = call i32 @memcmp(i8* %15, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 30)
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
ret void
}

LLVM IR (-O2):
@__const.ciphersaber_1_test.hmsg = [81 x i8] c"6f6d0babf3aa6719031530edb677ca74e0089dd0e7b8854356bb1448e37cdbefe7f3a84f4f5fb3fd\00"
@.str = [6 x i8] c"asdfg\00"
@.str.1 = [31 x i8] c"This is a test of CipherSaber.\00"
define void @ciphersaber_1_test() {
%1 = alloca [81 x i8]
%2 = alloca [40 x i8]
%3 = alloca [30 x i8]
%4 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%6 = call i32 @hex2raw(i8* %4, i8* %5)
%7 = icmp eq i32 %6, 40
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%11 = call i32 @ciphersaber_1_dec(i8* %10, i8* %5, i32 40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @memcmp(i8* %10, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 30)
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
ret void
}