#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_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char const);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
void nxt64_vect_cmp(const unsigned char *vector, const unsigned char *in) {
  unsigned char out[2 * 8 + 1];
  int i;
  out[2 * 8] = 0;
  for (i = 0; i < 8; i++) {
    sprintf((char *)out + 2 * i, "%02x", in[i]);
  }
  if (strcmp((char *)vector, (char *)out)) {
    fprintf(stderr, "Test failedn");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<nxt64_vect_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x8,-0x34(%rbp)
jge    119a <nxt64_vect_cmp+0x5a>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
lea    0xe7d(%rip),%rsi
movzbl (%rax,%rcx,1),%edx
call   1050 <sprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    115b <nxt64_vect_cmp+0x1b>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11d4 <nxt64_vect_cmp+0x94>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nxt64_vect_cmp>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r15
movb   $0x0,0x10(%rsp)
movzbl (%rsi),%edx
lea    0xea0(%rip),%r12
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
lea    0x2(%rsp),%rdi
movzbl 0x1(%rbx),%edx
mov    %r12,%rsi
call   1050 <sprintf@plt>
lea    0x4(%rsp),%rdi
movzbl 0x2(%rbx),%edx
mov    %r12,%rsi
call   1050 <sprintf@plt>
lea    0x6(%rsp),%rdi
movzbl 0x3(%rbx),%edx
mov    %r12,%rsi
call   1050 <sprintf@plt>
lea    0x8(%rsp),%rdi
movzbl 0x4(%rbx),%edx
mov    %r12,%rsi
call   1050 <sprintf@plt>
lea    0xa(%rsp),%rdi
movzbl 0x5(%rbx),%edx
mov    %r12,%rsi
call   1050 <sprintf@plt>
lea    0xc(%rsp),%rdi
movzbl 0x6(%rbx),%edx
mov    %r12,%rsi
call   1050 <sprintf@plt>
lea    0xe(%rsp),%rdi
movzbl 0x7(%rbx),%edx
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1201 <nxt64_vect_cmp+0xc1>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
lea    0xdf4(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%02x\00"
@stderr = global i32 0
@.str.1 = [13 x i8] c"Test failedn\00"
@EXIT_FAILURE = global i32 0
define void @nxt64_vect_cmp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [17 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = getelementptr inbounds [17 x i8], [17 x i8]* %5, i64 0, i64 16
store i8 0, i8* %7
store i32 0, i32* %6
br label %8
8: ; preds = %23, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = getelementptr inbounds [17 x i8], [17 x i8]* %5, i64 0, i64 0
%13 = load i32, i32* %6
%14 = mul nsw i32 2, %13
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
%17 = load i8*, i8** %4
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %21)
br label %23
23: ; preds = %11
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %8
26: ; preds = %8
%27 = load i8*, i8** %3
%28 = getelementptr inbounds [17 x i8], [17 x i8]* %5, i64 0, i64 0
%29 = call i64 @strcmp(i8* %27, i8* %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %26
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %26
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02x\00"
@stderr = global i32 0
@.str.1 = [13 x i8] c"Test failedn\00"
@EXIT_FAILURE = global i32 0
define void @nxt64_vect_cmp(i8* %0, i8* nocapture %1) {
%3 = alloca [17 x i8]
%4 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 16
store i8 0, i8* %5
%6 = load i8, i8* %1
%7 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %6)
%8 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 2
%9 = getelementptr inbounds i8, i8* %1, i64 1
%10 = load i8, i8* %9
%11 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %10)
%12 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 4
%13 = getelementptr inbounds i8, i8* %1, i64 2
%14 = load i8, i8* %13
%15 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %14)
%16 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 6
%17 = getelementptr inbounds i8, i8* %1, i64 3
%18 = load i8, i8* %17
%19 = call i32 @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %18)
%20 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 8
%21 = getelementptr inbounds i8, i8* %1, i64 4
%22 = load i8, i8* %21
%23 = call i32 @sprintf(i8* %20, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %22)
%24 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 10
%25 = getelementptr inbounds i8, i8* %1, i64 5
%26 = load i8, i8* %25
%27 = call i32 @sprintf(i8* %24, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %26)
%28 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 12
%29 = getelementptr inbounds i8, i8* %1, i64 6
%30 = load i8, i8* %29
%31 = call i32 @sprintf(i8* %28, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %30)
%32 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 14
%33 = getelementptr inbounds i8, i8* %1, i64 7
%34 = load i8, i8* %33
%35 = call i32 @sprintf(i8* %32, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %34)
%36 = call i64 @strcmp(i8* %0, i8* %4)
%37 = icmp eq i64 %36, 0
br i1 %37, label %43, label %38
38: ; preds = %2
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %2
ret void
}