#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*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void strings_matrix() {
  char *str_0 = "_abc_";
  char *str_1 = "_xyz_";
  char **matrix = (char **)malloc(2 * sizeof(char *));
  for (int i = 0; i < 2; i++) {
    matrix[i] = (char *)malloc(sizeof(char) * strlen(str_0));
  }
  strcpy(matrix[0], str_0);
  strcpy(matrix[1], str_1);
  for (int i = 0; i < 2; i++) {
    char *tmp_str = matrix[i];
    for (int j = 0; j < strlen(tmp_str); j++) {
      char tmp_char = tmp_str[j];
      printf("%c", tmp_char);
    }
    printf("\n");
  }
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 5; j++) {
      printf("%c", matrix[i][j]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<strings_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xeac(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    11b0 <strings_matrix+0x70>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1173 <strings_matrix+0x33>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x20(%rbp)
jge    125f <strings_matrix+0x11f>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
cmp    %ecx,%eax
jge    1243 <strings_matrix+0x103>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x2d(%rbp)
movsbl -0x2d(%rbp),%esi
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11f9 <strings_matrix+0xb9>
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d8 <strings_matrix+0x98>
movl   $0x0,-0x34(%rbp)
cmpl   $0x2,-0x34(%rbp)
jge    12cd <strings_matrix+0x18d>
movl   $0x0,-0x38(%rbp)
cmpl   $0x5,-0x38(%rbp)
jge    12b1 <strings_matrix+0x171>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1277 <strings_matrix+0x137>
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1266 <strings_matrix+0x126>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strings_matrix>:
push   %r15
push   %r14
push   %rbx
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
lea    0xea7(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,(%r14)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,0x8(%r14)
mov    (%r14),%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    0x8(%r14),%rdi
lea    0xe72(%rip),%rsi
call   1040 <strcpy@plt>
mov    (%r14),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    11cd <strings_matrix+0x8d>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11b0 <strings_matrix+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%r14),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    120d <strings_matrix+0xcd>
xor    %ebx,%ebx
nopl   0x0(%rax)
movsbl (%r15,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11f0 <strings_matrix+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%r14),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
mov    (%r14),%rax
movsbl 0x1(%rax),%edi
call   1030 <putchar@plt>
mov    (%r14),%rax
movsbl 0x2(%rax),%edi
call   1030 <putchar@plt>
mov    (%r14),%rax
movsbl 0x3(%rax),%edi
call   1030 <putchar@plt>
mov    (%r14),%rax
movsbl 0x4(%rax),%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%r14),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
mov    0x8(%r14),%rax
movsbl 0x1(%rax),%edi
call   1030 <putchar@plt>
mov    0x8(%r14),%rax
movsbl 0x2(%rax),%edi
call   1030 <putchar@plt>
mov    0x8(%r14),%rax
movsbl 0x3(%rax),%edi
call   1030 <putchar@plt>
mov    0x8(%r14),%rax
movsbl 0x4(%rax),%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"_abc_\00"
@.str.1 = [6 x i8] c"_xyz_\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @strings_matrix() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %2
%11 = call i64 @malloc(i32 16)
%12 = inttoptr i64 %11 to i8**
store i8** %12, i8*** %3
store i32 0, i32* %4
br label %13
13: ; preds = %28, %0
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %31
16: ; preds = %13
%17 = load i8*, i8** %1
%18 = call i32 @strlen(i8* %17)
%19 = sext i32 %18 to i64
%20 = mul i64 1, %19
%21 = trunc i64 %20 to i32
%22 = call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i8*
%24 = load i8**, i8*** %3
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
store i8* %23, i8** %27
br label %28
28: ; preds = %16
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %13
31: ; preds = %13
%32 = load i8**, i8*** %3
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = load i8*, i8** %1
%36 = call i32 @strcpy(i8* %34, i8* %35)
%37 = load i8**, i8*** %3
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = load i8*, i8** %2
%41 = call i32 @strcpy(i8* %39, i8* %40)
store i32 0, i32* %5
br label %42
42: ; preds = %70, %31
%43 = load i32, i32* %5
%44 = icmp slt i32 %43, 2
br i1 %44, label %45, label %73
45: ; preds = %42
%46 = load i8**, i8*** %3
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
store i8* %50, i8** %6
store i32 0, i32* %7
br label %51
51: ; preds = %65, %45
%52 = load i32, i32* %7
%53 = load i8*, i8** %6
%54 = call i32 @strlen(i8* %53)
%55 = icmp slt i32 %52, %54
br i1 %55, label %56, label %68
56: ; preds = %51
%57 = load i8*, i8** %6
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
%61 = load i8, i8* %60
store i8 %61, i8* %8
%62 = load i8, i8* %8
%63 = sext i8 %62 to i32
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %56
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
store i32 %67, i32* %7
br label %51
68: ; preds = %51
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %70
70: ; preds = %68
%71 = load i32, i32* %5
%72 = add nsw i32 %71, 1
store i32 %72, i32* %5
br label %42
73: ; preds = %42
store i32 0, i32* %9
br label %74
74: ; preds = %98, %73
%75 = load i32, i32* %9
%76 = icmp slt i32 %75, 2
br i1 %76, label %77, label %101
77: ; preds = %74
store i32 0, i32* %10
br label %78
78: ; preds = %93, %77
%79 = load i32, i32* %10
%80 = icmp slt i32 %79, 5
br i1 %80, label %81, label %96
81: ; preds = %78
%82 = load i8**, i8*** %3
%83 = load i32, i32* %9
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8*, i8** %82, i64 %84
%86 = load i8*, i8** %85
%87 = load i32, i32* %10
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %86, i64 %88
%90 = load i8, i8* %89
%91 = sext i8 %90 to i32
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %91)
br label %93
93: ; preds = %81
%94 = load i32, i32* %10
%95 = add nsw i32 %94, 1
store i32 %95, i32* %10
br label %78
96: ; preds = %78
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %98
98: ; preds = %96
%99 = load i32, i32* %9
%100 = add nsw i32 %99, 1
store i32 %100, i32* %9
br label %74
101: ; preds = %74
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"_abc_\00"
@.str.1 = [6 x i8] c"_xyz_\00"
define void @strings_matrix() {
%1 = tail call i64 @malloc(i32 16)
%2 = inttoptr i64 %1 to i8**
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %2
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = getelementptr inbounds i8*, i8** %2, i64 1
store i8* %8, i8** %9
%10 = load i8*, i8** %2
%11 = tail call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %9
%13 = tail call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%14 = load i8*, i8** %2
%15 = tail call i32 @strlen(i8* %14)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %84, label %17
17: ; preds = %84, %0
%18 = tail call i32 @putchar(i32 10)
%19 = load i8*, i8** %9
%20 = tail call i32 @strlen(i8* %19)
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %32
22: ; preds = %17, %22
%23 = phi i64 [ %28, %22 ], [ 0, %17 ]
%24 = getelementptr inbounds i8, i8* %19, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = tail call i32 @putchar(i32 %26)
%28 = add nuw nsw i64 %23, 1
%29 = tail call i32 @strlen(i8* %19)
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %28, %30
br i1 %31, label %22, label %32
32: ; preds = %22, %17
%33 = tail call i32 @putchar(i32 10)
%34 = load i8*, i8** %2
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = tail call i32 @putchar(i32 %36)
%38 = load i8*, i8** %2
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = tail call i32 @putchar(i32 %41)
%43 = load i8*, i8** %2
%44 = getelementptr inbounds i8, i8* %43, i64 2
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = tail call i32 @putchar(i32 %46)
%48 = load i8*, i8** %2
%49 = getelementptr inbounds i8, i8* %48, i64 3
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = tail call i32 @putchar(i32 %51)
%53 = load i8*, i8** %2
%54 = getelementptr inbounds i8, i8* %53, i64 4
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = tail call i32 @putchar(i32 %56)
%58 = tail call i32 @putchar(i32 10)
%59 = load i8*, i8** %9
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = tail call i32 @putchar(i32 %61)
%63 = load i8*, i8** %9
%64 = getelementptr inbounds i8, i8* %63, i64 1
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = tail call i32 @putchar(i32 %66)
%68 = load i8*, i8** %9
%69 = getelementptr inbounds i8, i8* %68, i64 2
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = tail call i32 @putchar(i32 %71)
%73 = load i8*, i8** %9
%74 = getelementptr inbounds i8, i8* %73, i64 3
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = tail call i32 @putchar(i32 %76)
%78 = load i8*, i8** %9
%79 = getelementptr inbounds i8, i8* %78, i64 4
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = tail call i32 @putchar(i32 %81)
%83 = tail call i32 @putchar(i32 10)
ret void
84: ; preds = %0, %84
%85 = phi i64 [ %90, %84 ], [ 0, %0 ]
%86 = getelementptr inbounds i8, i8* %14, i64 %85
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = tail call i32 @putchar(i32 %88)
%90 = add nuw nsw i64 %85, 1
%91 = tail call i32 @strlen(i8* %14)
%92 = sext i32 %91 to i64
%93 = icmp slt i64 %90, %92
br i1 %93, label %84, label %17
}