#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 /*<<< orphan*/ reverse(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ scanf(char *, ...);
void experiment(int x) {
  int r, c, i;
  scanf("%d %d", &r, &c);
  char arr[r][c + 1];
  for (i = 0; i < r; i++)
    scanf("%s", arr[i]);
  printf("Test %d\n", x);
  for (i = r - 1; i >= 0; i--) {
    reverse(arr[i], 0, c - 1);
    printf("%s\n", arr[i]);
  }
}


x86 assembly (clang, -O0):
<experiment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
lea    0xebe(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %rax,-0x38(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,%rsi
imul   %rax,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x20(%rbp)
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11cd <experiment+0x9d>
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rcx
movslq -0x10(%rbp),%rax
imul   %rcx,%rax
add    %rax,%rsi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1192 <experiment+0x62>
mov    -0x4(%rbp),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     1240 <experiment+0x110>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rcx
movslq -0x10(%rbp),%rax
imul   %rcx,%rax
add    %rax,%rdi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1030 <reverse@plt>
mov    -0x38(%rbp),%rcx
mov    -0x30(%rbp),%rsi
movslq -0x10(%rbp),%rax
imul   %rcx,%rax
add    %rax,%rsi
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    11e7 <experiment+0xb7>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<experiment>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,-0x34(%rbp)
lea    0xea5(%rip),%rdi
lea    -0x2c(%rbp),%rsi
lea    -0x30(%rbp),%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %rsp,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x30(%rbp),%r13d
add    $0x1,%r13d
imul   %r13,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r12
sub    %rax,%r12
mov    %r12,%rsp
cmpl   $0x0,-0x2c(%rbp)
jle    11cd <experiment+0x8d>
lea    0xe6b(%rip),%r15
mov    %r12,%rbx
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
add    $0x1,%r14
movslq -0x2c(%rbp),%rax
add    %r13,%rbx
cmp    %rax,%r14
jl     11b0 <experiment+0x70>
lea    0xe35(%rip),%rdi
mov    -0x34(%rbp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x2c(%rbp),%r14d
test   %r14d,%r14d
jle    121d <experiment+0xdd>
add    $0x1,%r14
nopl   0x0(%rax,%rax,1)
lea    -0x2(%r14),%ebx
imul   %r13,%rbx
add    %r12,%rbx
mov    -0x30(%rbp),%edx
add    $0xffffffff,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <reverse@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
add    $0xffffffffffffffff,%r14
cmp    $0x1,%r14
ja     11f0 <experiment+0xb0>
mov    -0x40(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [9 x i8] c"Test %d\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define void @experiment(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
store i32 %0, i32* %2
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%10 = load i32, i32* %3
%11 = zext i32 %10 to i64
%12 = load i32, i32* %4
%13 = add nsw i32 %12, 1
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %6
%16 = mul nuw i64 %11, %14
%17 = alloca i8, i64 %16
store i64 %11, i64* %7
store i64 %14, i64* %8
store i32 0, i32* %5
br label %18
18: ; preds = %28, %1
%19 = load i32, i32* %5
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = mul nsw i64 %24, %14
%26 = getelementptr inbounds i8, i8* %17, i64 %25
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %22
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %18
31: ; preds = %18
%32 = load i32, i32* %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %3
%35 = sub nsw i32 %34, 1
store i32 %35, i32* %5
br label %36
36: ; preds = %52, %31
%37 = load i32, i32* %5
%38 = icmp sge i32 %37, 0
br i1 %38, label %39, label %55
39: ; preds = %36
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = mul nsw i64 %41, %14
%43 = getelementptr inbounds i8, i8* %17, i64 %42
%44 = load i32, i32* %4
%45 = sub nsw i32 %44, 1
%46 = call i32 @reverse(i8* %43, i32 0, i32 %45)
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = mul nsw i64 %48, %14
%50 = getelementptr inbounds i8, i8* %17, i64 %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %39
%53 = load i32, i32* %5
%54 = add nsw i32 %53, -1
store i32 %54, i32* %5
br label %36
55: ; preds = %36
%56 = load i8*, i8** %6
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [9 x i8] c"Test %d\0A\00"
define void @experiment(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%7 = load i32, i32* %2
%8 = zext i32 %7 to i64
%9 = load i32, i32* %3
%10 = add nsw i32 %9, 1
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
%13 = mul nuw i64 %11, %8
%14 = alloca i8, i64 %13
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %1, %17
%18 = phi i64 [ %22, %17 ], [ 0, %1 ]
%19 = mul nuw nsw i64 %18, %11
%20 = getelementptr inbounds i8, i8* %14, i64 %19
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = add nuw nsw i64 %18, 1
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %22, %24
br i1 %25, label %17, label %26
26: ; preds = %17, %1
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %0)
%28 = load i32, i32* %2
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %43
30: ; preds = %26
%31 = zext i32 %28 to i64
br label %32
32: ; preds = %30, %32
%33 = phi i64 [ %31, %30 ], [ %34, %32 ]
%34 = add nsw i64 %33, -1
%35 = and i64 %34, 4294967295
%36 = mul nuw nsw i64 %35, %11
%37 = getelementptr inbounds i8, i8* %14, i64 %36
%38 = load i32, i32* %3
%39 = add nsw i32 %38, -1
%40 = call i32 @reverse(i8* %37, i32 0, i32 %39)
%41 = call i32 @puts(i8* %37)
%42 = icmp ugt i64 %33, 1
br i1 %42, label %32, label %43
43: ; preds = %32, %26
ret void
}