int joinfiles() {
  int i, error, ninp;
  char outp[256], str[256], **linp;
  do {
    printf("  choose the number of files to join (>1): ");
    scanf("%s", &str);
    ninp = atoi(str);
  } while (ninp <= 1);
  linp = (char **)malloc(ninp * sizeof(char *));
  printf("\n  choose %d files to be joint (.dat)\n", ninp);
  for (i = 0; i < ninp; i++) {
    linp[i] = (char *)malloc(256 * sizeof(char));
    printf("    file %d (max %d character): ", i + 1, 256 - 1);
    scanf("%s", linp[i]);
  }
  printf("\n  insert name for created file (.dat) (max %d character): ",
         256 - 1);
  scanf("%s", outp);
  error = joindata(ninp, linp, outp);
  for (i = 0; i < ninp; i++) {
    free(linp[i]);
  }
  free(linp);
  return error;
}


x86 assembly (clang, -O0):
<joinfiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeac(%rip),%rdi
lea    -0x210(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    -0x210(%rbp),%rdi
mov    $0x0,%al
call   1080 <atoi@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jle    116b <joinfiles+0xb>
movslq -0xc(%rbp),%rdi
shl    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x218(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1241 <joinfiles+0xe1>
mov    $0x100,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x218(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x4(%rbp),%esi
add    $0x1,%esi
lea    0xe4c(%rip),%rdi
mov    $0xff,%edx
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x218(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11d5 <joinfiles+0x75>
lea    0xe2f(%rip),%rdi
mov    $0xff,%esi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0xc(%rbp),%edi
mov    -0x218(%rbp),%rsi
lea    -0x110(%rbp),%rdx
mov    $0x0,%al
call   1040 <joindata@plt>
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12b9 <joinfiles+0x159>
mov    -0x218(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    128b <joinfiles+0x12b>
mov    -0x218(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<joinfiles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
lea    0xe88(%rip),%r14
lea    0xead(%rip),%r15
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <atoi@plt>
cmp    $0x2,%eax
jl     1190 <joinfiles+0x30>
mov    %eax,%ebp
mov    %eax,%r14d
lea    0x0(,%r14,8),%rdi
call   1060 <malloc@plt>
mov    %rax,%r13
lea    0xe5d(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe4a(%rip),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x100,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %rax,0x0(%r13,%rbx,8)
add    $0x1,%rbx
lea    0xe49(%rip),%rdi
mov    %ebx,%esi
mov    $0xff,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmp    %rbx,%r14
jne    11f0 <joinfiles+0x90>
lea    0xe43(%rip),%rdi
mov    $0xff,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xde5(%rip),%rdi
lea    0x100(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %r14d,%edi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <joindata@plt>
mov    %eax,%ebx
test   %ebp,%ebp
jle    1293 <joinfiles+0x133>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13,%rbp,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1280 <joinfiles+0x120>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c" choose the number of files to join (>1): \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [39 x i8] c"\0A choose %d files to be joint (.dat)\0A\00"
@.str.3 = [33 x i8] c" file %d (max %d character): \00"
@.str.4 = [60 x i8] c"\0A insert name for created file (.dat) (max %d character): \00"
define i32 @joinfiles() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = alloca i8**
br label %7
7: ; preds = %12, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), [256 x i8]* %5)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %10)
store i32 %11, i32* %3
br label %12
12: ; preds = %7
%13 = load i32, i32* %3
%14 = icmp sle i32 %13, 1
br i1 %14, label %7, label %15
15: ; preds = %12
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 8
%19 = call i8* @malloc(i64 %18)
%20 = bitcast i8* %19 to i8**
store i8** %20, i8*** %6
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %21)
store i32 0, i32* %1
br label %23
23: ; preds = %42, %15
%24 = load i32, i32* %1
%25 = load i32, i32* %3
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %45
27: ; preds = %23
%28 = call i8* @malloc(i64 256)
%29 = load i8**, i8*** %6
%30 = load i32, i32* %1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
store i8* %28, i8** %32
%33 = load i32, i32* %1
%34 = add nsw i32 %33, 1
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %34, i32 255)
%36 = load i8**, i8*** %6
%37 = load i32, i32* %1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %40)
br label %42
42: ; preds = %27
%43 = load i32, i32* %1
%44 = add nsw i32 %43, 1
store i32 %44, i32* %1
br label %23
45: ; preds = %23
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0), i32 255)
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%48 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %47)
%49 = load i32, i32* %3
%50 = load i8**, i8*** %6
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%52 = call i32 (i32, i8**, i8*, ...) bitcast (i32 (...)* @joindata to i32 (i32, i8**, i8*, ...)*)(i32 %49, i8** %50, i8* %51)
store i32 %52, i32* %2
store i32 0, i32* %1
br label %53
53: ; preds = %63, %45
%54 = load i32, i32* %1
%55 = load i32, i32* %3
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %66
57: ; preds = %53
%58 = load i8**, i8*** %6
%59 = load i32, i32* %1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %58, i64 %60
%62 = load i8*, i8** %61
br label %63
63: ; preds = %57
%64 = load i32, i32* %1
%65 = add nsw i32 %64, 1
store i32 %65, i32* %1
br label %53
66: ; preds = %53
%67 = load i8**, i8*** %6
%68 = bitcast i8** %67 to i8*
%69 = load i32, i32* %2
ret i32 %69
}

LLVM IR (-O2):
@.str = [44 x i8] c" choose the number of files to join (>1): \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [39 x i8] c"\0A choose %d files to be joint (.dat)\0A\00"
@.str.3 = [33 x i8] c" file %d (max %d character): \00"
@.str.4 = [60 x i8] c"\0A insert name for created file (.dat) (max %d character): \00"
define i32 @joinfiles() {
%1 = alloca [256 x i8]
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %5, %0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), [256 x i8]* %2)
%8 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %4)
%9 = icmp slt i32 %8, 2
br i1 %9, label %5, label %10
10: ; preds = %5
%11 = zext i32 %8 to i64
%12 = shl nuw nsw i64 %11, 3
%13 = call i8* @malloc(i64 %12)
%14 = bitcast i8* %13 to i8**
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%16 = zext i32 %8 to i64
br label %17
17: ; preds = %10, %17
%18 = phi i64 [ 0, %10 ], [ %21, %17 ]
%19 = call dereferenceable_or_null(256) i8* @malloc(i64 256)
%20 = getelementptr inbounds i8*, i8** %14, i64 %18
store i8* %19, i8** %20
%21 = add nuw nsw i64 %18, 1
%22 = trunc i64 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 255)
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%25 = icmp eq i64 %21, %16
br i1 %25, label %26, label %17
26: ; preds = %17
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0), i32 255)
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%29 = call i32 (i32, i8**, i8*, ...) bitcast (i32 (...)* @joindata to i32 (i32, i8**, i8*, ...)*)(i32 %8, i8** %14, i8* %3)
%30 = icmp sgt i32 %8, 0
br i1 %30, label %31, label %37
31: ; preds = %26, %31
%32 = phi i64 [ %35, %31 ], [ 0, %26 ]
%33 = getelementptr inbounds i8*, i8** %14, i64 %32
%34 = load i8*, i8** %33
%35 = add nuw nsw i64 %32, 1
%36 = icmp eq i64 %35, %11
br i1 %36, label %37, label %31
37: ; preds = %31, %26
ret i32 %29
}