#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*/ des(unsigned long **, unsigned char *);
int /*<<< orphan*/ deskey(unsigned long **, unsigned char *, int);
int /*<<< orphan*/ feof(int /*<<< orphan*/);
int /*<<< orphan*/ get8(unsigned char *);
scalar_t__ memcmp(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ put8(unsigned char *);
int /*<<< orphan*/ stdin;
main() {
  unsigned char key[8], plain[8], cipher[8], work[8];
  int test;
  int fail;
  static unsigned long kne[16][2], knd[16][2];
  for (test = 0; !feof(stdin); test++) {
    fail = 0;
    get8(key);
    printf(" K: ");
    put8(key);
    deskey(kne, key, 0);
    deskey(knd, key, 1);
    get8(plain);
    printf(" P: ");
    put8(plain);
    get8(cipher);
    printf(" C: ");
    put8(cipher);
    memcpy(work, plain, 8);
    des(kne, work);
    if (memcmp(work, cipher, 8) != 0) {
      printf(" Encrypt FAIL");
      printf(" c: ");
      put8(work);
      fail++;
    }
    des(knd, work);
    if (memcmp(work, plain, 8) != 0) {
      printf(" Decrypt FAIL");
      printf(" p: ");
      put8(work);
      fail++;
    }
    if (fail == 0)
      printf(" OK");
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x28(%rbp)
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b9 <main+0x39>
jmp    132f <main+0x1af>
movl   $0x0,-0x2c(%rbp)
lea    -0xc(%rbp),%rdi
call   1040 <get8@plt>
lea    0xe30(%rip),%rdi
call   1050 <printf@plt>
lea    -0xc(%rbp),%rdi
call   1030 <put8@plt>
lea    -0xc(%rbp),%rsi
lea    0x2e87(%rip),%rdi
xor    %edx,%edx
call   1060 <deskey@plt>
lea    -0xc(%rbp),%rsi
lea    0x2f75(%rip),%rdi
mov    $0x1,%edx
call   1060 <deskey@plt>
lea    -0x14(%rbp),%rdi
call   1040 <get8@plt>
lea    0xdf0(%rip),%rdi
call   1050 <printf@plt>
lea    -0x14(%rbp),%rdi
call   1030 <put8@plt>
lea    -0x1c(%rbp),%rdi
call   1040 <get8@plt>
lea    0xdd7(%rip),%rdi
call   1050 <printf@plt>
lea    -0x1c(%rbp),%rdi
call   1030 <put8@plt>
lea    -0x24(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x8,%edx
call   10a0 <memcpy@plt>
lea    -0x24(%rbp),%rsi
lea    0x2e12(%rip),%rdi
call   1070 <des@plt>
lea    -0x24(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x8,%edx
call   1080 <memcmp@plt>
cmp    $0x0,%rax
je     12a9 <main+0x129>
lea    0xd89(%rip),%rdi
call   1050 <printf@plt>
lea    0xd8b(%rip),%rdi
call   1050 <printf@plt>
lea    -0x24(%rbp),%rdi
call   1030 <put8@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
lea    -0x24(%rbp),%rsi
lea    0x2ebc(%rip),%rdi
call   1070 <des@plt>
lea    -0x24(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x8,%edx
call   1080 <memcmp@plt>
cmp    $0x0,%rax
je     12ff <main+0x17f>
lea    0xd46(%rip),%rdi
call   1050 <printf@plt>
lea    0xd48(%rip),%rdi
call   1050 <printf@plt>
lea    -0x24(%rbp),%rdi
call   1030 <put8@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    1315 <main+0x195>
lea    0xd25(%rip),%rdi
call   1050 <printf@plt>
lea    0xd1d(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1196 <main+0x16>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   10a0 <feof@plt>
test   %eax,%eax
je     11c1 <main+0x31>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x20(%rsp),%r13
lea    0x18(%rsp),%r12
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%rbp
jmp    121c <main+0x8c>
nopw   0x0(%rax,%rax,1)
lea    0xe3b(%rip),%rdi
call   1060 <printf@plt>
lea    0xe3d(%rip),%rdi
call   1060 <printf@plt>
mov    %rbp,%rdi
call   1030 <put8@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
call   10a0 <feof@plt>
test   %eax,%eax
jne    11b0 <main+0x20>
mov    %r13,%rdi
call   1050 <get8@plt>
lea    0xdd5(%rip),%rdi
call   1060 <printf@plt>
mov    %r13,%rdi
call   1030 <put8@plt>
lea    0x2e41(%rip),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %edx,%edx
call   1070 <deskey@plt>
lea    0x2f2d(%rip),%rdi
mov    %r13,%rsi
mov    $0x1,%edx
call   1070 <deskey@plt>
mov    %r12,%rdi
call   1050 <get8@plt>
lea    0xd96(%rip),%rdi
call   1060 <printf@plt>
mov    %r12,%rdi
call   1030 <put8@plt>
mov    %r14,%rdi
call   1050 <get8@plt>
lea    0xd7f(%rip),%rdi
call   1060 <printf@plt>
mov    %r14,%rdi
call   1030 <put8@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    $0x8,%edx
call   10b0 <memcpy@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1080 <des@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
call   1090 <memcmp@plt>
mov    %rax,%r15
test   %rax,%rax
je     12eb <main+0x15b>
lea    0xd3d(%rip),%rdi
call   1060 <printf@plt>
lea    0xd3f(%rip),%rdi
call   1060 <printf@plt>
mov    %rbp,%rdi
call   1030 <put8@plt>
lea    0x2e8e(%rip),%rdi
mov    %rbp,%rsi
call   1080 <des@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    $0x8,%edx
call   1090 <memcmp@plt>
test   %rax,%rax
jne    11e0 <main+0x50>
test   %r15,%r15
jne    1200 <main+0x70>
lea    0xd12(%rip),%rdi
call   1060 <printf@plt>
jmp    1200 <main+0x70>

LLVM IR (-O0):
@main.kne = internal global [16 x [2 x i64]] zeroinitializer
@main.knd = internal global [16 x [2 x i64]] zeroinitializer
@stdin = global i32 0
@.str = [5 x i8] c" K: \00"
@.str.1 = [5 x i8] c" P: \00"
@.str.2 = [5 x i8] c" C: \00"
@.str.3 = [14 x i8] c" Encrypt FAIL\00"
@.str.4 = [5 x i8] c" c: \00"
@.str.5 = [14 x i8] c" Decrypt FAIL\00"
@.str.6 = [5 x i8] c" p: \00"
@.str.7 = [4 x i8] c" OK\00"
@.str.8 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8]
%3 = alloca [8 x i8]
%4 = alloca [8 x i8]
%5 = alloca [8 x i8]
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
br label %8
8: ; preds = %70, %0
%9 = load i32, i32* @stdin
%10 = call i32 @feof(i32 %9)
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %73
13: ; preds = %8
store i32 0, i32* %7
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%15 = call i32 @get8(i8* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%18 = call i32 @put8(i8* %17)
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%20 = call i32 @deskey(i64** bitcast ([16 x [2 x i64]]* @main.kne to i64**), i8* %19, i32 0)
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%22 = call i32 @deskey(i64** bitcast ([16 x [2 x i64]]* @main.knd to i64**), i8* %21, i32 1)
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%24 = call i32 @get8(i8* %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%27 = call i32 @put8(i8* %26)
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%29 = call i32 @get8(i8* %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%31 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%32 = call i32 @put8(i8* %31)
%33 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%34 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%35 = call i32 @memcpy(i8* %33, i8* %34, i32 8)
%36 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%37 = call i32 @des(i64** bitcast ([16 x [2 x i64]]* @main.kne to i64**), i8* %36)
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%39 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%40 = call i64 @memcmp(i8* %38, i8* %39, i32 8)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %49
42: ; preds = %13
%43 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%44 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%45 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%46 = call i32 @put8(i8* %45)
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %49
49: ; preds = %42, %13
%50 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%51 = call i32 @des(i64** bitcast ([16 x [2 x i64]]* @main.knd to i64**), i8* %50)
%52 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%53 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%54 = call i64 @memcmp(i8* %52, i8* %53, i32 8)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %63
56: ; preds = %49
%57 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%58 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%59 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%60 = call i32 @put8(i8* %59)
%61 = load i32, i32* %7
%62 = add nsw i32 %61, 1
store i32 %62, i32* %7
br label %63
63: ; preds = %56, %49
%64 = load i32, i32* %7
%65 = icmp eq i32 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %63
%67 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %68
68: ; preds = %66, %63
%69 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %70
70: ; preds = %68
%71 = load i32, i32* %6
%72 = add nsw i32 %71, 1
store i32 %72, i32* %6
br label %8
73: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@main.kne = internal global [16 x [2 x i64]] zeroinitializer
@main.knd = internal global [16 x [2 x i64]] zeroinitializer
@stdin = global i32 0
@.str = [5 x i8] c" K: \00"
@.str.1 = [5 x i8] c" P: \00"
@.str.2 = [5 x i8] c" C: \00"
@.str.3 = [14 x i8] c" Encrypt FAIL\00"
@.str.4 = [5 x i8] c" c: \00"
@.str.5 = [14 x i8] c" Decrypt FAIL\00"
@.str.6 = [5 x i8] c" p: \00"
@.str.7 = [4 x i8] c" OK\00"
define i32 @main() {
%1 = alloca [8 x i8]
%2 = alloca [8 x i8]
%3 = alloca [8 x i8]
%4 = alloca [8 x i8]
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%9 = load i32, i32* @stdin
%10 = call i32 @feof(i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %48
12: ; preds = %0, %43
%13 = call i32 @get8(i8* %5)
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @put8(i8* %5)
%16 = call i32 @deskey(i64** bitcast ([16 x [2 x i64]]* @main.kne to i64**), i8* %5, i32 0)
%17 = call i32 @deskey(i64** bitcast ([16 x [2 x i64]]* @main.knd to i64**), i8* %5, i32 1)
%18 = call i32 @get8(i8* %6)
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @put8(i8* %6)
%21 = call i32 @get8(i8* %7)
%22 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @put8(i8* %7)
%24 = call i32 @memcpy(i8* %8, i8* %6, i32 8)
%25 = call i32 @des(i64** bitcast ([16 x [2 x i64]]* @main.kne to i64**), i8* %8)
%26 = call i64 @memcmp(i8* %8, i8* %7, i32 8)
%27 = icmp eq i64 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %12
%29 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 @put8(i8* %8)
br label %32
32: ; preds = %28, %12
%33 = call i32 @des(i64** bitcast ([16 x [2 x i64]]* @main.knd to i64**), i8* %8)
%34 = call i64 @memcmp(i8* %8, i8* %6, i32 8)
%35 = icmp eq i64 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %32
%37 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%38 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%39 = call i32 @put8(i8* %8)
br label %43
40: ; preds = %32
br i1 %27, label %41, label %43
41: ; preds = %40
%42 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %43
43: ; preds = %36, %41, %40
%44 = call i32 @putchar(i32 10)
%45 = load i32, i32* @stdin
%46 = call i32 @feof(i32 %45)
%47 = icmp eq i32 %46, 0
br i1 %47, label %12, label %48
48: ; preds = %43, %0
ret i32 0
}