#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_decode(char const *, unsigned char *, int,
                              int /*<<< orphan*/ *);
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 *, int, int, unsigned char *, int,
                               unsigned char *, int);
void set_1_challenge_2() {
  const char *input1 = "1c0111001f010100061a024b53535009181c";
  const char *input2 = "686974207468652062756c6c277320657965";
  const char *expected = "746865206b696420646f6e277420706c6179";
  unsigned char bytes1[18];
  unsigned char bytes2[18];
  unsigned char xored[18];
  char xored_hex[37];
  hex_decode(input1, bytes1, 18, NULL);
  hex_decode(input2, bytes2, 18, NULL);
  xor_perform(bytes1, 18, 1, bytes2, 18, xored, 18);
  hex_encode(xored, 18, xored_hex, 37);
  printf("Set 1 Challenge 2: %s\n",
         strcmp(xored_hex, expected) == 0 ? "PASS" : "FAIL");
}


x86 assembly (clang, -O0):
<set_1_challenge_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
lea    0xe9e(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xeb8(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xed2(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x12,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <hex_decode@plt>
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x12,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <hex_decode@plt>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rcx
lea    -0x70(%rbp),%r9
mov    $0x12,%r8d
mov    $0x1,%edx
mov    %r8d,%esi
movl   $0x12,(%rsp)
call   1060 <xor_perform@plt>
lea    -0x70(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
mov    $0x12,%esi
mov    $0x25,%ecx
call   1070 <hex_encode@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
lea    0xe89(%rip),%rsi
lea    0xe7d(%rip),%rax
cmp    $0x0,%rcx
cmove  %rax,%rsi
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_1_challenge_2>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x98,%rsp
lea    0xe9b(%rip),%rdi
lea    0x50(%rsp),%r14
mov    %r14,%rsi
mov    $0x12,%edx
xor    %ecx,%ecx
call   1040 <hex_decode@plt>
lea    0xea5(%rip),%rdi
lea    0x30(%rsp),%r15
mov    %r15,%rsi
mov    $0x12,%edx
xor    %ecx,%ecx
call   1040 <hex_decode@plt>
movl   $0x12,(%rsp)
lea    0x10(%rsp),%r12
mov    %r14,%rdi
mov    $0x12,%esi
mov    $0x1,%edx
mov    %r15,%rcx
mov    $0x12,%r8d
mov    %r12,%r9
call   1060 <xor_perform@plt>
lea    0x70(%rsp),%rbx
mov    %r12,%rdi
mov    $0x12,%esi
mov    %rbx,%rdx
mov    $0x25,%ecx
call   1070 <hex_encode@plt>
lea    0xe6b(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
lea    0xe95(%rip),%rax
lea    0xe93(%rip),%rsi
cmove  %rax,%rsi
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [37 x i8] c"1c0111001f010100061a024b53535009181c\00"
@.str.1 = [37 x i8] c"686974207468652062756c6c277320657965\00"
@.str.2 = [37 x i8] c"746865206b696420646f6e277420706c6179\00"
@.str.3 = [23 x i8] c"Set 1 Challenge 2: %s\0A\00"
@.str.4 = [5 x i8] c"PASS\00"
@.str.5 = [5 x i8] c"FAIL\00"
define void @set_1_challenge_2() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [18 x i8]
%5 = alloca [18 x i8]
%6 = alloca [18 x i8]
%7 = alloca [37 x i8]
store i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8** %3
%8 = load i8*, i8** %1
%9 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 0
%10 = call i32 @hex_decode(i8* %8, i8* %9, i32 18, i32* null)
%11 = load i8*, i8** %2
%12 = getelementptr inbounds [18 x i8], [18 x i8]* %5, i64 0, i64 0
%13 = call i32 @hex_decode(i8* %11, i8* %12, i32 18, i32* null)
%14 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [18 x i8], [18 x i8]* %5, i64 0, i64 0
%16 = getelementptr inbounds [18 x i8], [18 x i8]* %6, i64 0, i64 0
%17 = call i32 @xor_perform(i8* %14, i32 18, i32 1, i8* %15, i32 18, i8* %16, i32 18)
%18 = getelementptr inbounds [18 x i8], [18 x i8]* %6, i64 0, i64 0
%19 = getelementptr inbounds [37 x i8], [37 x i8]* %7, i64 0, i64 0
%20 = call i32 @hex_encode(i8* %18, i32 18, i8* %19, i32 37)
%21 = getelementptr inbounds [37 x i8], [37 x i8]* %7, i64 0, i64 0
%22 = load i8*, i8** %3
%23 = call i64 @strcmp(i8* %21, i8* %22)
%24 = icmp eq i64 %23, 0
%25 = zext i1 %24 to i64
%26 = select i1 %24, 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)
%27 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %26)
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"1c0111001f010100061a024b53535009181c\00"
@.str.1 = [37 x i8] c"686974207468652062756c6c277320657965\00"
@.str.2 = [37 x i8] c"746865206b696420646f6e277420706c6179\00"
@.str.3 = [23 x i8] c"Set 1 Challenge 2: %s\0A\00"
@.str.4 = [5 x i8] c"PASS\00"
@.str.5 = [5 x i8] c"FAIL\00"
define void @set_1_challenge_2() {
%1 = alloca [18 x i8]
%2 = alloca [18 x i8]
%3 = alloca [18 x i8]
%4 = alloca [37 x i8]
%5 = getelementptr inbounds [18 x i8], [18 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [18 x i8], [18 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [37 x i8], [37 x i8]* %4, i64 0, i64 0
%9 = call i32 @hex_decode(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %5, i32 18, i32* null)
%10 = call i32 @hex_decode(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %6, i32 18, i32* null)
%11 = call i32 @xor_perform(i8* %5, i32 18, i32 1, i8* %6, i32 18, i8* %7, i32 18)
%12 = call i32 @hex_encode(i8* %7, i32 18, i8* %8, i32 37)
%13 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
%15 = 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)
%16 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %15)
ret void
}