#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 /*<<< orphan*/ uint8_t;
typedef int uint32_t;
typedef int /*<<< orphan*/ uint16_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ encrypt(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
int /*<<< orphan*/ write(int, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  uint8_t *buf;
  uint32_t buflen, i;
  FILE *f;
  if (argc != 2) {
    printf("Usage: %s text_to_encrypt", argv[0]);
    exit(1);
  }
  buflen = strlen(argv[1]);
  buf = (uint8_t *)malloc(buflen);
  memcpy(buf, argv[1], buflen);
  for (i = 0; i < buflen && i + 2 * (sizeof(uint16_t)) <= buflen;
       i += sizeof(uint32_t)) {
    encrypt((uint16_t *)&buf[i]);
  }
  write(1, buf, buflen);
  return 0;
}


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     11ad <main+0x3d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe62(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x1c(%rbp),%edx
call   1070 <memcpy@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%ecx
xor    %eax,%eax
cmp    -0x1c(%rbp),%ecx
mov    %al,-0x29(%rbp)
jge    120a <main+0x9a>
movslq -0x20(%rbp),%rax
add    $0x8,%rax
movslq -0x1c(%rbp),%rcx
cmp    %rcx,%rax
setbe  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    121a <main+0xaa>
jmp    123e <main+0xce>
mov    -0x18(%rbp),%rdi
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1060 <encrypt@plt>
movslq -0x20(%rbp),%rax
add    $0x4,%rax
mov    %eax,-0x20(%rbp)
jmp    11e4 <main+0x74>
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
cmp    $0x2,%edi
jne    11e8 <main+0x78>
mov    0x8(%r15),%rdi
call   1040 <strlen@plt>
mov    %eax,%r12d
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    0x8(%r15),%rsi
mov    %rax,%rdi
mov    %r12d,%edx
call   1070 <memcpy@plt>
cmp    $0x8,%r12d
jl     11cd <main+0x5d>
movslq %r12d,%rbx
xor    %ebp,%ebp
lea    (%r14,%rbp,4),%rdi
call   1060 <encrypt@plt>
lea    0x4(%rbp),%eax
cmp    %r12d,%eax
jge    11cd <main+0x5d>
movslq %eax,%rbp
lea    0x8(%rbp),%rax
cmp    %rbx,%rax
jbe    11b0 <main+0x40>
mov    $0x1,%edi
mov    %r14,%rsi
mov    %r12d,%edx
call   1030 <write@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r15),%rsi
lea    0xe0e(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Usage: %s text_to_encrypt\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strlen(i8* %21)
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i32*
store i32* %25, i32** %6
%26 = load i32*, i32** %6
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = load i32, i32* %7
%31 = call i32 @memcpy(i32* %26, i8* %29, i32 %30)
store i32 0, i32* %8
br label %32
32: ; preds = %51, %18
%33 = load i32, i32* %8
%34 = load i32, i32* %7
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load i32, i32* %8
%38 = sext i32 %37 to i64
%39 = add i64 %38, 8
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = icmp ule i64 %39, %41
br label %43
43: ; preds = %36, %32
%44 = phi i1 [ false, %32 ], [ %42, %36 ]
br i1 %44, label %45, label %56
45: ; preds = %43
%46 = load i32*, i32** %6
%47 = load i32, i32* %8
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = call i32 @encrypt(i32* %49)
br label %51
51: ; preds = %45
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = add i64 %53, 4
%55 = trunc i64 %54 to i32
store i32 %55, i32* %8
br label %32
56: ; preds = %43
%57 = load i32*, i32** %6
%58 = load i32, i32* %7
%59 = call i32 @write(i32 1, i32* %57, i32 %58)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Usage: %s text_to_encrypt\00"
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 i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strlen(i8* %10)
%12 = tail call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32*
%14 = load i8*, i8** %9
%15 = tail call i32 @memcpy(i32* %13, i8* %14, i32 %11)
%16 = sext i32 %11 to i64
%17 = icmp sgt i32 %11, 7
br i1 %17, label %18, label %29
18: ; preds = %8, %18
%19 = phi i64 [ %25, %18 ], [ 0, %8 ]
%20 = trunc i64 %19 to i32
%21 = getelementptr inbounds i32, i32* %13, i64 %19
%22 = tail call i32 @encrypt(i32* %21)
%23 = add i32 %20, 4
%24 = icmp slt i32 %23, %11
%25 = sext i32 %23 to i64
%26 = add nsw i64 %25, 8
%27 = icmp ule i64 %26, %16
%28 = select i1 %24, i1 %27, i1 false
br i1 %28, label %18, label %29
29: ; preds = %18, %8
%30 = tail call i32 @write(i32 1, i32* %13, i32 %11)
ret i32 0
}