#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*/ strncat(char *, ...);
char *encodeDict(char *input, int size) {
  char ans[10000] = "d";
  int i;
  for (i = 0; i < size; i++) {
    strncat(ans, input[i], 10000);
  }
  strncat(ans, "e", 10000);
  return ans;
}


x86 assembly (clang, -O0):
<encodeDict>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2730,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x2720(%rbp),%rdi
xor    %esi,%esi
mov    $0x2710,%edx
call   1030 <memset@plt>
movb   $0x64,-0x2720(%rbp)
movl   $0x0,-0x2724(%rbp)
mov    -0x2724(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119b <encodeDict+0x7b>
lea    -0x2720(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x2724(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
mov    $0x2710,%edx
mov    $0x0,%al
call   1040 <strncat@plt>
mov    -0x2724(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2724(%rbp)
jmp    1156 <encodeDict+0x36>
lea    -0x2720(%rbp),%rdi
lea    0xe57(%rip),%rsi
mov    $0x2710,%edx
mov    $0x0,%al
call   1040 <strncat@plt>
lea    -0x2720(%rbp),%rax
add    $0x2730,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encodeDict>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x2718,%rsp
mov    %esi,%ebp
mov    %rdi,%r15
mov    %rsp,%rdi
mov    $0x2710,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movb   $0x64,(%rsp)
test   %ebp,%ebp
jle    116d <encodeDict+0x4d>
mov    %ebp,%ebp
mov    %rsp,%r14
xor    %ebx,%ebx
movsbl (%r15,%rbx,1),%esi
mov    %r14,%rdi
mov    $0x2710,%edx
xor    %eax,%eax
call   1040 <strncat@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <encodeDict+0x30>
lea    0xe8c(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x2710,%edx
xor    %eax,%eax
call   1040 <strncat@plt>
mov    %rbx,%rax
add    $0x2718,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"e\00"
define i8* @encodeDict(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [10000 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = bitcast [10000 x i8]* %5 to i8*
%8 = bitcast i8* %7 to [10000 x i8]*
%9 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i32 0, i32 0
store i8 100, i8* %9
store i32 0, i32* %6
br label %10
10: ; preds = %23, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %26
14: ; preds = %10
%15 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%16 = load i8*, i8** %3
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = call i32 (i8*, ...) @strncat(i8* %15, i32 %21, i32 10000)
br label %23
23: ; preds = %14
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %10
26: ; preds = %10
%27 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%28 = call i32 (i8*, ...) @strncat(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 10000)
%29 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
ret i8* %29
}

LLVM IR (-O2):
@.str = [2 x i8] c"e\00"
define i8* @encodeDict(i8* nocapture %0, i32 %1) {
%3 = alloca [10000 x i8]
%4 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
store i8 100, i8* %4
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %16
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %14, %8 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = call i32 (i8*, ...) @strncat(i8* %4, i32 %12, i32 10000)
%14 = add nuw nsw i64 %9, 1
%15 = icmp eq i64 %14, %7
br i1 %15, label %16, label %8
16: ; preds = %8, %2
%17 = call i32 (i8*, ...) @strncat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 10000)
ret i8* %4
}