#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 atoi(char *);
int /*<<< orphan*/ do_procedure(int);
int /*<<< orphan*/ is_number(char *);
int /*<<< orphan*/ print_menu();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
void start_ui() {
  char temp_str[16];
  int choice;
  printf("Witaj w programie do obslugi zajezdni tramwajowej!\n");
  printf("----------------------------------------\n\n");
  for (;;) {
    print_menu();
    scanf(" %15[^\n]", temp_str);
    while (!is_number(temp_str)) {
      printf("To nie jest liczba!\n");
      printf("Podaj numer operacji i nacisnij enter: ");
      scanf(" %15[^\n]", temp_str);
    }
    choice = atoi(temp_str);
    if (!choice)
      break;
    do_procedure(choice);
  }
  printf("\n=======================\n");
  printf("Wyjscie z programu...\n");
}


x86 assembly (clang, -O0):
<start_ui>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <print_menu@plt>
lea    -0x10(%rbp),%rsi
lea    0xecd(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x10(%rbp),%rdi
call   1030 <is_number@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b5 <start_ui+0x55>
jmp    11e2 <start_ui+0x82>
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
lea    -0x10(%rbp),%rsi
lea    0xe87(%rip),%rdi
call   1060 <scanf@plt>
jmp    1197 <start_ui+0x37>
lea    -0x10(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11fd <start_ui+0x9d>
jmp    120a <start_ui+0xaa>
mov    -0x14(%rbp),%edi
call   1080 <do_procedure@plt>
jmp    1180 <start_ui+0x20>
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
lea    0xea2(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_ui>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeaf(%rip),%rdi
call   1040 <puts@plt>
lea    0xed6(%rip),%rdi
call   1040 <puts@plt>
lea    0xe66(%rip),%r14
mov    %rsp,%rbx
lea    0xf19(%rip),%r15
lea    0xe5e(%rip),%r12
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <print_menu@plt>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    %rbx,%rdi
call   1030 <is_number@plt>
test   %eax,%eax
jne    11f0 <start_ui+0x80>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1050 <printf@plt>
jmp    11c0 <start_ui+0x50>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1080 <atoi@plt>
test   %eax,%eax
je     1205 <start_ui+0x95>
mov    %eax,%edi
call   1090 <do_procedure@plt>
jmp    11b0 <start_ui+0x40>
lea    0xe82(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8f(%rip),%rdi
call   1040 <puts@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [52 x i8] c"Witaj w programie do obslugi zajezdni tramwajowej!\0A\00"
@.str.1 = [43 x i8] c"----------------------------------------\0A\0A\00"
@.str.2 = [9 x i8] c" %15[^\0A]\00"
@.str.3 = [21 x i8] c"To nie jest liczba!\0A\00"
@.str.4 = [40 x i8] c"Podaj numer operacji i nacisnij enter: \00"
@.str.5 = [26 x i8] c"\0A=======================\0A\00"
@.str.6 = [23 x i8] c"Wyjscie z programu...\0A\00"
define void @start_ui() {
%1 = alloca [16 x i8]
%2 = alloca i32
%3 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %5
5: ; preds = %25, %0
%6 = call i32 (...) @print_menu()
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %14, %5
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%11 = call i32 @is_number(i8* %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%18 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %9
19: ; preds = %9
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = icmp ne i32 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %19
br label %28
25: ; preds = %19
%26 = load i32, i32* %2
%27 = call i32 @do_procedure(i32 %26)
br label %5
28: ; preds = %24
%29 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%30 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.2 = [9 x i8] c" %15[^\0A]\00"
@.str.4 = [40 x i8] c"Podaj numer operacji i nacisnij enter: \00"
@str = [51 x i8] c"Witaj w programie do obslugi zajezdni tramwajowej!\00"
@str.7 = [42 x i8] c"----------------------------------------\0A\00"
@str.8 = [25 x i8] c"\0A=======================\00"
@str.9 = [22 x i8] c"Wyjscie z programu...\00"
@str.10 = [20 x i8] c"To nie jest liczba!\00"
define void @start_ui() {
%1 = alloca [16 x i8]
%2 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.7, i64 0, i64 0))
br label %5
5: ; preds = %19, %0
%6 = call i32 (...) @print_menu()
%7 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%8 = call i32 @is_number(i8* %2)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %5, %10
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%14 = call i32 @is_number(i8* %2)
%15 = icmp eq i32 %14, 0
br i1 %15, label %10, label %16
16: ; preds = %10, %5
%17 = call i32 @atoi(i8* %2)
%18 = icmp eq i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 @do_procedure(i32 %17)
br label %5
21: ; preds = %16
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.8, i64 0, i64 0))
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
ret void
}