#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 /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
int main(void) {
  setbuf(stdout, NULL);
  int Wahl = 4;
  int dez = 0;
  while (Wahl > 2 || Wahl < 0) {
    printf("***Darstellungsrechner***\n\n1 = Dezimal nach Oktal\n2 = Dezimal "
           "nach Hexadezimal\n0 = Programm beenden\n\nIhre Auswahl: ");
    scanf("%i", &Wahl);
  }
  if (Wahl == 0) {
    return 1;
  } else if (Wahl == 1) {
    printf("\n--> Dezimal nach Oktal\n\n");
  } else if (Wahl == 2) {
    printf("\n--> Dezimal nach Hexadezimal\n\n");
  }
  printf("Geben Sie eine Dezimalzahl ein: ");
  scanf("%i", &dez);
  (Wahl < 2) ? printf("\nDie Oktaldarstellung von %i ist %o", dez, dez)
             : printf("\nDie Hexadezimaldarstellung von %i ist %x", dez, dez);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <setbuf@plt>
movl   $0x4,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x1,%al
cmpl   $0x2,-0x8(%rbp)
mov    %al,-0xd(%rbp)
jg     1178 <main+0x48>
cmpl   $0x0,-0x8(%rbp)
setl   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1188 <main+0x58>
jmp    11ab <main+0x7b>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
jmp    115f <main+0x2f>
cmpl   $0x0,-0x8(%rbp)
jne    11c1 <main+0x91>
movl   $0x1,-0x4(%rbp)
jmp    125c <main+0x12c>
cmpl   $0x1,-0x8(%rbp)
jne    11de <main+0xae>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fb <main+0xcb>
cmpl   $0x2,-0x8(%rbp)
jne    11f6 <main+0xc6>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fb <main+0xcb>
jmp    1200 <main+0xd0>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe5f(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x2,-0x8(%rbp)
jge    1241 <main+0x111>
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1255 <main+0x125>
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1040 <setbuf@plt>
movl   $0x4,0x8(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xe90(%rip),%r14
lea    0xefd(%rip),%r15
lea    0x8(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0x8(%rsp),%eax
cmp    $0x2,%eax
ja     1180 <main+0x40>
test   %eax,%eax
je     11b0 <main+0x70>
cmp    $0x1,%eax
jne    11b7 <main+0x77>
lea    0xf57(%rip),%rdi
jmp    11be <main+0x7e>
mov    $0x1,%ebx
jmp    1208 <main+0xc8>
lea    0xf28(%rip),%rdi
call   1030 <puts@plt>
lea    0xead(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
cmpl   $0x2,0x8(%rsp)
mov    0xc(%rsp),%edx
lea    0xea4(%rip),%rax
lea    0xec1(%rip),%rdi
cmovl  %rax,%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [116 x i8] c"***Darstellungsrechner***\0A\0A1 = Dezimal nach Oktal\0A2 = Dezimal nach Hexadezimal\0A0 = Programm beenden\0A\0AIhre Auswahl: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [26 x i8] c"\0A--> Dezimal nach Oktal\0A\0A\00"
@.str.3 = [32 x i8] c"\0A--> Dezimal nach Hexadezimal\0A\0A\00"
@.str.4 = [33 x i8] c"Geben Sie eine Dezimalzahl ein: \00"
@.str.5 = [36 x i8] c"\0ADie Oktaldarstellung von %i ist %o\00"
@.str.6 = [42 x i8] c"\0ADie Hexadezimaldarstellung von %i ist %x\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* @stdout
%5 = call i32 @setbuf(i32 %4, i32* null)
store i32 4, i32* %2
store i32 0, i32* %3
br label %6
6: ; preds = %14, %0
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 2
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 0
br label %12
12: ; preds = %9, %6
%13 = phi i1 [ true, %6 ], [ %11, %9 ]
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %6
17: ; preds = %12
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %17
store i32 1, i32* %1
br label %48
21: ; preds = %17
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %32
26: ; preds = %21
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 2
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
br label %32
32: ; preds = %31, %24
br label %33
33: ; preds = %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%36 = load i32, i32* %2
%37 = icmp slt i32 %36, 2
br i1 %37, label %38, label %42
38: ; preds = %33
%39 = load i32, i32* %3
%40 = load i32, i32* %3
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 %39, i32 %40)
br label %46
42: ; preds = %33
%43 = load i32, i32* %3
%44 = load i32, i32* %3
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), i32 %43, i32 %44)
br label %46
46: ; preds = %42, %38
%47 = phi i32 [ %41, %38 ], [ %45, %42 ]
store i32 0, i32* %1
br label %48
48: ; preds = %46, %20
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [116 x i8] c"***Darstellungsrechner***\0A\0A1 = Dezimal nach Oktal\0A2 = Dezimal nach Hexadezimal\0A0 = Programm beenden\0A\0AIhre Auswahl: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.4 = [33 x i8] c"Geben Sie eine Dezimalzahl ein: \00"
@.str.5 = [36 x i8] c"\0ADie Oktaldarstellung von %i ist %o\00"
@.str.6 = [42 x i8] c"\0ADie Hexadezimaldarstellung von %i ist %x\00"
@str = [31 x i8] c"\0A--> Dezimal nach Hexadezimal\0A\00"
@str.7 = [25 x i8] c"\0A--> Dezimal nach Oktal\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @stdout
%4 = tail call i32 @setbuf(i32 %3, i32* null)
%5 = bitcast i32* %1 to i8*
store i32 4, i32* %1
%6 = bitcast i32* %2 to i8*
store i32 0, i32* %2
br label %7
7: ; preds = %0, %7
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([116 x i8], [116 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 = icmp ugt i32 %10, 2
br i1 %11, label %7, label %12
12: ; preds = %7
switch i32 %10, label %13 [
i32 0, label %24
i32 1, label %14
]
13: ; preds = %12
br label %14
14: ; preds = %12, %13
%15 = phi i8* [ getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0), %13 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @str.7, i64 0, i64 0), %12 ]
%16 = call i32 @puts(i8* dereferenceable(1) %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%19 = load i32, i32* %1
%20 = icmp slt i32 %19, 2
%21 = load i32, i32* %2
%22 = select i1 %20, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %22, i32 %21, i32 %21)
br label %24
24: ; preds = %14, %12
%25 = phi i32 [ 1, %12 ], [ 0, %14 ]
ret i32 %25
}