#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 EOF;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getchar();
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stderr;
size_t strlen(char *);
int main(int argc, char *argv[]) {
  char *ks;
  size_t kl;
  int ki;
  if (argc != 2) {
    fprintf(stderr, "usage: %s key\n", argv[0]);
    return EXIT_FAILURE;
  }
  ks = argv[1];
  kl = strlen(ks);
  ki = 0;
  for (;;) {
    char ic, kc, oc;
    int r;
    r = getchar();
    if (EOF == r)
      break;
    ic = r;
    kc = ks[ki];
    oc = ic ^ kc;
    putchar(oc);
    ki = (ki + 1) % kl;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     118d <main+0x4d>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe89(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    121e <main+0xde>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%eax
cmp    -0x2c(%rbp),%eax
jne    11ce <main+0x8e>
jmp    1212 <main+0xd2>
mov    -0x2c(%rbp),%eax
mov    %al,-0x25(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x26(%rbp)
movsbl -0x25(%rbp),%eax
movsbl -0x26(%rbp),%ecx
xor    %ecx,%eax
mov    %al,-0x27(%rbp)
movsbl -0x27(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x20(%rbp)
mov    %edx,%eax
mov    %eax,-0x24(%rbp)
jmp    11ad <main+0x6d>
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmp    $0x2,%edi
jne    11c1 <main+0x81>
mov    0x8(%rsi),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rax,%r15
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e7b(%rip),%r13
mov    0x2e54(%rip),%r12
jmp    118f <main+0x4f>
cs nopw 0x0(%rax,%rax,1)
xor    %edx,%edx
div    %r15
mov    %rdx,%rbx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    %eax,0x0(%r13)
je     11e0 <main+0xa0>
movslq %ebx,%rbx
xor    (%r14,%rbx,1),%al
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
movslq %ebx,%rax
mov    %rax,%rcx
or     %r15,%rcx
shr    $0x20,%rcx
jne    1180 <main+0x40>
mov    %ebx,%eax
xor    %edx,%edx
div    %r15d
mov    %edx,%ebx
jmp    1188 <main+0x48>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe2c(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2df0(%rip),%r12
mov    (%r12),%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"usage: %s key\0A\00"
@EXIT_FAILURE = global i32 0
@EOF = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %31
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strlen(i8* dereferenceable(1) %10)
%12 = tail call i32 (...) @getchar()
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %13, %12
br i1 %14, label %31, label %15
15: ; preds = %8, %15
%16 = phi i32 [ %28, %15 ], [ %12, %8 ]
%17 = phi i32 [ %27, %15 ], [ 0, %8 ]
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %10, i64 %18
%20 = load i8, i8* %19
%21 = trunc i32 %16 to i8
%22 = xor i8 %20, %21
%23 = tail call i32 @putchar(i8 signext %22)
%24 = add nsw i32 %17, 1
%25 = sext i32 %24 to i64
%26 = urem i64 %25, %11
%27 = trunc i64 %26 to i32
%28 = tail call i32 (...) @getchar()
%29 = load i32, i32* @EOF
%30 = icmp eq i32 %29, %28
br i1 %30, label %31, label %15
31: ; preds = %15, %8, %4
%32 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_SUCCESS, %8 ], [ @EXIT_SUCCESS, %15 ]
%33 = load i32, i32* %32
ret i32 %33
}