#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*/ hex_encode(unsigned char *, int, char *, int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(char *, char const *);
int /*<<< orphan*/ xor_perform(unsigned char const *, int, int,
                               unsigned char const *, int, unsigned char *,
                               int);
void set_1_challenge_5() {
  const char *input = "Burning 'em, if you ain't quick and nimble\nI go crazy "
                      "when I hear a cymbal";
  const char *expected = "0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d633"
                         "43c2a26226324272765272a282b2f20430a652e2c652a3124333a"
                         "653e2b2027630c692b20283165286326302e27282f";
  unsigned char buf[74];
  char hex[149];
  xor_perform((const unsigned char *)input, 74, 1, (const unsigned char *)"ICE",
              3, buf, 75);
  hex_encode(buf, 74, hex, 149);
  printf("Set 1 Challenge 5: %s\n",
         strcmp(hex, expected) == 0 ? "PASS" : "FAIL");
}


x86 assembly (clang, -O0):
<set_1_challenge_5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
lea    0xeae(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xeee(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%r9
mov    $0x4a,%esi
mov    $0x1,%edx
lea    0xf66(%rip),%rcx
mov    $0x3,%r8d
movl   $0x4b,(%rsp)
call   1050 <xor_perform@plt>
lea    -0x60(%rbp),%rdi
lea    -0x100(%rbp),%rdx
mov    $0x4a,%esi
mov    $0x95,%ecx
call   1060 <hex_encode@plt>
lea    -0x100(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
lea    0xf40(%rip),%rsi
lea    0xf34(%rip),%rax
cmp    $0x0,%rcx
cmove  %rax,%rsi
lea    0xf0e(%rip),%rdi
call   1030 <printf@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_1_challenge_5>:
push   %r14
push   %rbx
sub    $0xf8,%rsp
movl   $0x4b,(%rsp)
lea    0xea8(%rip),%rdi
lea    0xf81(%rip),%rcx
lea    0x10(%rsp),%r14
mov    $0x4a,%esi
mov    $0x1,%edx
mov    $0x3,%r8d
mov    %r14,%r9
call   1050 <xor_perform@plt>
lea    0x60(%rsp),%rbx
mov    %r14,%rdi
mov    $0x4a,%esi
mov    %rbx,%rdx
mov    $0x95,%ecx
call   1060 <hex_encode@plt>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
lea    0xf4c(%rip),%rax
lea    0xf4a(%rip),%rsi
cmove  %rax,%rsi
lea    0xf23(%rip),%rdi
call   1030 <printf@plt>
add    $0xf8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [75 x i8] c"Burning 'em, if you ain't quick and nimble\0AI go crazy when I hear a cymbal\00"
@.str.1 = [149 x i8] c"0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d63343c2a26226324272765272a282b2f20430a652e2c652a3124333a653e2b2027630c692b20283165286326302e27282f\00"
@.str.2 = [4 x i8] c"ICE\00"
@.str.3 = [23 x i8] c"Set 1 Challenge 5: %s\0A\00"
@.str.4 = [5 x i8] c"PASS\00"
@.str.5 = [5 x i8] c"FAIL\00"
define void @set_1_challenge_5() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca [74 x i8]
%4 = alloca [149 x i8]
store i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i8** %2
%5 = load i8*, i8** %1
%6 = getelementptr inbounds [74 x i8], [74 x i8]* %3, i64 0, i64 0
%7 = call i32 @xor_perform(i8* %5, i32 74, i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3, i8* %6, i32 75)
%8 = getelementptr inbounds [74 x i8], [74 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [149 x i8], [149 x i8]* %4, i64 0, i64 0
%10 = call i32 @hex_encode(i8* %8, i32 74, i8* %9, i32 149)
%11 = getelementptr inbounds [149 x i8], [149 x i8]* %4, i64 0, i64 0
%12 = load i8*, i8** %2
%13 = call i64 @strcmp(i8* %11, i8* %12)
%14 = icmp eq i64 %13, 0
%15 = zext i1 %14 to i64
%16 = select i1 %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0)
%17 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %16)
ret void
}

LLVM IR (-O2):
@.str = [75 x i8] c"Burning 'em, if you ain't quick and nimble\0AI go crazy when I hear a cymbal\00"
@.str.1 = [149 x i8] c"0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d63343c2a26226324272765272a282b2f20430a652e2c652a3124333a653e2b2027630c692b20283165286326302e27282f\00"
@.str.2 = [4 x i8] c"ICE\00"
@.str.3 = [23 x i8] c"Set 1 Challenge 5: %s\0A\00"
@.str.4 = [5 x i8] c"PASS\00"
@.str.5 = [5 x i8] c"FAIL\00"
define void @set_1_challenge_5() {
%1 = alloca [74 x i8]
%2 = alloca [149 x i8]
%3 = getelementptr inbounds [74 x i8], [74 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [149 x i8], [149 x i8]* %2, i64 0, i64 0
%5 = call i32 @xor_perform(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), i32 74, i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3, i8* %3, i32 75)
%6 = call i32 @hex_encode(i8* %3, i32 74, i8* %4, i32 149)
%7 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0)
%10 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %9)
ret void
}