#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*/ bzero(char *, int);
int endofline(char **, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int combine(char **out, int start, char **_res) {
  int end = endofline(out, start);
  char *res = (*_res);
  if (start == end) {
    return (0);
  }
  res = (char *)malloc(256);
  bzero(res, 256);
  sprintf((char *)res, "%s", out[start]);
  start++;
  while (start != end) {
    sprintf((char *)res, "%s %s", res, out[start]);
    start++;
  }
  (*_res) = res;
  return (1);
}


x86 assembly (clang, -O0):
<combine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <endofline@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    1185 <combine+0x45>
movl   $0x0,-0x4(%rbp)
jmp    1216 <combine+0xd6>
mov    $0x100,%edi
call   1030 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x100,%esi
call   1050 <bzero@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     1204 <combine+0xc4>
mov    -0x30(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xe11(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c8 <combine+0x88>
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<combine>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%r15d
mov    %rdi,%r12
call   1050 <endofline@plt>
mov    %eax,%r13d
xor    %eax,%eax
cmp    %r15d,%r13d
je     11e9 <combine+0x99>
mov    %rbx,(%rsp)
mov    $0x100,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x100,%esi
call   1060 <bzero@plt>
movslq %r15d,%rax
mov    (%r12,%rax,8),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0x1(%r15),%eax
cmp    %r13d,%eax
je     11dd <combine+0x8d>
cltq
lea    (%r12,%rax,8),%r14
not    %r15d
add    %r13d,%r15d
lea    0xe44(%rip),%r12
xor    %ebp,%ebp
xchg   %ax,%ax
mov    (%r14,%rbp,8),%rcx
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
add    $0x1,%rbp
cmp    %ebp,%r15d
jne    11c0 <combine+0x70>
mov    (%rsp),%rax
mov    %rbx,(%rax)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [6 x i8] c"%s %s\00"
define i32 @combine(i8** %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i8*
store i8** %0, i8*** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%10 = load i8**, i8*** %5
%11 = load i32, i32* %6
%12 = call i32 @endofline(i8** %10, i32 %11)
store i32 %12, i32* %8
%13 = load i8**, i8*** %7
%14 = load i8*, i8** %13
store i8* %14, i8** %9
%15 = load i32, i32* %6
%16 = load i32, i32* %8
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %3
store i32 0, i32* %4
br label %51
19: ; preds = %3
%20 = call i64 @malloc(i32 256)
%21 = inttoptr i64 %20 to i8*
store i8* %21, i8** %9
%22 = load i8*, i8** %9
%23 = call i32 @bzero(i8* %22, i32 256)
%24 = load i8*, i8** %9
%25 = load i8**, i8*** %5
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %33
33: ; preds = %37, %19
%34 = load i32, i32* %6
%35 = load i32, i32* %8
%36 = icmp ne i32 %34, %35
br i1 %36, label %37, label %48
37: ; preds = %33
%38 = load i8*, i8** %9
%39 = load i8*, i8** %9
%40 = load i8**, i8*** %5
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %39, i8* %44)
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
br label %33
48: ; preds = %33
%49 = load i8*, i8** %9
%50 = load i8**, i8*** %7
store i8* %49, i8** %50
store i32 1, i32* %4
br label %51
51: ; preds = %48, %18
%52 = load i32, i32* %4
ret i32 %52
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%s %s\00"
define i32 @combine(i8** %0, i32 %1, i8** nocapture writeonly %2) {
%4 = tail call i32 @endofline(i8** %0, i32 %1)
%5 = icmp eq i32 %4, %1
br i1 %5, label %27, label %6
6: ; preds = %3
%7 = tail call i64 @malloc(i32 256)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @bzero(i8* %8, i32 256)
%10 = sext i32 %1 to i64
%11 = getelementptr inbounds i8*, i8** %0, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i8* @strcpy(i8* dereferenceable(1) %8, i8* dereferenceable(1) %12)
%14 = add i32 %1, 1
%15 = icmp eq i32 %14, %4
br i1 %15, label %26, label %16
16: ; preds = %6
%17 = sext i32 %14 to i64
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ %17, %16 ], [ %23, %18 ]
%20 = getelementptr inbounds i8*, i8** %0, i64 %19
%21 = load i8*, i8** %20
%22 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* %21)
%23 = add nsw i64 %19, 1
%24 = trunc i64 %23 to i32
%25 = icmp eq i32 %4, %24
br i1 %25, label %26, label %18
26: ; preds = %18, %6
store i8* %8, i8** %2
br label %27
27: ; preds = %3, %26
%28 = phi i32 [ 1, %26 ], [ 0, %3 ]
ret i32 %28
}