#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ decipher(unsigned int, int *, int *);
int /*<<< orphan*/ encipher(unsigned int, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
void main(int argc, char **argv) {
  uint32_t i;
  uint32_t s0, s1;
  uint32_t k[] = {0, 0, 0, 0};
  uint32_t v[] = {0, 0};
  unsigned int rounds = 32;
  printf("i #                k               #       pt       #        ct      "
         "\n");
  for (i = 0; i < 100; i++) {
    printf("%02X %08X%08X%08X%08X ", i, k[0], k[1], k[2], k[3]);
    printf("%08X%08X ", v[0], v[1]);
    encipher(rounds, v, k);
    s0 = v[0];
    s1 = v[1];
    printf("%08X%08X\n", v[0], v[1]);
    decipher(rounds, v, k);
    k[2 + (i % 2)] ^= s0;
    k[1 - (i % 2)] ^= s1;
    v[0] = s0;
    v[1] = s1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
movl   $0x20,-0x3c(%rbp)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    125d <main+0x11d>
mov    -0x14(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x24(%rbp),%r9d
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%edi
lea    -0x38(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1050 <encipher@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x38(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%edi
lea    -0x38(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1060 <decipher@plt>
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
add    $0x2,%edx
movslq %edx,%rax
xor    -0x30(%rbp,%rax,4),%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x1c(%rbp),%ecx
mov    -0x14(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    $0x1,%eax
sub    %edx,%eax
cltq
xor    -0x30(%rbp,%rax,4),%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x18(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118b <main+0x4b>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%r12
lea    0x10(%rsp),%rbx
lea    0xe9b(%rip),%r13
xor    %r9d,%r9d
xor    %r8d,%r8d
xor    %ecx,%ecx
xor    %edx,%edx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
lea    0xe69(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x20,%edi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1050 <encipher@plt>
mov    0x8(%rsp),%r14d
mov    0xc(%rsp),%r15d
mov    %r13,%rdi
mov    %r14d,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x20,%edi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <decipher@plt>
mov    %ebp,%eax
and    $0x1,%eax
lea    0x2(%rax),%ecx
xor    %r14d,0x10(%rsp,%rcx,4)
xor    $0x1,%eax
xor    %r15d,0x10(%rsp,%rax,4)
mov    %r14d,0x8(%rsp)
mov    %r15d,0xc(%rsp)
cmp    $0x63,%ebp
je     122e <main+0xee>
mov    0x10(%rsp),%edx
mov    0x14(%rsp),%ecx
mov    0x18(%rsp),%r8d
mov    0x1c(%rsp),%r9d
add    $0x1,%ebp
jmp    1190 <main+0x50>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [71 x i8] c"i # k # pt # ct \0A\00"
@.str.1 = [23 x i8] c"%02X %08X%08X%08X%08X \00"
@.str.2 = [10 x i8] c"%08X%08X \00"
@.str.3 = [10 x i8] c"%08X%08X\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [4 x i32]
%9 = alloca [2 x i32]
%10 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%11 = bitcast [4 x i32]* %8 to i8*
%12 = bitcast [2 x i32]* %9 to i8*
store i32 32, i32* %10
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %14
14: ; preds = %70, %2
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 100
br i1 %16, label %17, label %73
17: ; preds = %14
%18 = load i32, i32* %5
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 0
%20 = load i32, i32* %19
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 1
%22 = load i32, i32* %21
%23 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 2
%24 = load i32, i32* %23
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 3
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %20, i32 %22, i32 %24, i32 %26)
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%29 = load i32, i32* %28
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %31)
%33 = load i32, i32* %10
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%35 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 0
%36 = call i32 @encipher(i32 %33, i32* %34, i32* %35)
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%38 = load i32, i32* %37
store i32 %38, i32* %6
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%40 = load i32, i32* %39
store i32 %40, i32* %7
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%42 = load i32, i32* %41
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %42, i32 %44)
%46 = load i32, i32* %10
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%48 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 0
%49 = call i32 @decipher(i32 %46, i32* %47, i32* %48)
%50 = load i32, i32* %6
%51 = load i32, i32* %5
%52 = srem i32 %51, 2
%53 = add nsw i32 2, %52
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = xor i32 %56, %50
store i32 %57, i32* %55
%58 = load i32, i32* %7
%59 = load i32, i32* %5
%60 = srem i32 %59, 2
%61 = sub nsw i32 1, %60
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 %62
%64 = load i32, i32* %63
%65 = xor i32 %64, %58
store i32 %65, i32* %63
%66 = load i32, i32* %6
%67 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
store i32 %66, i32* %67
%68 = load i32, i32* %7
%69 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
store i32 %68, i32* %69
br label %70
70: ; preds = %17
%71 = load i32, i32* %5
%72 = add nsw i32 %71, 1
store i32 %72, i32* %5
br label %14
73: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str.1 = [23 x i8] c"%02X %08X%08X%08X%08X \00"
@.str.2 = [10 x i8] c"%08X%08X \00"
@.str.3 = [10 x i8] c"%08X%08X\0A\00"
@str = [70 x i8] c"i # k # pt # ct \00"
define void @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4 x i32]
%4 = alloca i64
%5 = bitcast i64* %4 to [2 x i32]*
%6 = bitcast [4 x i32]* %3 to i8*
%7 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str, i64 0, i64 0))
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
%13 = bitcast i64* %4 to i32*
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
br label %15
15: ; preds = %43, %2
%16 = phi i32 [ 0, %2 ], [ %47, %43 ]
%17 = phi i32 [ 0, %2 ], [ %46, %43 ]
%18 = phi i32 [ 0, %2 ], [ %45, %43 ]
%19 = phi i32 [ 0, %2 ], [ %44, %43 ]
%20 = phi i32 [ 0, %2 ], [ %41, %43 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %19, i32 %18, i32 %17, i32 %16)
%22 = load i32, i32* %13
%23 = load i32, i32* %14
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %23)
%25 = call i32 @encipher(i32 32, i32* %13, i32* %9)
%26 = load i32, i32* %13
%27 = load i32, i32* %14
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %26, i32 %27)
%29 = call i32 @decipher(i32 32, i32* %13, i32* %9)
%30 = and i32 %20, 1
%31 = or i32 %30, 2
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = xor i32 %34, %26
store i32 %35, i32* %33
%36 = xor i32 %30, 1
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = xor i32 %39, %27
store i32 %40, i32* %38
store i32 %26, i32* %13
store i32 %27, i32* %14
%41 = add nuw nsw i32 %20, 1
%42 = icmp eq i32 %41, 100
br i1 %42, label %48, label %43
43: ; preds = %15
%44 = load i32, i32* %9
%45 = load i32, i32* %10
%46 = load i32, i32* %11
%47 = load i32, i32* %12
br label %15
48: ; preds = %15
ret void
}