#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*/ piece(char *, char, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char);
char *colapse_repeating_get_key(char *row, int key_column_count,
                                char delimiter) {
  static char key[512];
  char *key_ptr;
  char piece_buffer[128];
  int i;
  key_ptr = key;
  for (i = 0; i < key_column_count; i++) {
    piece(piece_buffer, delimiter, row, i);
    key_ptr += sprintf(key_ptr, "%s%c", piece_buffer, delimiter);
  }
  *key_ptr = '\0';
  return key;
}


x86 assembly (clang, -O0):
<colapse_repeating_get_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
lea    0x2f02(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b6 <colapse_repeating_get_key+0x96>
lea    -0xa0(%rbp),%rdi
mov    -0xd(%rbp),%al
mov    -0x8(%rbp),%rdx
mov    -0xa4(%rbp),%ecx
movsbl %al,%esi
call   1040 <piece@plt>
mov    -0x18(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
lea    0xe77(%rip),%rsi
movsbl -0xd(%rbp),%ecx
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    114c <colapse_repeating_get_key+0x2c>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2e7c(%rip),%rax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<colapse_repeating_get_key>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
test   %esi,%esi
jle    1184 <colapse_repeating_get_key+0x64>
mov    %esi,%r15d
mov    %rdi,%r14
lea    0x2efe(%rip),%rbx
xor    %ebp,%ebp
movsbl %dl,%r12d
mov    %rsp,%r13
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r12d,%esi
mov    %r14,%rdx
mov    %ebp,%ecx
call   1040 <piece@plt>
mov    %rbx,%rdi
lea    0xe96(%rip),%rsi
mov    %r13,%rdx
mov    %r12d,%ecx
call   1030 <sprintf@plt>
cltq
add    %rax,%rbx
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    1150 <colapse_repeating_get_key+0x30>
jmp    118b <colapse_repeating_get_key+0x6b>
lea    0x2eb5(%rip),%rbx
movb   $0x0,(%rbx)
lea    0x2eab(%rip),%rax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@colapse_repeating_get_key.key = internal global [512 x i8] zeroinitializer
@.str = [5 x i8] c"%s%c\00"
define i8* @colapse_repeating_get_key(i8* %0, i32 %1, i8 signext %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8*
%8 = alloca [128 x i8]
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8 %2, i8* %6
store i8* getelementptr inbounds ([512 x i8], [512 x i8]* @colapse_repeating_get_key.key, i64 0, i64 0), i8** %7
store i32 0, i32* %9
br label %10
10: ; preds = %27, %3
%11 = load i32, i32* %9
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %30
14: ; preds = %10
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%16 = load i8, i8* %6
%17 = load i8*, i8** %4
%18 = load i32, i32* %9
%19 = call i32 @piece(i8* %15, i8 signext %16, i8* %17, i32 %18)
%20 = load i8*, i8** %7
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%22 = load i8, i8* %6
%23 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %21, i8 signext %22)
%24 = load i8*, i8** %7
%25 = sext i32 %23 to i64
%26 = getelementptr inbounds i8, i8* %24, i64 %25
store i8* %26, i8** %7
br label %27
27: ; preds = %14
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 1
store i32 %29, i32* %9
br label %10
30: ; preds = %10
%31 = load i8*, i8** %7
store i8 0, i8* %31
ret i8* getelementptr inbounds ([512 x i8], [512 x i8]* @colapse_repeating_get_key.key, i64 0, i64 0)
}

LLVM IR (-O2):
@colapse_repeating_get_key.key = internal global [512 x i8] zeroinitializer
@.str = [5 x i8] c"%s%c\00"
define i8* @colapse_repeating_get_key(i8* %0, i32 %1, i8 signext %2) {
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %16
7: ; preds = %3, %7
%8 = phi i32 [ %14, %7 ], [ 0, %3 ]
%9 = phi i8* [ %13, %7 ], [ getelementptr inbounds ([512 x i8], [512 x i8]* @colapse_repeating_get_key.key, i64 0, i64 0), %3 ]
%10 = call i32 @piece(i8* %5, i8 signext %2, i8* %0, i32 %8)
%11 = call i32 @sprintf(i8* dereferenceable(1) %9, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %5, i8 signext %2)
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %9, i64 %12
%14 = add nuw nsw i32 %8, 1
%15 = icmp eq i32 %14, %1
br i1 %15, label %16, label %7
16: ; preds = %7, %3
%17 = phi i8* [ getelementptr inbounds ([512 x i8], [512 x i8]* @colapse_repeating_get_key.key, i64 0, i64 0), %3 ], [ %13, %7 ]
store i8 0, i8* %17
ret i8* getelementptr inbounds ([512 x i8], [512 x i8]* @colapse_repeating_get_key.key, i64 0, i64 0)
}