#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 strlen(char *);
char *encrypt(char *string) {
  int i;
  for (i = 0; i < strlen(string); i += 2)
    string[i]++;
  for (i = 1; i < strlen(string); i += 2)
    string[i]--;
  return string;
}


x86 assembly (clang, -O0):
<encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jge    115e <encrypt+0x4e>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
add    $0x1,%dl
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <encrypt+0x13>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    11a0 <encrypt+0x90>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
add    $0xff,%dl
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    1165 <encrypt+0x55>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encrypt>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %eax,%eax
jle    1145 <encrypt+0x35>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
addb   $0x1,(%r14,%rbx,1)
add    $0x2,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %ebx,%eax
jg     1130 <encrypt+0x20>
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     1175 <encrypt+0x65>
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
addb   $0xff,(%r14,%rbx,1)
add    $0x2,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %ebx,%eax
jg     1160 <encrypt+0x50>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @encrypt(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %16, %1
%5 = load i32, i32* %3
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = icmp slt i32 %5, %7
br i1 %8, label %9, label %19
9: ; preds = %4
%10 = load i8*, i8** %2
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = add i8 %14, 1
store i8 %15, i8* %13
br label %16
16: ; preds = %9
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 2
store i32 %18, i32* %3
br label %4
19: ; preds = %4
store i32 1, i32* %3
br label %20
20: ; preds = %32, %19
%21 = load i32, i32* %3
%22 = load i8*, i8** %2
%23 = call i32 @strlen(i8* %22)
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %35
25: ; preds = %20
%26 = load i8*, i8** %2
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = add i8 %30, -1
store i8 %31, i8* %29
br label %32
32: ; preds = %25
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 2
store i32 %34, i32* %3
br label %20
35: ; preds = %20
%36 = load i8*, i8** %2
ret i8* %36
}

LLVM IR (-O2):
define i8* @encrypt(i8* returned %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %7, %1
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 1
br i1 %6, label %16, label %25
7: ; preds = %1, %7
%8 = phi i64 [ %12, %7 ], [ 0, %1 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = add i8 %10, 1
store i8 %11, i8* %9
%12 = add nuw i64 %8, 2
%13 = tail call i32 @strlen(i8* %0)
%14 = trunc i64 %12 to i32
%15 = icmp sgt i32 %13, %14
br i1 %15, label %7, label %4
16: ; preds = %4, %16
%17 = phi i64 [ %21, %16 ], [ 1, %4 ]
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = add i8 %19, -1
store i8 %20, i8* %18
%21 = add nuw i64 %17, 2
%22 = tail call i32 @strlen(i8* %0)
%23 = trunc i64 %21 to i32
%24 = icmp sgt i32 %22, %23
br i1 %24, label %16, label %25
25: ; preds = %16, %4
ret i8* %0
}