#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 rand();
main() {
  int niz[100];
  int i, n;
  n = rand() % 100 + 1;
  for (i = 0; i < 100; i++)
    printf("%3d", niz[i] = rand() % (40 - 3) + 3 + 1);
  printf("\n\nPocetna adresa niza je %p\n", niz);
  printf("\nAdresa prvog elementa niza je %p\n", &niz[0]);
  printf("\nAdresa drugog elementa niza je %p\n", &niz[1]);
  for (i = 0; i < 100; i++)
    printf("%3d", niz[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x1a8(%rbp)
movl   $0x0,-0x1a4(%rbp)
cmpl   $0x64,-0x1a4(%rbp)
jge    11a8 <main+0x88>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x25,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
add    $0x3,%esi
add    $0x1,%esi
movslq -0x1a4(%rbp),%rax
mov    %esi,-0x1a0(%rbp,%rax,4)
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    1154 <main+0x34>
lea    -0x1a0(%rbp),%rsi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1a0(%rbp),%rsi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1a0(%rbp),%rsi
add    $0x4,%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a4(%rbp)
cmpl   $0x64,-0x1a4(%rbp)
jge    1232 <main+0x112>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    11f5 <main+0xd5>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x198,%rsp
xor    %eax,%eax
call   1040 <rand@plt>
lea    0xec8(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0xffffffffdd67c8a7,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x5,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%edx
lea    (%rcx,%rdx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%esi
add    $0x4,%esi
mov    %esi,(%rsp,%rbx,4)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1140 <main+0x20>
lea    0xe78(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe81(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x4(%rsp),%rsi
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe3c(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    11d0 <main+0xb0>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%3d\00"
@.str.1 = [29 x i8] c"\0A\0APocetna adresa niza je %p\0A\00"
@.str.2 = [35 x i8] c"\0AAdresa prvog elementa niza je %p\0A\00"
@.str.3 = [36 x i8] c"\0AAdresa drugog elementa niza je %p\0A\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = tail call i32 (...) @rand()
br label %4
4: ; preds = %0, %4
%5 = phi i64 [ 0, %0 ], [ %11, %4 ]
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 37
%8 = add nsw i32 %7, 4
%9 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %5
store i32 %8, i32* %9
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%11 = add nuw nsw i64 %5, 1
%12 = icmp eq i64 %11, 100
br i1 %12, label %13, label %4
13: ; preds = %4
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32* %14)
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 1
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32* %17)
br label %19
19: ; preds = %13, %19
%20 = phi i64 [ 0, %13 ], [ %24, %19 ]
%21 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = add nuw nsw i64 %20, 1
%25 = icmp eq i64 %24, 100
br i1 %25, label %26, label %19
26: ; preds = %19
ret i32 0
}