#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*/ strcat(char *, char *);
void AppendItem(char *s, char *item, int len, int width) {
  char buf[64];
  int i;
  for (i = 0; i < len; i++)
    buf[i] = item[i];
  for (i = len; i < width; i++)
    buf[i] = ' ';
  buf[width] = '\0';
  strcat(s, buf);
}


x86 assembly (clang, -O0):
<AppendItem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    115a <AppendItem+0x4a>
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x64(%rbp),%rax
mov    %cl,-0x60(%rbp,%rax,1)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    112d <AppendItem+0x1d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1183 <AppendItem+0x73>
movslq -0x64(%rbp),%rax
movb   $0x20,-0x60(%rbp,%rax,1)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1160 <AppendItem+0x50>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1030 <strcat@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AppendItem>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %ecx,%ebp
mov    %edx,%ebx
mov    %rdi,%r14
test   %edx,%edx
jle    114d <AppendItem+0x1d>
mov    %ebx,%edx
mov    %rsp,%rdi
call   1040 <memcpy@plt>
cmp    %ebp,%ebx
jge    116d <AppendItem+0x3d>
movslq %ebx,%rax
lea    (%rsp,%rax,1),%rdi
not    %ebx
add    %ebp,%ebx
add    $0x1,%rbx
mov    $0x20,%esi
mov    %rbx,%rdx
call   1030 <memset@plt>
movslq %ebp,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rsi
mov    %r14,%rdi
call   1050 <strcat@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define void @AppendItem(i8* %0, i8* nocapture %1, i32 %2, i32 %3) {
%5 = alloca [64 x i8]
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%10 = zext i32 %2 to i64
br label %11
11: ; preds = %8, %4
%12 = icmp slt i32 %2, %3
br i1 %12, label %13, label %20
13: ; preds = %11
%14 = sext i32 %2 to i64
%15 = getelementptr [64 x i8], [64 x i8]* %5, i64 0, i64 %14
%16 = xor i32 %2, -1
%17 = add i32 %16, %3
%18 = zext i32 %17 to i64
%19 = add nuw nsw i64 %18, 1
br label %20
20: ; preds = %13, %11
%21 = sext i32 %3 to i64
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 %21
store i8 0, i8* %22
%23 = call i32 @strcat(i8* %0, i8* %6)
ret void
}