#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main() {
  int i;
  char *buffer;
  buffer = (char *)malloc(20);
  strcpy(buffer, "ET phone home!");
  for (i = 0; i < strlen(buffer); i++)
    buffer[i] += 4;
  printf("The code is      %s\n", buffer);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x14,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    11b0 <main+0x70>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
add    $0x4,%edx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1174 <main+0x34>
mov    -0x10(%rbp),%rsi
lea    0xe54(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x14,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
lea    0xea8(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1188 <main+0x48>
xor    %ebx,%ebx
xchg   %ax,%ax
addb   $0x4,(%r14,%rbx,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1170 <main+0x30>
lea    0xe80(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [15 x i8] c"ET phone home!\00"
@.str.1 = [21 x i8] c"The code is %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i64 @malloc(i32 20)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %8
8: ; preds = %22, %0
%9 = load i32, i32* %2
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %25
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = add nsw i32 %19, 4
%21 = trunc i32 %20 to i8
store i8 %21, i8* %17
br label %22
22: ; preds = %13
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %8
25: ; preds = %8
%26 = load i8*, i8** %3
%27 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str = [15 x i8] c"ET phone home!\00"
@.str.1 = [21 x i8] c"The code is %s\0A\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 20)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @strlen(i8* %2)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %0, %6
%7 = phi i64 [ %11, %6 ], [ 0, %0 ]
%8 = getelementptr inbounds i8, i8* %2, i64 %7
%9 = load i8, i8* %8
%10 = add i8 %9, 4
store i8 %10, i8* %8
%11 = add nuw nsw i64 %7, 1
%12 = tail call i32 @strlen(i8* %2)
%13 = sext i32 %12 to i64
%14 = icmp slt i64 %11, %13
br i1 %14, label %6, label %15
15: ; preds = %6, %0
%16 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i32 0
}