#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
int main(void) {
  setbuf(stdout, NULL);
  int opcode;
  double zahl1;
  double zahl2;
  printf("Dieses Programm rechnet mit zwei Zahlen.\n");
  printf("Bitte geben Sie die Art\nder Rechenoperation an:\n");
  printf(" 1 : +\n 2 : -\n 3 : *\n 4 : /\n");
  printf("Rechenoperation...............: ");
  scanf("%i", &opcode);
  printf("Bitte die erste Zahl eingeben : ");
  scanf("%lf", &zahl1);
  printf("Bitte die zweite Zahl eingeben: ");
  scanf("%lf", &zahl2);
  int stellen = 4;
  switch (opcode) {
  case 1:
    printf("Ergebnis: %lf\n", zahl1 + zahl2);
    break;
  case 2:
    printf("Ergebnis: %lf\n", zahl1 - zahl2);
    break;
  case 3:
    printf("Ergebnis: %lf\n", zahl1 * zahl2);
    break;
  case 4:
    if (zahl2) {
      printf("Ergebnis: %.lf\n", zahl1 / zahl2);
    } else {
      printf("Division durch null: nicht erlaubt!\n");
    }
    break;
  default:
    printf("Falsche Eingabe!\n");
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,-0x3c(%rbp)
mov    %eax,%esi
call   1030 <setbuf@plt>
mov    -0x3c(%rbp),%eax
lea    0xeb2(%rip),%rdi
mov    %al,-0x29(%rbp)
call   1040 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xeca(%rip),%rdi
call   1040 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xeec(%rip),%rdi
call   1040 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xefa(%rip),%rdi
call   1040 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xf0c(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x29(%rbp),%al
lea    0xefc(%rip),%rdi
call   1040 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xf0e(%rip),%rdi
mov    %rdi,-0x38(%rbp)
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x29(%rbp),%al
lea    0xefb(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x29(%rbp),%al
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x4,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x3,%eax
ja     12bf <main+0x18f>
mov    -0x28(%rbp),%rax
lea    0xdee(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
lea    0xec6(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    12cd <main+0x19d>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
lea    0xea9(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    12cd <main+0x19d>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
lea    0xe8c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    12cd <main+0x19d>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    128f <main+0x15f>
jp     128f <main+0x15f>
jmp    12ac <main+0x17c>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
lea    0xe61(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    12ba <main+0x18a>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12cd <main+0x19d>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d04(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1040 <setbuf@plt>
lea    0xf3d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf5a(%rip),%rdi
call   1030 <puts@plt>
lea    0xf7e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea3(%rip),%rdi
lea    0x1c(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea6(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x1c(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1205 <main+0xc5>
lea    0xe12(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
jmp    1228 <main+0xe8>
lea    0xf26(%rip),%rdi
jmp    1264 <main+0x124>
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
jmp    1228 <main+0xe8>
movsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
lea    0xe4b(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    1269 <main+0x129>
movsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    124a <main+0x10a>
jnp    125d <main+0x11d>
movsd  0x10(%rsp),%xmm0
divsd  %xmm1,%xmm0
lea    0xe2e(%rip),%rdi
jmp    122f <main+0xef>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d68(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [42 x i8] c"Dieses Programm rechnet mit zwei Zahlen.\0A\00"
@.str.1 = [49 x i8] c"Bitte geben Sie die Art\0Ader Rechenoperation an:\0A\00"
@.str.2 = [29 x i8] c" 1 : +\0A 2 : -\0A 3 : *\0A 4 : /\0A\00"
@.str.3 = [33 x i8] c"Rechenoperation...............: \00"
@.str.4 = [3 x i8] c"%i\00"
@.str.5 = [33 x i8] c"Bitte die erste Zahl eingeben : \00"
@.str.6 = [4 x i8] c"%lf\00"
@.str.7 = [33 x i8] c"Bitte die zweite Zahl eingeben: \00"
@.str.8 = [15 x i8] c"Ergebnis: %lf\0A\00"
@.str.9 = [16 x i8] c"Ergebnis: %.lf\0A\00"
@.str.10 = [37 x i8] c"Division durch null: nicht erlaubt!\0A\00"
@.str.11 = [18 x i8] c"Falsche Eingabe!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store i32 0, i32* %1
%6 = load i32, i32* @stdout
%7 = call i32 @setbuf(i32 %6, i32* null)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %3)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %4)
store i32 4, i32* %5
%17 = load i32, i32* %2
switch i32 %17, label %44 [
i32 1, label %18
i32 2, label %23
i32 3, label %28
i32 4, label %33
]
18: ; preds = %0
%19 = load double, double* %3
%20 = load double, double* %4
%21 = fadd double %19, %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), double %21)
br label %46
23: ; preds = %0
%24 = load double, double* %3
%25 = load double, double* %4
%26 = fsub double %24, %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), double %26)
br label %46
28: ; preds = %0
%29 = load double, double* %3
%30 = load double, double* %4
%31 = fmul double %29, %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), double %31)
br label %46
33: ; preds = %0
%34 = load double, double* %4
%35 = fcmp une double %34, 0.000000e+00
br i1 %35, label %36, label %41
36: ; preds = %33
%37 = load double, double* %3
%38 = load double, double* %4
%39 = fdiv double %37, %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), double %39)
br label %43
41: ; preds = %33
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0))
br label %43
43: ; preds = %41, %36
br label %46
44: ; preds = %0
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
br label %46
46: ; preds = %44, %43, %28, %23, %18
%47 = load i32, i32* @EXIT_SUCCESS
ret i32 %47
}

LLVM IR (-O2):
@stdout = global i32 0
@.str.3 = [33 x i8] c"Rechenoperation...............: \00"
@.str.4 = [3 x i8] c"%i\00"
@.str.5 = [33 x i8] c"Bitte die erste Zahl eingeben : \00"
@.str.6 = [4 x i8] c"%lf\00"
@.str.7 = [33 x i8] c"Bitte die zweite Zahl eingeben: \00"
@.str.8 = [15 x i8] c"Ergebnis: %lf\0A\00"
@.str.9 = [16 x i8] c"Ergebnis: %.lf\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [41 x i8] c"Dieses Programm rechnet mit zwei Zahlen.\00"
@str.12 = [48 x i8] c"Bitte geben Sie die Art\0Ader Rechenoperation an:\00"
@str.13 = [28 x i8] c" 1 : +\0A 2 : -\0A 3 : *\0A 4 : /\00"
@str.14 = [36 x i8] c"Division durch null: nicht erlaubt!\00"
@str.15 = [17 x i8] c"Falsche Eingabe!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = load i32, i32* @stdout
%5 = tail call i32 @setbuf(i32 %4, i32* null)
%6 = bitcast i32* %1 to i8*
%7 = bitcast double* %2 to i8*
%8 = bitcast double* %3 to i8*
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.12, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.13, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %2)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %3)
%18 = load i32, i32* %1
switch i32 %18, label %43 [
i32 1, label %19
i32 2, label %24
i32 3, label %29
i32 4, label %34
]
19: ; preds = %0
%20 = load double, double* %2
%21 = load double, double* %3
%22 = fadd double %20, %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), double %22)
br label %45
24: ; preds = %0
%25 = load double, double* %2
%26 = load double, double* %3
%27 = fsub double %25, %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), double %27)
br label %45
29: ; preds = %0
%30 = load double, double* %2
%31 = load double, double* %3
%32 = fmul double %30, %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), double %32)
br label %45
34: ; preds = %0
%35 = load double, double* %3
%36 = fcmp une double %35, 0.000000e+00
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = load double, double* %2
%39 = fdiv double %38, %35
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), double %39)
br label %45
41: ; preds = %34
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.14, i64 0, i64 0))
br label %45
43: ; preds = %0
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.15, i64 0, i64 0))
br label %45
45: ; preds = %37, %41, %43, %29, %24, %19
%46 = load i32, i32* @EXIT_SUCCESS
ret i32 %46
}