#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
void add_strs(char **__restrict__ c, char **a, char **b, int n) {
#pragma omp parallel for
  for (int i = 0; i < n; i++) {
    const char *sa = a[i], *sb = b[i];
    int la = strlen(sa), lb = strlen(sb), lc = la + lb;
    char *sc = (char *)malloc((lc + 1) * sizeof(char));
    strcpy(sc, sa);
    strcpy(sc + la, sb);
    c[i] = sc;
  }
}


x86 assembly (clang, -O0):
<add_strs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11f1 <add_strs+0xc1>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x48(%rbp),%rdi
movslq -0x34(%rbp),%rax
add    %rax,%rdi
mov    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x48(%rbp),%rdx
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114e <add_strs+0x1e>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_strs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %ecx,%ecx
jle    11b9 <add_strs+0x89>
mov    %rsi,%r15
mov    %ecx,%eax
mov    %rax,(%rsp)
xor    %r12d,%r12d
mov    %rdx,0x10(%rsp)
mov    %rdi,0x8(%rsp)
nopl   0x0(%rax,%rax,1)
mov    (%r15,%r12,8),%rbx
mov    (%rdx,%r12,8),%r13
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %r13,%rdi
call   1040 <strlen@plt>
lea    (%rax,%rbp,1),%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
movslq %ebp,%rdi
add    %r14,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    0x8(%rsp),%rdi
mov    0x10(%rsp),%rdx
mov    %r14,(%rdi,%r12,8)
add    $0x1,%r12
cmp    %r12,(%rsp)
jne    1160 <add_strs+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @add_strs(i8** noalias %0, i8** %1, i8** %2, i32 %3) {
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
store i8** %0, i8*** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %16
16: ; preds = %59, %4
%17 = load i32, i32* %9
%18 = load i32, i32* %8
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %62
20: ; preds = %16
%21 = load i8**, i8*** %6
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
store i8* %25, i8** %10
%26 = load i8**, i8*** %7
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
store i8* %30, i8** %11
%31 = load i8*, i8** %10
%32 = call i32 @strlen(i8* %31)
store i32 %32, i32* %12
%33 = load i8*, i8** %11
%34 = call i32 @strlen(i8* %33)
store i32 %34, i32* %13
%35 = load i32, i32* %12
%36 = load i32, i32* %13
%37 = add nsw i32 %35, %36
store i32 %37, i32* %14
%38 = load i32, i32* %14
%39 = add nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = mul i64 %40, 1
%42 = trunc i64 %41 to i32
%43 = call i64 @malloc(i32 %42)
%44 = inttoptr i64 %43 to i8*
store i8* %44, i8** %15
%45 = load i8*, i8** %15
%46 = load i8*, i8** %10
%47 = call i32 @strcpy(i8* %45, i8* %46)
%48 = load i8*, i8** %15
%49 = load i32, i32* %12
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8*, i8** %11
%53 = call i32 @strcpy(i8* %51, i8* %52)
%54 = load i8*, i8** %15
%55 = load i8**, i8*** %5
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
store i8* %54, i8** %58
br label %59
59: ; preds = %20
%60 = load i32, i32* %9
%61 = add nsw i32 %60, 1
store i32 %61, i32* %9
br label %16
62: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @add_strs(i8** noalias nocapture writeonly %0, i8** nocapture %1, i8** nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = zext i32 %3 to i64
br label %9
8: ; preds = %9, %4
ret void
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %26, %9 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8*, i8** %2, i64 %10
%14 = load i8*, i8** %13
%15 = tail call i32 @strlen(i8* %12)
%16 = tail call i32 @strlen(i8* %14)
%17 = add i32 %15, 1
%18 = add i32 %17, %16
%19 = tail call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i8*
%21 = tail call i32 @strcpy(i8* %20, i8* %12)
%22 = sext i32 %15 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = tail call i32 @strcpy(i8* %23, i8* %14)
%25 = getelementptr inbounds i8*, i8** %0, i64 %10
store i8* %20, i8** %25
%26 = add nuw nsw i64 %10, 1
%27 = icmp eq i64 %26, %7
br i1 %27, label %8, label %9
}