#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*/ min_input(char *, int *);
int /*<<< orphan*/ printf(char *);
int meny() {
  int valg;
  int valg_ok = 0;
  while (valg_ok == 0) {
    printf("\nVelg 1 for aa avslutte\n");
    printf("Velg 2 for aa legge sammen to tall, a + b\n");
    printf("Velg 3 for aa multiplisere to tall, a x b\n");
    printf("\n");
    min_input("Velg:", &valg);
    if (valg == 1 || valg == 2 || valg == 3) {
      return valg;
    } else {
      printf("Ugyldig valg, velg 1, 2 eller 3\n");
    }
  }
}


x86 assembly (clang, -O0):
<meny>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11b3 <meny+0x93>
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
call   1030 <printf@plt>
lea    0xf30(%rip),%rdi
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <min_input@plt>
cmpl   $0x1,-0x8(%rbp)
je     1197 <meny+0x77>
cmpl   $0x2,-0x8(%rbp)
je     1197 <meny+0x77>
cmpl   $0x3,-0x8(%rbp)
jne    11a2 <meny+0x82>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b3 <meny+0x93>
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <meny+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<meny>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xec4(%rip),%rdi
call   1040 <puts@plt>
lea    0xed0(%rip),%rdi
call   1040 <puts@plt>
lea    0xeee(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe90(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <min_input@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x3,%ecx
jb     11f1 <meny+0xc1>
lea    0xee5(%rip),%r14
lea    0xe72(%rip),%r15
lea    0xe83(%rip),%r12
lea    0xea6(%rip),%r13
lea    0xe57(%rip),%rbx
lea    0x4(%rsp),%rbp
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <min_input@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x2,%ecx
ja     11b0 <meny+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"\0AVelg 1 for aa avslutte\0A\00"
@.str.1 = [43 x i8] c"Velg 2 for aa legge sammen to tall, a + b\0A\00"
@.str.2 = [43 x i8] c"Velg 3 for aa multiplisere to tall, a x b\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [6 x i8] c"Velg:\00"
@.str.5 = [33 x i8] c"Ugyldig valg, velg 1, 2 eller 3\0A\00"
define i32 @meny() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %3
br label %4
4: ; preds = %25, %0
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %26
7: ; preds = %4
%8 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @min_input(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 1
br i1 %14, label %21, label %15
15: ; preds = %7
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 2
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %2
%20 = icmp eq i32 %19, 3
br i1 %20, label %21, label %23
21: ; preds = %18, %15, %7
%22 = load i32, i32* %2
store i32 %22, i32* %1
br label %26
23: ; preds = %18
%24 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %25
25: ; preds = %23
br label %4
26: ; preds = %21, %4
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str.4 = [6 x i8] c"Velg:\00"
@str = [24 x i8] c"\0AVelg 1 for aa avslutte\00"
@str.6 = [42 x i8] c"Velg 2 for aa legge sammen to tall, a + b\00"
@str.7 = [42 x i8] c"Velg 3 for aa multiplisere to tall, a x b\00"
@str.8 = [32 x i8] c"Ugyldig valg, velg 1, 2 eller 3\00"
define i32 @meny() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.6, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.7, i64 0, i64 0))
%6 = call i32 @putchar(i32 10)
%7 = call i32 @min_input(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add i32 %8, -1
%10 = icmp ult i32 %9, 3
br i1 %10, label %21, label %11
11: ; preds = %0, %11
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.8, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.6, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.7, i64 0, i64 0))
%16 = call i32 @putchar(i32 10)
%17 = call i32 @min_input(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%18 = load i32, i32* %1
%19 = add i32 %18, -1
%20 = icmp ult i32 %19, 3
br i1 %20, label %21, label %11
21: ; preds = %11, %0
%22 = phi i32 [ %8, %0 ], [ %18, %11 ]
ret i32 %22
}