#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*/ base64_encode(unsigned char *, int, char *, int);
int /*<<< orphan*/ hex_decode(char const *, unsigned char *, int,
                              int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(char *, char const *);
void set_1_challenge_1() {
  const char *input = "49276d206b696c6c696e6720796f757220627261696e206c696b6520"
                      "6120706f69736f6e6f7573206d757368726f6f6d";
  const char *expected =
      "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t";
  unsigned char bytes[48];
  char base64[65];
  hex_decode(input, bytes, 48, NULL);
  base64_encode(bytes, 48, base64, 65);
  printf("Set 1 Challenge 1: %s\n",
         strcmp(base64, expected) == 0 ? "PASS" : "FAIL");
}


x86 assembly (clang, -O0):
<set_1_challenge_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
lea    0xeae(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xf04(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x30,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <hex_decode@plt>
lea    -0x40(%rbp),%rdi
lea    -0x90(%rbp),%rdx
mov    $0x30,%esi
mov    $0x41,%ecx
call   1060 <base64_encode@plt>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
lea    0xf13(%rip),%rsi
lea    0xf07(%rip),%rax
cmp    $0x0,%rcx
cmove  %rax,%rsi
lea    0xee1(%rip),%rdi
call   1030 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_1_challenge_1>:
push   %r14
push   %rbx
sub    $0x78,%rsp
lea    0xeb2(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
mov    $0x30,%edx
xor    %ecx,%ecx
call   1040 <hex_decode@plt>
lea    0x30(%rsp),%rbx
mov    %r14,%rdi
mov    $0x30,%esi
mov    %rbx,%rdx
mov    $0x41,%ecx
call   1060 <base64_encode@plt>
lea    0xee0(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
lea    0xf26(%rip),%rax
lea    0xf24(%rip),%rsi
cmove  %rax,%rsi
lea    0xefd(%rip),%rdi
call   1030 <printf@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [97 x i8] c"49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d\00"
@.str.1 = [65 x i8] c"SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t\00"
@.str.2 = [23 x i8] c"Set 1 Challenge 1: %s\0A\00"
@.str.3 = [5 x i8] c"PASS\00"
@.str.4 = [5 x i8] c"FAIL\00"
define void @set_1_challenge_1() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca [48 x i8]
%4 = alloca [65 x i8]
store i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i8** %2
%5 = load i8*, i8** %1
%6 = getelementptr inbounds [48 x i8], [48 x i8]* %3, i64 0, i64 0
%7 = call i32 @hex_decode(i8* %5, i8* %6, i32 48, i32* null)
%8 = getelementptr inbounds [48 x i8], [48 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [65 x i8], [65 x i8]* %4, i64 0, i64 0
%10 = call i32 @base64_encode(i8* %8, i32 48, i8* %9, i32 65)
%11 = getelementptr inbounds [65 x i8], [65 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.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0)
%17 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %16)
ret void
}

LLVM IR (-O2):
@.str = [97 x i8] c"49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d\00"
@.str.1 = [65 x i8] c"SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t\00"
@.str.2 = [23 x i8] c"Set 1 Challenge 1: %s\0A\00"
@.str.3 = [5 x i8] c"PASS\00"
@.str.4 = [5 x i8] c"FAIL\00"
define void @set_1_challenge_1() {
%1 = alloca [48 x i8]
%2 = alloca [65 x i8]
%3 = getelementptr inbounds [48 x i8], [48 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 0
%5 = call i32 @hex_decode(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0), i8* %3, i32 48, i32* null)
%6 = call i32 @base64_encode(i8* %3, i32 48, i8* %4, i32 65)
%7 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([65 x i8], [65 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.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0)
%10 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %9)
ret void
}