#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*/ lr_save_string(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int PadToX(char *cCharToPad, char *cParamName, int iValLength,
           char *cValueToAdd) {
  char cTemp[1024] = "";
  int iLoop = 0;
  int iMainLoop = 0;
  int iSubLoop = 0;
  for (iMainLoop = 0; iMainLoop < iValLength; iMainLoop++) {
    if (iMainLoop == strlen(cCharToPad)) {
      iLoop = iValLength - iMainLoop;
      for (iSubLoop = 0; iSubLoop < iLoop; iSubLoop++) {
        strcat(cTemp, cValueToAdd);
      }
    }
  }
  strcat(cTemp, cCharToPad);
  lr_save_string(cTemp, cParamName);
}


x86 assembly (clang, -O0):
<PadToX>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
movl   $0x0,-0x434(%rbp)
movl   $0x0,-0x438(%rbp)
movl   $0x0,-0x43c(%rbp)
movl   $0x0,-0x438(%rbp)
mov    -0x438(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1236 <PadToX+0xf6>
mov    -0x438(%rbp),%eax
mov    %eax,-0x440(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x440(%rbp),%eax
cmp    %ecx,%eax
jne    121d <PadToX+0xdd>
mov    -0x1c(%rbp),%eax
sub    -0x438(%rbp),%eax
mov    %eax,-0x434(%rbp)
movl   $0x0,-0x43c(%rbp)
mov    -0x43c(%rbp),%eax
cmp    -0x434(%rbp),%eax
jge    1218 <PadToX+0xd8>
lea    -0x430(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x43c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x43c(%rbp)
jmp    11e2 <PadToX+0xa2>
jmp    121d <PadToX+0xdd>
jmp    1222 <PadToX+0xe2>
mov    -0x438(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x438(%rbp)
jmp    1195 <PadToX+0x55>
lea    -0x430(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x430(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <lr_save_string@plt>
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PadToX>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rcx,%rbx
mov    %edx,%r15d
mov    %rsi,0x8(%rsp)
mov    %rdi,(%rsp)
lea    0x10(%rsp),%rdi
xor    %r13d,%r13d
mov    $0x400,%edx
xor    %esi,%esi
call   1040 <memset@plt>
test   %r15d,%r15d
jle    11d3 <PadToX+0x93>
lea    0x10(%rsp),%rbp
mov    %r15d,%r14d
jmp    119d <PadToX+0x5d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r13d
add    $0xffffffff,%r14d
cmp    %r15d,%r13d
je     11d3 <PadToX+0x93>
mov    (%rsp),%rdi
call   1030 <strlen@plt>
cmp    %eax,%r13d
jne    1190 <PadToX+0x50>
cmp    %r15d,%r13d
jge    1190 <PadToX+0x50>
mov    %r14d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
add    $0xffffffff,%r12d
jne    11c0 <PadToX+0x80>
jmp    1190 <PadToX+0x50>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    (%rsp),%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    0x8(%rsp),%rsi
call   1050 <lr_save_string@plt>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @PadToX(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca [1024 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
%14 = bitcast [1024 x i8]* %10 to i8*
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %12
br label %15
15: ; preds = %41, %4
%16 = load i32, i32* %12
%17 = load i32, i32* %8
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %44
19: ; preds = %15
%20 = load i32, i32* %12
%21 = load i8*, i8** %6
%22 = call i32 @strlen(i8* %21)
%23 = icmp eq i32 %20, %22
br i1 %23, label %24, label %40
24: ; preds = %19
%25 = load i32, i32* %8
%26 = load i32, i32* %12
%27 = sub nsw i32 %25, %26
store i32 %27, i32* %11
store i32 0, i32* %13
br label %28
28: ; preds = %36, %24
%29 = load i32, i32* %13
%30 = load i32, i32* %11
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %39
32: ; preds = %28
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%34 = load i8*, i8** %9
%35 = call i32 @strcat(i8* %33, i8* %34)
br label %36
36: ; preds = %32
%37 = load i32, i32* %13
%38 = add nsw i32 %37, 1
store i32 %38, i32* %13
br label %28
39: ; preds = %28
br label %40
40: ; preds = %39, %19
br label %41
41: ; preds = %40
%42 = load i32, i32* %12
%43 = add nsw i32 %42, 1
store i32 %43, i32* %12
br label %15
44: ; preds = %15
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%46 = load i8*, i8** %6
%47 = call i32 @strcat(i8* %45, i8* %46)
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%49 = load i8*, i8** %7
%50 = call i32 @lr_save_string(i8* %48, i8* %49)
%51 = load i32, i32* %5
ret i32 %51
}

LLVM IR (-O2):
define i32 @PadToX(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %24
8: ; preds = %4, %20
%9 = phi i32 [ %22, %20 ], [ %2, %4 ]
%10 = phi i32 [ %21, %20 ], [ 0, %4 ]
%11 = call i32 @strlen(i8* %0)
%12 = icmp eq i32 %10, %11
%13 = icmp slt i32 %10, %2
%14 = and i1 %12, %13
br i1 %14, label %15, label %20
15: ; preds = %8, %15
%16 = phi i32 [ %18, %15 ], [ 0, %8 ]
%17 = call i32 @strcat(i8* %6, i8* %3)
%18 = add nuw nsw i32 %16, 1
%19 = icmp eq i32 %18, %9
br i1 %19, label %20, label %15
20: ; preds = %15, %8
%21 = add nuw nsw i32 %10, 1
%22 = add i32 %9, -1
%23 = icmp eq i32 %21, %2
br i1 %23, label %24, label %8
24: ; preds = %20, %4
%25 = call i32 @strcat(i8* %6, i8* %0)
%26 = call i32 @lr_save_string(i8* %6, i8* %1)
ret i32 undef
}