#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*/ punjenjeListe(int *, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int odabir = 0, brojGeneriranihZnakova = 0;
  int lista[100000] = {};
  do {
    printf("Odaberite operaciju nad listom (1, 2 ili 3): ");
    scanf("%d", &odabir);
  } while (odabir < 1 || odabir > 3);
  do {
    printf("Unesite broj generiranih znakova: ");
    scanf("%d", &brojGeneriranihZnakova);
    if (odabir == 2 && brojGeneriranihZnakova > 100000 / 2) {
      brojGeneriranihZnakova = 100000 / 2;
    }
  } while (brojGeneriranihZnakova < 1 || brojGeneriranihZnakova > 100000);
  punjenjeListe(lista, odabir, brojGeneriranihZnakova);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61aa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x61a90(%rbp),%rdi
xor    %esi,%esi
mov    $0x61a80,%edx
call   1050 <memset@plt>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x1,%al
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x61a91(%rbp)
jl     11ae <main+0x6e>
cmpl   $0x3,-0x8(%rbp)
setg   %al
mov    %al,-0x61a91(%rbp)
mov    -0x61a91(%rbp),%al
test   $0x1,%al
jne    1173 <main+0x33>
jmp    11c1 <main+0x81>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
lea    0xe5a(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x2,-0x8(%rbp)
jne    11fb <main+0xbb>
cmpl   $0xc350,-0xc(%rbp)
jle    11fb <main+0xbb>
movl   $0xc350,-0xc(%rbp)
jmp    1200 <main+0xc0>
mov    $0x1,%al
cmpl   $0x1,-0xc(%rbp)
mov    %al,-0x61a92(%rbp)
jl     1222 <main+0xe2>
cmpl   $0x186a0,-0xc(%rbp)
setg   %al
mov    %al,-0x61a92(%rbp)
mov    -0x61a92(%rbp),%al
test   $0x1,%al
jne    11c1 <main+0x81>
lea    -0x61a90(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <punjenjeListe@plt>
xor    %eax,%eax
add    $0x61aa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x61a90,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x61a80,%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xe8c(%rip),%r14
lea    0xeb3(%rip),%r15
lea    0xc(%rsp),%rbx
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xfffffffc,%eax
cmp    $0xfffffffd,%eax
jb     1180 <main+0x40>
lea    0xe8b(%rip),%r14
lea    0xe81(%rip),%r15
lea    0x8(%rsp),%rbx
jmp    11cd <main+0x8d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    -0x186a1(%rdx),%eax
cmp    $0xfffe7960,%eax
jae    1202 <main+0xc2>
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
cmp    $0x2,%esi
jne    11c0 <main+0x80>
cmp    $0xc351,%edx
jl     11c0 <main+0x80>
movl   $0xc350,0x8(%rsp)
mov    $0xc350,%edx
lea    0x10(%rsp),%rdi
call   1040 <punjenjeListe@plt>
xor    %eax,%eax
add    $0x61a90,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Odaberite operaciju nad listom (1, 2 ili 3): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [35 x i8] c"Unesite broj generiranih znakova: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100000 x i32]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%5 = bitcast [100000 x i32]* %4 to i8*
br label %6
6: ; preds = %15, %0
%7 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %9
9: ; preds = %6
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 1
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 3
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ true, %9 ], [ %14, %12 ]
br i1 %16, label %6, label %17
17: ; preds = %15
br label %18
18: ; preds = %34, %17
%19 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 2
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = load i32, i32* %3
%25 = icmp sgt i32 %24, 50000
br i1 %25, label %26, label %27
26: ; preds = %23
store i32 50000, i32* %3
br label %27
27: ; preds = %26, %23, %18
br label %28
28: ; preds = %27
%29 = load i32, i32* %3
%30 = icmp slt i32 %29, 1
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = load i32, i32* %3
%33 = icmp sgt i32 %32, 100000
br label %34
34: ; preds = %31, %28
%35 = phi i1 [ true, %28 ], [ %33, %31 ]
br i1 %35, label %18, label %36
36: ; preds = %34
%37 = getelementptr inbounds [100000 x i32], [100000 x i32]* %4, i64 0, i64 0
%38 = load i32, i32* %2
%39 = load i32, i32* %3
%40 = call i32 @punjenjeListe(i32* %37, i32 %38, i32 %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [46 x i8] c"Odaberite operaciju nad listom (1, 2 ili 3): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [35 x i8] c"Unesite broj generiranih znakova: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100000 x i32]
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = bitcast [100000 x i32]* %3 to i8*
br label %7
7: ; preds = %7, %0
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 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* %1)
%10 = load i32, i32* %1
%11 = add i32 %10, -4
%12 = icmp ult i32 %11, -3
br i1 %12, label %7, label %13
13: ; preds = %7, %22
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %1
%17 = icmp eq i32 %16, 2
%18 = load i32, i32* %2
%19 = icmp sgt i32 %18, 50000
%20 = select i1 %17, i1 %19, i1 false
br i1 %20, label %21, label %22
21: ; preds = %13
store i32 50000, i32* %2
br label %25
22: ; preds = %13
%23 = add i32 %18, -100001
%24 = icmp ult i32 %23, -100000
br i1 %24, label %13, label %25
25: ; preds = %22, %21
%26 = phi i32 [ 50000, %21 ], [ %18, %22 ]
%27 = getelementptr inbounds [100000 x i32], [100000 x i32]* %3, i64 0, i64 0
%28 = call i32 @punjenjeListe(i32* %27, i32 %16, i32 %26)
ret i32 0
}