#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 */
void *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ wypelnijSlimak(int **, int, int, int, int, int);
int main() {
  int rozmiar, srodek, i;
  int **slimak;
  printf("Rozmiar tablicy: ");
  scanf("%d", &rozmiar);
  slimak = malloc(rozmiar * sizeof(int *));
  for (i = 0; i < rozmiar; i++) {
    slimak[i] = malloc(rozmiar * sizeof(int));
  }
  if (rozmiar % 2 == 0)
    srodek = (rozmiar / 2) - 1;
  else
    srodek = rozmiar / 2;
  slimak[srodek][srodek] = 1;
  slimak[srodek][srodek + 1] = 2;
  slimak[srodek + 1][srodek + 1] = 3;
  slimak[srodek + 1][srodek] = 4;
  int w = srodek + 1, k = srodek;
  wypelnijSlimak(slimak, w, k, 3, 5, rozmiar);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11bd <main+0x7d>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1185 <main+0x45>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11e7 <main+0xa7>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11f5 <main+0xb5>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0xc(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movl   $0x2,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movl   $0x3,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0xc(%rbp),%rcx
movl   $0x4,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x8(%rbp),%r9d
mov    $0x3,%ecx
mov    $0x5,%r8d
call   1060 <wypelnijSlimak@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%r15d
lea    0x0(,%r15,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r14
test   %r15d,%r15d
jle    11a4 <main+0x64>
lea    0x0(,%r15,4),%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1040 <malloc@plt>
mov    %rax,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1190 <main+0x50>
mov    %r15d,%eax
and    $0x1,%eax
mov    %r15d,%ecx
shr    $0x1f,%ecx
add    %r15d,%ecx
sar    %ecx
lea    (%rcx,%rax,1),%edx
add    $0xffffffff,%edx
movslq %edx,%rdx
mov    (%r14,%rdx,8),%rdi
movl   $0x1,(%rdi,%rdx,4)
add    %eax,%ecx
movslq %ecx,%rsi
movl   $0x2,(%rdi,%rsi,4)
mov    (%r14,%rsi,8),%rax
movl   $0x3,(%rax,%rsi,4)
movl   $0x4,(%rax,%rdx,4)
mov    0x4(%rsp),%r9d
mov    %r14,%rdi
mov    $0x3,%ecx
mov    $0x5,%r8d
call   1060 <wypelnijSlimak@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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