#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 vrednost, izbor;
  printf("Vnesi pocetnа vrednost: ");
  scanf("%d", &vrednost);
  do {
    do {
      printf("Meni:\n");
      printf("1 - zgolemi\n");
      printf("2 - namali\n");
      printf("3 - dupliraj\n");
      printf("0 - kraj\n");
      printf("izbor : ");
      scanf("%d", &izbor);
    } while ((izbor < 0) || (izbor > 3));
    switch (izbor) {
    case 1:
      vrednost++;
      break;
    case 2:
      vrednost--;
      break;
    case 3:
      vrednost *= 2;
      break;
    case 0:
      printf("Kraj\n");
      break;
    default:
      printf("Nevaliden izbor!\n");
      break;
    }
    printf("Vrednost = %d\n", vrednost);
  } while (izbor != 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1152 <main+0x32>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7d(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jl     11cf <main+0xaf>
cmpl   $0x3,-0xc(%rbp)
setg   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1152 <main+0x32>
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%rax
ja     123c <main+0x11c>
mov    -0x18(%rbp),%rax
lea    0xe0a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    124a <main+0x12a>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    124a <main+0x12a>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    124a <main+0x12a>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124a <main+0x12a>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    114d <main+0x2d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeda(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
lea    0xeec(%rip),%r12
lea    0xef1(%rip),%rbp
lea    0xef5(%rip),%r14
lea    0xefb(%rip),%r15
lea    0xeb2(%rip),%r13
lea    0x4(%rsp),%rbx
jmp    11af <main+0x7f>
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%esi
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rbx
je     1237 <main+0x107>
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3e(%rip),%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%eax
ja     11af <main+0x7f>
ja     1182 <main+0x52>
mov    %eax,%eax
lea    0xdf8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe60(%rip),%rdi
jmp    1189 <main+0x59>
addl   $0x1,(%rsp)
jmp    118e <main+0x5e>
addl   $0xffffffff,(%rsp)
jmp    118e <main+0x5e>
shll   (%rsp)
jmp    118e <main+0x5e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Vnesi pocetn\D0\B0 vrednost: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"Meni:\0A\00"
@.str.3 = [13 x i8] c"1 - zgolemi\0A\00"
@.str.4 = [12 x i8] c"2 - namali\0A\00"
@.str.5 = [14 x i8] c"3 - dupliraj\0A\00"
@.str.6 = [10 x i8] c"0 - kraj\0A\00"
@.str.7 = [9 x i8] c"izbor : \00"
@.str.8 = [6 x i8] c"Kraj\0A\00"
@.str.9 = [18 x i8] c"Nevaliden izbor!\0A\00"
@.str.10 = [15 x i8] c"Vrednost = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %6
6: ; preds = %41, %0
br label %7
7: ; preds = %21, %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %15
15: ; preds = %7
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %3
%20 = icmp sgt i32 %19, 3
br label %21
21: ; preds = %18, %15
%22 = phi i1 [ true, %15 ], [ %20, %18 ]
br i1 %22, label %7, label %23
23: ; preds = %21
%24 = load i32, i32* %3
switch i32 %24, label %36 [
i32 1, label %25
i32 2, label %28
i32 3, label %31
i32 0, label %34
]
25: ; preds = %23
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
br label %38
28: ; preds = %23
%29 = load i32, i32* %2
%30 = add nsw i32 %29, -1
store i32 %30, i32* %2
br label %38
31: ; preds = %23
%32 = load i32, i32* %2
%33 = mul nsw i32 %32, 2
store i32 %33, i32* %2
br label %38
34: ; preds = %23
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %38
36: ; preds = %23
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %38
38: ; preds = %36, %34, %31, %28, %25
%39 = load i32, i32* %2
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %38
%42 = load i32, i32* %3
%43 = icmp ne i32 %42, 0
br i1 %43, label %6, label %44
44: ; preds = %41
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Vnesi pocetn\D0\B0 vrednost: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.7 = [9 x i8] c"izbor : \00"
@.str.10 = [15 x i8] c"Vrednost = %d\0A\00"
@str = [6 x i8] c"Meni:\00"
@str.11 = [12 x i8] c"1 - zgolemi\00"
@str.12 = [11 x i8] c"2 - namali\00"
@str.13 = [13 x i8] c"3 - dupliraj\00"
@str.14 = [9 x i8] c"0 - kraj\00"
@str.15 = [5 x i8] c"Kraj\00"
@str.16 = [17 x i8] c"Nevaliden izbor!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 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* %1)
br label %7
7: ; preds = %17, %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.11, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.12, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.13, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.14, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %2
%16 = icmp ugt i32 %15, 3
br i1 %16, label %17, label %18
17: ; preds = %7, %32
br label %7
18: ; preds = %7
switch i32 %15, label %30 [
i32 1, label %19
i32 2, label %22
i32 3, label %25
i32 0, label %28
]
19: ; preds = %18
%20 = load i32, i32* %1
%21 = add nsw i32 %20, 1
store i32 %21, i32* %1
br label %32
22: ; preds = %18
%23 = load i32, i32* %1
%24 = add nsw i32 %23, -1
store i32 %24, i32* %1
br label %32
25: ; preds = %18
%26 = load i32, i32* %1
%27 = shl nsw i32 %26, 1
store i32 %27, i32* %1
br label %32
28: ; preds = %18
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.15, i64 0, i64 0))
br label %32
30: ; preds = %18
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.16, i64 0, i64 0))
br label %32
32: ; preds = %30, %28, %25, %22, %19
%33 = load i32, i32* %1
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %2
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %17
37: ; preds = %32
ret i32 0
}