#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*/ printf(char *, char);
void print_the_field(int ROW, int COL, char **matrix, size_t lenght) {
  int row, col, ctr = 0;
  for (row = 0; row < ROW; row++) {
    for (col = 0; col < COL; col++, ctr++) {
      printf("%c", matrix[row][col]);
      if (ctr == lenght) {
        break;
      }
    }
  }
}


x86 assembly (clang, -O0):
<print_the_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b5 <print_the_field+0xa5>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a2 <print_the_field+0x92>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
lea    0xe96(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
movslq -0x24(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    1186 <print_the_field+0x76>
jmp    11a2 <print_the_field+0x92>
jmp    118b <print_the_field+0x7b>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1147 <print_the_field+0x37>
jmp    11a7 <print_the_field+0x97>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1134 <print_the_field+0x24>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_the_field>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,0x10(%rsp)
mov    %esi,0xc(%rsp)
test   %edi,%edi
jle    11a4 <print_the_field+0x94>
mov    %rdx,%rbx
mov    %edi,%eax
mov    %rax,0x20(%rsp)
mov    0xc(%rsp),%ebp
negq   0x10(%rsp)
xor    %r14d,%r14d
lea    0xeb8(%rip),%r13
xor    %ecx,%ecx
jmp    1163 <print_the_field+0x53>
nopl   0x0(%rax)
mov    0x18(%rsp),%rcx
add    %r12,%rcx
add    $0x1,%r14
cmp    0x20(%rsp),%r14
je     11a4 <print_the_field+0x94>
cmpl   $0x0,0xc(%rsp)
jle    1158 <print_the_field+0x48>
movslq %ecx,%rcx
mov    0x10(%rsp),%rax
mov    %rcx,0x18(%rsp)
lea    (%rax,%rcx,1),%r15
xor    %r12d,%r12d
xchg   %ax,%ax
mov    (%rbx,%r14,8),%rax
movsbl (%rax,%r12,1),%esi
mov    %r13,%rdi
call   1030 <printf@plt>
mov    %r15,%rax
add    %r12,%rax
je     1150 <print_the_field+0x40>
add    $0x1,%r12
cmp    %r12,%rbp
jne    1180 <print_the_field+0x70>
jmp    1150 <print_the_field+0x40>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @print_the_field(i32 %0, i32 %1, i8** nocapture %2, i64 %3) {
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %35
6: ; preds = %4
%7 = icmp sgt i32 %1, 0
%8 = zext i32 %0 to i64
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %6, %31
%11 = phi i64 [ 0, %6 ], [ %33, %31 ]
%12 = phi i32 [ 0, %6 ], [ %32, %31 ]
%13 = getelementptr inbounds i8*, i8** %2, i64 %11
br i1 %7, label %14, label %31
14: ; preds = %10
%15 = sext i32 %12 to i64
br label %16
16: ; preds = %14, %24
%17 = phi i64 [ 0, %14 ], [ %25, %24 ]
%18 = phi i64 [ %15, %14 ], [ %26, %24 ]
%19 = load i8*, i8** %13
%20 = getelementptr inbounds i8, i8* %19, i64 %17
%21 = load i8, i8* %20
%22 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %21)
%23 = icmp eq i64 %18, %3
br i1 %23, label %28, label %24
24: ; preds = %16
%25 = add nuw nsw i64 %17, 1
%26 = add nsw i64 %18, 1
%27 = icmp eq i64 %25, %9
br i1 %27, label %28, label %16
28: ; preds = %24, %16
%29 = phi i64 [ %18, %16 ], [ %26, %24 ]
%30 = trunc i64 %29 to i32
br label %31
31: ; preds = %28, %10
%32 = phi i32 [ %12, %10 ], [ %30, %28 ]
%33 = add nuw nsw i64 %11, 1
%34 = icmp eq i64 %33, %8
br i1 %34, label %35, label %10
35: ; preds = %31, %4
ret void
}