#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 */
char *malloc(unsigned int);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ putchar(char);
unsigned int strlen(char *);
void main(int argc, char *argv[]) {
  char *clr = "I.Wrote.A.Kernel!";
  char *enc;
  char key = '\x69';
  unsigned int i = 0;
  unsigned int j = 0;
  if (argc > 1) {
    clr = argv[1];
  }
  if (argc > 2) {
    key = argv[2][0];
  }
  enc = malloc(strlen(clr));
  for (j = 0; j <= strlen(clr); j++) {
    enc[j] = clr[j] ^ key;
    printf("\\x%02x", enc[j]);
  }
  putchar('\n');
  return;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x18(%rbp)
movb   $0x69,-0x21(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x1,-0x4(%rbp)
jle    1182 <main+0x42>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x4(%rbp)
jle    1199 <main+0x59>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%al
mov    %al,-0x21(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
ja     1212 <main+0xd2>
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
movsbl -0x21(%rbp),%ecx
xor    %ecx,%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
lea    0xe17(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1050 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b4 <main+0x74>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x69,%r15b
cmp    $0x2,%edi
jl     114e <main+0x1e>
mov    0x8(%rsi),%rbx
je     1155 <main+0x25>
mov    0x10(%rsi),%rax
mov    (%rax),%r15b
jmp    1155 <main+0x25>
lea    0xeab(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
xor    %ebp,%ebp
lea    0xea4(%rip),%r14
xchg   %ax,%ax
mov    %ebp,%eax
movzbl (%rbx,%rax,1),%eax
xor    %r15b,%al
movsbl %al,%esi
mov    %r14,%rdi
call   1050 <printf@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    %eax,%ebp
jbe    1170 <main+0x40>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"I.Wrote.A.Kernel!\00"
@.str.1 = [7 x i8] c"\\x%02x\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8** %5
store i8 105, i8* %7
store i32 0, i32* %8
store i32 0, i32* %9
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
store i8* %15, i8** %5
br label %16
16: ; preds = %12, %2
%17 = load i32, i32* %3
%18 = icmp sgt i32 %17, 2
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = load i8**, i8*** %4
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
store i8 %24, i8* %7
br label %25
25: ; preds = %19, %16
%26 = load i8*, i8** %5
%27 = call i32 @strlen(i8* %26)
%28 = call i8* @malloc(i32 %27)
store i8* %28, i8** %6
store i32 0, i32* %9
br label %29
29: ; preds = %55, %25
%30 = load i32, i32* %9
%31 = load i8*, i8** %5
%32 = call i32 @strlen(i8* %31)
%33 = icmp ule i32 %30, %32
br i1 %33, label %34, label %58
34: ; preds = %29
%35 = load i8*, i8** %5
%36 = load i32, i32* %9
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = load i8, i8* %7
%42 = sext i8 %41 to i32
%43 = xor i32 %40, %42
%44 = trunc i32 %43 to i8
%45 = load i8*, i8** %6
%46 = load i32, i32* %9
%47 = zext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
store i8 %44, i8* %48
%49 = load i8*, i8** %6
%50 = load i32, i32* %9
%51 = zext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8, i8* %52
%54 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 signext %53)
br label %55
55: ; preds = %34
%56 = load i32, i32* %9
%57 = add i32 %56, 1
store i32 %57, i32* %9
br label %29
58: ; preds = %29
%59 = call i32 @putchar(i8 signext 10)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"I.Wrote.A.Kernel!\00"
@.str.1 = [7 x i8] c"\\x%02x\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %12
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = icmp eq i32 %0, 2
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = load i8, i8* %10
br label %12
12: ; preds = %2, %8, %4
%13 = phi i8* [ %6, %8 ], [ %6, %4 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %2 ]
%14 = phi i8 [ %11, %8 ], [ 105, %4 ], [ 105, %2 ]
%15 = tail call i32 @strlen(i8* %13)
%16 = tail call i32 @strlen(i8* %13)
br label %17
17: ; preds = %12, %17
%18 = phi i32 [ 0, %12 ], [ %24, %17 ]
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %13, i64 %19
%21 = load i8, i8* %20
%22 = xor i8 %21, %14
%23 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 signext %22)
%24 = add i32 %18, 1
%25 = tail call i32 @strlen(i8* %13)
%26 = icmp ugt i32 %24, %25
br i1 %26, label %27, label %17
27: ; preds = %17
%28 = tail call i32 @putchar(i8 signext 10)
ret void
}