#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 *, int, ...);
void print_array(char array[2][4]) {
  int element1;
  for (element1 = 0; element1 < 2; ++element1) {
    printf("Dimension %d:\n", element1 + 1);
    int element2;
    for (element2 = 0; array[element1][element2] != '\0'; ++element2)
      printf("\tarray[%d][%d] = %c\n", element1, element2,
             array[element1][element2]);
  }
}


x86 assembly (clang, -O0):
<print_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jge    11b4 <print_array+0xa4>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11a1 <print_array+0x91>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1148 <print_array+0x38>
jmp    11a6 <print_array+0x96>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <print_array+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_array>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
lea    0xee1(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%r15),%al
test   %al,%al
je     115f <print_array+0x4f>
lea    0xed6(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl %al,%ecx
mov    %r14,%rdi
xor    %esi,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0x1(%r15,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <print_array+0x30>
lea    0xe9a(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%r15),%al
test   %al,%al
je     11b2 <print_array+0xa2>
lea    0xe8e(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %al,%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0x5(%r15,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1190 <print_array+0x80>
pop    %rbx
pop    %r14
pop    %r15
ret

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

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