#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*/ assert(int);
int /*<<< orphan*/ ipcrypt_decrypt(unsigned char *, unsigned char *,
                                   unsigned char *);
int /*<<< orphan*/ ipcrypt_encrypt(unsigned char *, unsigned char *,
                                   unsigned char *);
scalar_t__ memcmp(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int main(void) {
  unsigned char ip[4] = {192, 168, 69, 42};
  unsigned char k[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
  unsigned char out2[4];
  unsigned char out[4];
  unsigned char expected[4] = {93, 155, 197, 186};
  unsigned long i;
  for (i = 0; i < 100000000UL; i++) {
    ipcrypt_encrypt(out, ip, k);
    ipcrypt_decrypt(out2, out, k);
    assert(memcmp(out2, ip, 4) == 0);
    memcpy(ip, out, 4);
  }
  assert(memcmp(out, expected, 4) == 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9b(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xea1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe9e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe80(%rip),%eax
mov    %eax,-0x2c(%rbp)
movq   $0x0,-0x38(%rbp)
cmpq   $0x5f5e100,-0x38(%rbp)
05
jae    1205 <main+0xb5>
lea    -0x28(%rbp),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <ipcrypt_encrypt@plt>
lea    -0x24(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <ipcrypt_decrypt@plt>
lea    -0x24(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x4,%edx
call   1070 <memcpy@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    118f <main+0x3f>
lea    -0x28(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
movl   $0x2a45a8c0,0x4(%rsp)
2a
movaps 0xe94(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0xbac59b5d,(%rsp)
mov    $0x5f5e100,%ebx
lea    0x8(%rsp),%r14
lea    0x4(%rsp),%r13
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <ipcrypt_encrypt@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <ipcrypt_decrypt@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1070 <memcpy@plt>
add    $0xffffffffffffffff,%rbx
jne    11a0 <main+0x50>
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.ip = [4 x i8] c"\C0\A8E*"
@__const.main.k = [16 x i8] c"\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\10"
@__const.main.expected = [4 x i8] c"]\9B\C5\BA"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i8]
%3 = alloca [16 x i8]
%4 = alloca [4 x i8]
%5 = alloca [4 x i8]
%6 = alloca [4 x i8]
%7 = alloca i64
store i32 0, i32* %1
%8 = bitcast [4 x i8]* %2 to i8*
%9 = bitcast [16 x i8]* %3 to i8*
%10 = bitcast [4 x i8]* %6 to i8*
store i64 0, i64* %7
br label %11
11: ; preds = %32, %0
%12 = load i64, i64* %7
%13 = icmp ult i64 %12, 100000000
br i1 %13, label %14, label %35
14: ; preds = %11
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%18 = call i32 @ipcrypt_encrypt(i8* %15, i8* %16, i8* %17)
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%22 = call i32 @ipcrypt_decrypt(i8* %19, i8* %20, i8* %21)
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%25 = call i64 @memcmp(i8* %23, i8* %24, i32 4)
%26 = icmp eq i64 %25, 0
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%31 = call i32 @memcpy(i8* %29, i8* %30, i32 4)
br label %32
32: ; preds = %14
%33 = load i64, i64* %7
%34 = add i64 %33, 1
store i64 %34, i64* %7
br label %11
35: ; preds = %11
%36 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%37 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%38 = call i64 @memcmp(i8* %36, i8* %37, i32 4)
%39 = icmp eq i64 %38, 0
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
ret i32 0
}

LLVM IR (-O2):
@__const.main.k = [16 x i8] c"\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\10"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i8]
%3 = alloca [4 x i8]
%4 = alloca [4 x i8]
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
store i32 709208256, i32* %1
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%10 = bitcast i32* %5 to i8*
store i32 -1161454755, i32* %5
br label %11
11: ; preds = %0, %11
%12 = phi i64 [ 0, %0 ], [ %20, %11 ]
%13 = call i32 @ipcrypt_encrypt(i8* %9, i8* %6, i8* %7)
%14 = call i32 @ipcrypt_decrypt(i8* %8, i8* %9, i8* %7)
%15 = call i64 @memcmp(i8* %8, i8* %6, i32 4)
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = call i32 @memcpy(i8* %6, i8* %9, i32 4)
%20 = add nuw nsw i64 %12, 1
%21 = icmp eq i64 %20, 100000000
br i1 %21, label %22, label %11
22: ; preds = %11
%23 = call i64 @memcmp(i8* %9, i8* %10, i32 4)
%24 = icmp eq i64 %23, 0
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
ret i32 0
}