#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*/ AddChar(char **, char const);
const char *modifyPattern(const char *pattern) {
  char *newPattern = 0;
  while (*pattern != '\0') {
    if (*pattern == 'E') {
      AddChar(&newPattern, 'd');
    } else if (*pattern == 'a') {
      AddChar(&newPattern, 't');
      AddChar(&newPattern, 't');
    } else {
      AddChar(&newPattern, *pattern);
    }
    ++pattern;
  }
  AddChar(&newPattern, '\0');
  return newPattern;
}


x86 assembly (clang, -O0):
<modifyPattern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ae <modifyPattern+0x9e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x45,%eax
jne    1157 <modifyPattern+0x47>
lea    -0x10(%rbp),%rdi
mov    $0x64,%esi
call   1030 <AddChar@plt>
jmp    119d <modifyPattern+0x8d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
jne    1188 <modifyPattern+0x78>
lea    -0x10(%rbp),%rdi
mov    $0x74,%esi
call   1030 <AddChar@plt>
lea    -0x10(%rbp),%rdi
mov    $0x74,%esi
call   1030 <AddChar@plt>
jmp    1198 <modifyPattern+0x88>
mov    -0x8(%rbp),%rax
lea    -0x10(%rbp),%rdi
movsbl (%rax),%esi
call   1030 <AddChar@plt>
jmp    119d <modifyPattern+0x8d>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1124 <modifyPattern+0x14>
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1030 <AddChar@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<modifyPattern>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movq   $0x0,(%rsp)
mov    %rsp,%r14
jmp    114e <modifyPattern+0x3e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    $0x74,%esi
call   1030 <AddChar@plt>
mov    $0x74,%al
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <AddChar@plt>
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x45,%al
je     1160 <modifyPattern+0x50>
cmp    $0x61,%al
je     1130 <modifyPattern+0x20>
test   %al,%al
jne    113f <modifyPattern+0x2f>
jmp    1164 <modifyPattern+0x54>
nop
mov    $0x64,%al
jmp    113f <modifyPattern+0x2f>
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <AddChar@plt>
mov    (%rsp),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @modifyPattern(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
store i8* null, i8** %3
br label %4
4: ; preds = %29, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %32
9: ; preds = %4
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 69
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = call i32 @AddChar(i8** %3, i8 signext 100)
br label %29
16: ; preds = %9
%17 = load i8*, i8** %2
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 97
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = call i32 @AddChar(i8** %3, i8 signext 116)
%23 = call i32 @AddChar(i8** %3, i8 signext 116)
br label %28
24: ; preds = %16
%25 = load i8*, i8** %2
%26 = load i8, i8* %25
%27 = call i32 @AddChar(i8** %3, i8 signext %26)
br label %28
28: ; preds = %24, %21
br label %29
29: ; preds = %28, %14
%30 = load i8*, i8** %2
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %2
br label %4
32: ; preds = %4
%33 = call i32 @AddChar(i8** %3, i8 signext 0)
%34 = load i8*, i8** %3
ret i8* %34
}

LLVM IR (-O2):
define i8* @modifyPattern(i8* nocapture %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i8* null, i8** %2
br label %4
4: ; preds = %10, %1
%5 = phi i8* [ %0, %1 ], [ %13, %10 ]
%6 = load i8, i8* %5
switch i8 %6, label %9 [
i8 0, label %14
i8 69, label %10
i8 97, label %7
]
7: ; preds = %4
%8 = call i32 @AddChar(i8** %2, i8 signext 116)
br label %10
9: ; preds = %4
br label %10
10: ; preds = %4, %7, %9
%11 = phi i8 [ 116, %7 ], [ %6, %9 ], [ 100, %4 ]
%12 = call i32 @AddChar(i8** %2, i8 signext %11)
%13 = getelementptr inbounds i8, i8* %5, i64 1
br label %4
14: ; preds = %4
%15 = call i32 @AddChar(i8** %2, i8 signext 0)
%16 = load i8*, i8** %2
ret i8* %16
}