#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 cipherFunction(int, int const, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int j;
  uint32_t Li = 15, Ri = 19, Li1, Ri1;
  uint32_t fRi, fLi1;
  const uint32_t key = 8;
  printf("Input Li = %d, Ri = %d\n", Li, Ri);
  for (j = 0; j < 6; j++) {
    fRi = cipherFunction(Ri, key, j);
    Li1 = Ri;
    Ri1 = Li ^ fRi;
    printf("loop %d, Li1 = %d, Ri1 = %d\n", j, Li1, Ri1);
    Ri = Ri1;
    Li = Li1;
  }
  printf("End encoding: %d %d\n", Li1, Ri1);
  printf("\n");
  for (j = 6 - 1; j >= 0; j--) {
    fLi1 = cipherFunction(Li1, key, j);
    Li = Ri1 ^ fLi1;
    Ri = Li1;
    printf("loop %d, Li1 = %d, Ri1 = %d\n", j, Li, Ri);
    Ri1 = Ri;
    Li1 = Li;
  }
  printf("End decoding: Li = %d Ri = %d\n", Li1, Ri1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xf,-0xc(%rbp)
movl   $0x13,-0x10(%rbp)
movl   $0x8,-0x24(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    11bc <main+0x9c>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%edx
mov    $0x8,%esi
call   1040 <cipherFunction@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
xor    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115f <main+0x3f>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x5,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1242 <main+0x122>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%edx
mov    $0x8,%esi
call   1040 <cipherFunction@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
xor    -0x20(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    11e5 <main+0xc5>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%rdi
mov    $0xf,%esi
mov    $0x13,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x13,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1050 <cipherFunction@plt>
mov    %eax,%ebx
xor    $0xf,%ebx
lea    0xeaf(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x13,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
mov    $0x8,%esi
mov    $0x1,%edx
call   1050 <cipherFunction@plt>
mov    %eax,%ebp
xor    $0x13,%ebp
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    $0x8,%esi
mov    $0x2,%edx
call   1050 <cipherFunction@plt>
xor    %eax,%ebx
mov    %r14,%rdi
mov    $0x2,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
mov    $0x8,%esi
mov    $0x3,%edx
call   1050 <cipherFunction@plt>
xor    %eax,%ebp
mov    %r14,%rdi
mov    $0x3,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    $0x8,%esi
mov    $0x4,%edx
call   1050 <cipherFunction@plt>
xor    %eax,%ebx
mov    %r14,%rdi
mov    $0x4,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
mov    $0x8,%esi
mov    $0x5,%edx
call   1050 <cipherFunction@plt>
xor    %eax,%ebp
mov    %r14,%rdi
mov    $0x5,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdf1(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
mov    $0x8,%esi
mov    $0x5,%edx
call   1050 <cipherFunction@plt>
xor    %eax,%ebp
mov    %r14,%rdi
mov    $0x5,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    $0x8,%esi
mov    $0x4,%edx
call   1050 <cipherFunction@plt>
xor    %eax,%ebx
mov    %r14,%rdi
mov    $0x4,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
mov    $0x8,%esi
mov    $0x3,%edx
call   1050 <cipherFunction@plt>
xor    %eax,%ebp
mov    %r14,%rdi
mov    $0x3,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    $0x8,%esi
mov    $0x2,%edx
call   1050 <cipherFunction@plt>
xor    %eax,%ebx
mov    %r14,%rdi
mov    $0x2,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
mov    $0x8,%esi
mov    $0x1,%edx
call   1050 <cipherFunction@plt>
xor    %eax,%ebp
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1050 <cipherFunction@plt>
xor    %eax,%ebx
mov    %r14,%rdi
xor    %esi,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd0c(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Input Li = %d, Ri = %d\0A\00"
@.str.1 = [29 x i8] c"loop %d, Li1 = %d, Ri1 = %d\0A\00"
@.str.2 = [21 x i8] c"End encoding: %d %d\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [31 x i8] c"End decoding: Li = %d Ri = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 15, i32* %3
store i32 19, i32* %4
store i32 8, i32* %9
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11)
store i32 0, i32* %2
br label %13
13: ; preds = %30, %0
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 6
br i1 %15, label %16, label %33
16: ; preds = %13
%17 = load i32, i32* %4
%18 = load i32, i32* %2
%19 = call i32 @cipherFunction(i32 %17, i32 8, i32 %18)
store i32 %19, i32* %7
%20 = load i32, i32* %4
store i32 %20, i32* %5
%21 = load i32, i32* %3
%22 = load i32, i32* %7
%23 = xor i32 %21, %22
store i32 %23, i32* %6
%24 = load i32, i32* %2
%25 = load i32, i32* %5
%26 = load i32, i32* %6
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %25, i32 %26)
%28 = load i32, i32* %6
store i32 %28, i32* %4
%29 = load i32, i32* %5
store i32 %29, i32* %3
br label %30
30: ; preds = %16
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %13
33: ; preds = %13
%34 = load i32, i32* %5
%35 = load i32, i32* %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %34, i32 %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 5, i32* %2
br label %38
38: ; preds = %55, %33
%39 = load i32, i32* %2
%40 = icmp sge i32 %39, 0
br i1 %40, label %41, label %58
41: ; preds = %38
%42 = load i32, i32* %5
%43 = load i32, i32* %2
%44 = call i32 @cipherFunction(i32 %42, i32 8, i32 %43)
store i32 %44, i32* %8
%45 = load i32, i32* %6
%46 = load i32, i32* %8
%47 = xor i32 %45, %46
store i32 %47, i32* %3
%48 = load i32, i32* %5
store i32 %48, i32* %4
%49 = load i32, i32* %2
%50 = load i32, i32* %3
%51 = load i32, i32* %4
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %49, i32 %50, i32 %51)
%53 = load i32, i32* %4
store i32 %53, i32* %6
%54 = load i32, i32* %3
store i32 %54, i32* %5
br label %55
55: ; preds = %41
%56 = load i32, i32* %2
%57 = add nsw i32 %56, -1
store i32 %57, i32* %2
br label %38
58: ; preds = %38
%59 = load i32, i32* %5
%60 = load i32, i32* %6
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %59, i32 %60)
%62 = load i32, i32* %1
ret i32 %62
}

LLVM IR (-O2):
@.str = [24 x i8] c"Input Li = %d, Ri = %d\0A\00"
@.str.1 = [29 x i8] c"loop %d, Li1 = %d, Ri1 = %d\0A\00"
@.str.2 = [21 x i8] c"End encoding: %d %d\0A\00"
@.str.4 = [31 x i8] c"End decoding: Li = %d Ri = %d\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 15, i32 19)
%2 = tail call i32 @cipherFunction(i32 19, i32 8, i32 0)
%3 = xor i32 %2, 15
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 19, i32 %3)
%5 = tail call i32 @cipherFunction(i32 %3, i32 8, i32 1)
%6 = xor i32 %5, 19
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %3, i32 %6)
%8 = tail call i32 @cipherFunction(i32 %6, i32 8, i32 2)
%9 = xor i32 %8, %3
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %6, i32 %9)
%11 = tail call i32 @cipherFunction(i32 %9, i32 8, i32 3)
%12 = xor i32 %11, %6
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %9, i32 %12)
%14 = tail call i32 @cipherFunction(i32 %12, i32 8, i32 4)
%15 = xor i32 %14, %9
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 %12, i32 %15)
%17 = tail call i32 @cipherFunction(i32 %15, i32 8, i32 5)
%18 = xor i32 %17, %12
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %15, i32 %18)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %15, i32 %18)
%21 = tail call i32 @putchar(i32 10)
%22 = tail call i32 @cipherFunction(i32 %15, i32 8, i32 5)
%23 = xor i32 %22, %18
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %23, i32 %15)
%25 = tail call i32 @cipherFunction(i32 %23, i32 8, i32 4)
%26 = xor i32 %25, %15
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 %26, i32 %23)
%28 = tail call i32 @cipherFunction(i32 %26, i32 8, i32 3)
%29 = xor i32 %28, %23
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %29, i32 %26)
%31 = tail call i32 @cipherFunction(i32 %29, i32 8, i32 2)
%32 = xor i32 %31, %26
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %32, i32 %29)
%34 = tail call i32 @cipherFunction(i32 %32, i32 8, i32 1)
%35 = xor i32 %34, %29
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %35, i32 %32)
%37 = tail call i32 @cipherFunction(i32 %35, i32 8, i32 0)
%38 = xor i32 %37, %32
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %38, i32 %35)
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %38, i32 %35)
ret i32 0
}