#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*/ scanf(char *, int *);
int main() {
  int n;
  int t[n];
  printf("Podaj ilość elementów w tablicy: ");
  scanf("%d", &n);
  printf("Podaj %d liczb całkowitych:\n", n);
  for (int i = 0; i <= n; i++) {
    scanf("%d", &t[i]);
  }
  printf("Wczytano do tablicy:\n");
  for (int i = 0; i <= n; i++) {
    printf("%d \n", t[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11c1 <main+0xa1>
mov    -0x28(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe77(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118c <main+0x6c>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1209 <main+0xe9>
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d6 <main+0xb6>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsp,%r15
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
lea    0xec3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x4(%rsp)
js     11ad <main+0x7d>
mov    %rsp,%r12
mov    $0xffffffffffffffff,%rbx
lea    0xea1(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
movslq 0x4(%rsp),%rax
add    $0x4,%r12
add    $0x1,%rbx
cmp    %rax,%rbx
jl     1190 <main+0x60>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x4(%rsp)
js     11eb <main+0xbb>
mov    $0xffffffffffffffff,%rbx
lea    0xe78(%rip),%r14
xchg   %ax,%ax
mov    (%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x4(%rsp),%rax
add    $0x1,%rbx
cmp    %rax,%rbx
jl     11d0 <main+0xa0>
mov    %r15,%rsp
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Podaj ilo\C5\9B\C4\87 element\C3\B3w w tablicy: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"Podaj %d liczb ca\C5\82kowitych:\0A\00"
@.str.3 = [22 x i8] c"Wczytano do tablicy:\0A\00"
@.str.4 = [5 x i8] c"%d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = load i32, i32* %2
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %3
%10 = alloca i32, i64 %8
store i64 %8, i64* %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %13)
store i32 0, i32* %5
br label %15
15: ; preds = %24, %0
%16 = load i32, i32* %5
%17 = load i32, i32* %2
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %10, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %22)
br label %24
24: ; preds = %19
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %15
27: ; preds = %15
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %6
br label %29
29: ; preds = %39, %27
%30 = load i32, i32* %6
%31 = load i32, i32* %2
%32 = icmp sle i32 %30, %31
br i1 %32, label %33, label %42
33: ; preds = %29
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %10, i64 %35
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %33
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %29
42: ; preds = %29
%43 = load i8*, i8** %3
%44 = load i32, i32* %1
ret i32 %44
}

LLVM IR (-O2):
@.str = [37 x i8] c"Podaj ilo\C5\9B\C4\87 element\C3\B3w w tablicy: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"Podaj %d liczb ca\C5\82kowitych:\0A\00"
@.str.4 = [5 x i8] c"%d \0A\00"
@str = [21 x i8] c"Wczytano do tablicy:\00"
define i32 @main() {
%1 = alloca [0 x i32]
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i8* @llvm.stacksave()
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %17, %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 0
br i1 %14, label %25, label %15
15: ; preds = %11
%16 = getelementptr inbounds [0 x i32], [0 x i32]* %1, i64 0, i64 0
br label %26
17: ; preds = %0, %17
%18 = phi i64 [ %21, %17 ], [ 0, %0 ]
%19 = getelementptr inbounds [0 x i32], [0 x i32]* %1, i64 0, i64 %18
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %19)
%21 = add nuw nsw i64 %18, 1
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %18, %23
br i1 %24, label %17, label %11
25: ; preds = %26, %11
ret i32 0
26: ; preds = %15, %26
%27 = phi i64 [ 0, %15 ], [ %30, %26 ]
%28 = load i32, i32* %16
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%30 = add nuw nsw i64 %27, 1
%31 = load i32, i32* %2
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %27, %32
br i1 %33, label %26, label %25
}