#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*/ clear_s();
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, ...);
int f_calculate(int i) {
  printf("\nInput the formated triad :\n");
  float n;
  float n1;
  char c1;
  char c2;
  char c3;
  float n2;
  int sn1 = 0;
  int sc1 = 0;
  int sc2 = 0;
  int sc3 = 0;
  int sn2 = 0;
  int r = 0;
  int ix = 0;
  char chr;
  if (scanf(" %f", &n1) == 1) {
    sn1 = 1;
  }
  if (scanf("%c", &c1) == 1) {
    sc1 = 1;
  }
  if (scanf("%c", &c2) == 1) {
    sc2 = 1;
  }
  if (scanf("%c", &c3) == 1) {
    sc3 = 1;
  }
  if (scanf("%f", &n2) == 1) {
    sn2 = 1;
  }
  if (sn1 == 1 && sc1 == 1 && c1 == ' ' && sc2 == 1 && sc3 == 1 && c3 == ' ' &&
      sn2 == 1) {
    if (c2 == '+') {
      n = n1 + n2;
      printf("Result of addition is : %f\n", n);
    } else if (c2 == '-') {
      n = n1 - n2;
      printf("Result of deduction is : %f\n", n);
    } else if (c2 == '*') {
      n = n1 * n2;
      printf("Result of multiplication is : %f\n", n);
    } else if (c2 == '/') {
      if (n2 != 0) {
        n = n1 / n2;
        printf("Result of division is : %f\n", n);
      } else {
        printf("Division cant be done (nothing can be divided by zero)\n");
      }
    } else {
      printf("Error! Wrong formula!\n");
    }
  } else {
    printf("\n Input error!\n");
  }
  clear_s();
  while (ix == 0) {
    printf("Do you want to continue the program (y/n) ? ");
    if (scanf(" %c", &chr) == 1) {
      if (chr == 'y') {
        ix = 1;
        printf("OK\n");
      } else if (chr == 'n') {
        printf("Thanks for using this program!");
        printf("EAP/Exercise 1/ Theme 1.");
        r = 1;
        ix = 1;
      }
    }
  }
  return r;
}


x86 assembly (clang, -O0):
<f_calculate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
lea    0xe9c(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    119c <f_calculate+0x6c>
movl   $0x1,-0x18(%rbp)
lea    0xf82(%rip),%rdi
lea    -0xd(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11be <f_calculate+0x8e>
movl   $0x1,-0x1c(%rbp)
lea    0xf60(%rip),%rdi
lea    -0xe(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11e0 <f_calculate+0xb0>
movl   $0x1,-0x20(%rbp)
lea    0xf3e(%rip),%rdi
lea    -0xf(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1202 <f_calculate+0xd2>
movl   $0x1,-0x24(%rbp)
lea    0xe15(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1224 <f_calculate+0xf4>
movl   $0x1,-0x28(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    13a1 <f_calculate+0x271>
cmpl   $0x1,-0x1c(%rbp)
jne    13a1 <f_calculate+0x271>
movsbl -0xd(%rbp),%eax
cmp    $0x20,%eax
jne    13a1 <f_calculate+0x271>
cmpl   $0x1,-0x20(%rbp)
jne    13a1 <f_calculate+0x271>
cmpl   $0x1,-0x24(%rbp)
jne    13a1 <f_calculate+0x271>
movsbl -0xf(%rbp),%eax
cmp    $0x20,%eax
jne    13a1 <f_calculate+0x271>
cmpl   $0x1,-0x28(%rbp)
jne    13a1 <f_calculate+0x271>
movsbl -0xe(%rbp),%eax
cmp    $0x2b,%eax
jne    12a8 <f_calculate+0x178>
movss  -0xc(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd85(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    139c <f_calculate+0x26c>
movsbl -0xe(%rbp),%eax
cmp    $0x2d,%eax
jne    12e0 <f_calculate+0x1b0>
movss  -0xc(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd69(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1397 <f_calculate+0x267>
movsbl -0xe(%rbp),%eax
cmp    $0x2a,%eax
jne    1318 <f_calculate+0x1e8>
movss  -0xc(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd4e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1392 <f_calculate+0x262>
movsbl -0xe(%rbp),%eax
cmp    $0x2f,%eax
jne    137f <f_calculate+0x24f>
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1341 <f_calculate+0x211>
jp     1341 <f_calculate+0x211>
jmp    136c <f_calculate+0x23c>
movss  -0xc(%rbp),%xmm0
divss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd1c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    137a <f_calculate+0x24a>
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    138d <f_calculate+0x25d>
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1392 <f_calculate+0x262>
jmp    1397 <f_calculate+0x267>
jmp    139c <f_calculate+0x26c>
jmp    13af <f_calculate+0x27f>
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clear_s@plt>
cmpl   $0x0,-0x30(%rbp)
jne    1456 <f_calculate+0x326>
lea    0xd30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd4f(%rip),%rdi
lea    -0x31(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1451 <f_calculate+0x321>
movsbl -0x31(%rbp),%eax
cmp    $0x79,%eax
jne    1410 <f_calculate+0x2e0>
movl   $0x1,-0x30(%rbp)
lea    0xd24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    144c <f_calculate+0x31c>
movsbl -0x31(%rbp),%eax
cmp    $0x6e,%eax
jne    1447 <f_calculate+0x317>
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    144c <f_calculate+0x31c>
jmp    1451 <f_calculate+0x321>
jmp    13b6 <f_calculate+0x286>
mov    -0x2c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_calculate>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xfab(%rip),%rdi
call   1040 <puts@plt>
lea    0xebb(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %eax,%r14d
lea    0xf4e(%rip),%rbp
lea    0xf(%rsp),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %eax,%r15d
lea    0xe(%rsp),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %eax,%ebx
lea    0xd(%rsp),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %eax,%ebp
lea    0xe6b(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1219 <f_calculate+0xd9>
cmp    $0x1,%ebp
jne    1219 <f_calculate+0xd9>
cmp    $0x1,%ebx
jne    1219 <f_calculate+0xd9>
cmp    $0x1,%r14d
jne    1219 <f_calculate+0xd9>
cmp    $0x1,%r15d
jne    1219 <f_calculate+0xd9>
cmpb   $0x20,0xf(%rsp)
jne    1219 <f_calculate+0xd9>
cmpb   $0x20,0xd(%rsp)
jne    1219 <f_calculate+0xd9>
mov    0xe(%rsp),%al
add    $0xd6,%al
cmp    $0x5,%al
ja     1240 <f_calculate+0x100>
movzbl %al,%eax
lea    0xe09(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  0x14(%rsp),%xmm0
mulss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe3e(%rip),%rdi
jmp    128e <f_calculate+0x14e>
lea    0xef8(%rip),%rdi
call   1040 <puts@plt>
jmp    1295 <f_calculate+0x155>
movss  0x14(%rsp),%xmm0
addss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdde(%rip),%rdi
jmp    128e <f_calculate+0x14e>
lea    0xee3(%rip),%rdi
jmp    1220 <f_calculate+0xe0>
movss  0x14(%rsp),%xmm0
subss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdd8(%rip),%rdi
jmp    128e <f_calculate+0x14e>
movss  0x10(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1276 <f_calculate+0x136>
jnp    1315 <f_calculate+0x1d5>
movss  0x14(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xde9(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <clear_s@plt>
lea    0xdf0(%rip),%r14
lea    0xe16(%rip),%rbp
lea    0xc(%rsp),%rbx
nop
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    12b0 <f_calculate+0x170>
movzbl 0xc(%rsp),%eax
cmp    $0x6e,%al
je     12e9 <f_calculate+0x1a9>
cmp    $0x79,%al
jne    12b0 <f_calculate+0x170>
lea    0xe47(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
jmp    130a <f_calculate+0x1ca>
lea    0xdd4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xde5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe24(%rip),%rdi
jmp    1220 <f_calculate+0xe0>

LLVM IR (-O0):
@.str = [29 x i8] c"\0AInput the formated triad :\0A\00"
@.str.1 = [4 x i8] c" %f\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [28 x i8] c"Result of addition is : %f\0A\00"
@.str.5 = [29 x i8] c"Result of deduction is : %f\0A\00"
@.str.6 = [34 x i8] c"Result of multiplication is : %f\0A\00"
@.str.7 = [28 x i8] c"Result of division is : %f\0A\00"
@.str.8 = [56 x i8] c"Division cant be done (nothing can be divided by zero)\0A\00"
@.str.9 = [23 x i8] c"Error! Wrong formula!\0A\00"
@.str.10 = [16 x i8] c"\0A Input error!\0A\00"
@.str.11 = [45 x i8] c"Do you want to continue the program (y/n) ? \00"
@.str.12 = [4 x i8] c" %c\00"
@.str.13 = [4 x i8] c"OK\0A\00"
@.str.14 = [31 x i8] c"Thanks for using this program!\00"
@.str.15 = [25 x i8] c"EAP/Exercise 1/ Theme 1.\00"
define i32 @f_calculate(i32 %0) {
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca float
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8
store i32 %0, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float* %4)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %21
20: ; preds = %1
store i32 1, i32* %9
br label %21
21: ; preds = %20, %1
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 1, i32* %10
br label %25
25: ; preds = %24, %21
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 1, i32* %11
br label %29
29: ; preds = %28, %25
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %33
32: ; preds = %29
store i32 1, i32* %12
br label %33
33: ; preds = %32, %29
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %8)
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %37
36: ; preds = %33
store i32 1, i32* %13
br label %37
37: ; preds = %36, %33
%38 = load i32, i32* %9
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %116
40: ; preds = %37
%41 = load i32, i32* %10
%42 = icmp eq i32 %41, 1
br i1 %42, label %43, label %116
43: ; preds = %40
%44 = load i8, i8* %5
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 32
br i1 %46, label %47, label %116
47: ; preds = %43
%48 = load i32, i32* %11
%49 = icmp eq i32 %48, 1
br i1 %49, label %50, label %116
50: ; preds = %47
%51 = load i32, i32* %12
%52 = icmp eq i32 %51, 1
br i1 %52, label %53, label %116
53: ; preds = %50
%54 = load i8, i8* %7
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 32
br i1 %56, label %57, label %116
57: ; preds = %53
%58 = load i32, i32* %13
%59 = icmp eq i32 %58, 1
br i1 %59, label %60, label %116
60: ; preds = %57
%61 = load i8, i8* %6
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 43
br i1 %63, label %64, label %71
64: ; preds = %60
%65 = load float, float* %4
%66 = load float, float* %8
%67 = fadd float %65, %66
store float %67, float* %3
%68 = load float, float* %3
%69 = fpext float %68 to double
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), double %69)
br label %115
71: ; preds = %60
%72 = load i8, i8* %6
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 45
br i1 %74, label %75, label %82
75: ; preds = %71
%76 = load float, float* %4
%77 = load float, float* %8
%78 = fsub float %76, %77
store float %78, float* %3
%79 = load float, float* %3
%80 = fpext float %79 to double
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), double %80)
br label %114
82: ; preds = %71
%83 = load i8, i8* %6
%84 = sext i8 %83 to i32
%85 = icmp eq i32 %84, 42
br i1 %85, label %86, label %93
86: ; preds = %82
%87 = load float, float* %4
%88 = load float, float* %8
%89 = fmul float %87, %88
store float %89, float* %3
%90 = load float, float* %3
%91 = fpext float %90 to double
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), double %91)
br label %113
93: ; preds = %82
%94 = load i8, i8* %6
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 47
br i1 %96, label %97, label %110
97: ; preds = %93
%98 = load float, float* %8
%99 = fcmp une float %98, 0.000000e+00
br i1 %99, label %100, label %107
100: ; preds = %97
%101 = load float, float* %4
%102 = load float, float* %8
%103 = fdiv float %101, %102
store float %103, float* %3
%104 = load float, float* %3
%105 = fpext float %104 to double
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %105)
br label %109
107: ; preds = %97
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0))
br label %109
109: ; preds = %107, %100
br label %112
110: ; preds = %93
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0))
br label %112
112: ; preds = %110, %109
br label %113
113: ; preds = %112, %86
br label %114
114: ; preds = %113, %75
br label %115
115: ; preds = %114, %64
br label %118
116: ; preds = %57, %53, %50, %47, %43, %40, %37
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
br label %118
118: ; preds = %116, %115
%119 = call i32 (...) @clear_s()
br label %120
120: ; preds = %142, %118
%121 = load i32, i32* %15
%122 = icmp eq i32 %121, 0
br i1 %122, label %123, label %143
123: ; preds = %120
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0))
%125 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* %16)
%126 = icmp eq i32 %125, 1
br i1 %126, label %127, label %142
127: ; preds = %123
%128 = load i8, i8* %16
%129 = sext i8 %128 to i32
%130 = icmp eq i32 %129, 121
br i1 %130, label %131, label %133
131: ; preds = %127
store i32 1, i32* %15
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0))
br label %141
133: ; preds = %127
%134 = load i8, i8* %16
%135 = sext i8 %134 to i32
%136 = icmp eq i32 %135, 110
br i1 %136, label %137, label %140
137: ; preds = %133
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0))
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0))
store i32 1, i32* %14
store i32 1, i32* %15
br label %140
140: ; preds = %137, %133
br label %141
141: ; preds = %140, %131
br label %142
142: ; preds = %141, %123
br label %120
143: ; preds = %120
%144 = load i32, i32* %14
ret i32 %144
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c" %f\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [28 x i8] c"Result of addition is : %f\0A\00"
@.str.5 = [29 x i8] c"Result of deduction is : %f\0A\00"
@.str.6 = [34 x i8] c"Result of multiplication is : %f\0A\00"
@.str.7 = [28 x i8] c"Result of division is : %f\0A\00"
@.str.11 = [45 x i8] c"Do you want to continue the program (y/n) ? \00"
@.str.12 = [4 x i8] c" %c\00"
@.str.14 = [31 x i8] c"Thanks for using this program!\00"
@.str.15 = [25 x i8] c"EAP/Exercise 1/ Theme 1.\00"
@str = [28 x i8] c"\0AInput the formated triad :\00"
@str.16 = [15 x i8] c"\0A Input error!\00"
@str.17 = [3 x i8] c"OK\00"
@str.18 = [22 x i8] c"Error! Wrong formula!\00"
@str.19 = [55 x i8] c"Division cant be done (nothing can be divided by zero)\00"
define i32 @f_calculate(i32 %0) {
%2 = alloca float
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = alloca float
%7 = alloca i8
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%9 = bitcast float* %2 to i8*
%10 = bitcast float* %6 to i8*
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float* %2)
%12 = icmp eq i32 %11, 1
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%14 = icmp eq i32 %13, 1
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%16 = icmp eq i32 %15, 1
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%18 = icmp eq i32 %17, 1
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %6)
%20 = icmp eq i32 %19, 1
%21 = and i1 %12, %14
%22 = load i8, i8* %3
%23 = icmp eq i8 %22, 32
%24 = select i1 %21, i1 %23, i1 false
%25 = and i1 %16, %24
%26 = and i1 %18, %25
%27 = load i8, i8* %5
%28 = icmp eq i8 %27, 32
%29 = select i1 %26, i1 %28, i1 false
%30 = and i1 %20, %29
br i1 %30, label %31, label %63
31: ; preds = %1
%32 = load i8, i8* %4
switch i8 %32, label %61 [
i8 43, label %33
i8 45, label %39
i8 42, label %45
i8 47, label %51
]
33: ; preds = %31
%34 = load float, float* %2
%35 = load float, float* %6
%36 = fadd float %34, %35
%37 = fpext float %36 to double
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), double %37)
br label %65
39: ; preds = %31
%40 = load float, float* %2
%41 = load float, float* %6
%42 = fsub float %40, %41
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), double %43)
br label %65
45: ; preds = %31
%46 = load float, float* %2
%47 = load float, float* %6
%48 = fmul float %46, %47
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), double %49)
br label %65
51: ; preds = %31
%52 = load float, float* %6
%53 = fcmp une float %52, 0.000000e+00
br i1 %53, label %54, label %59
54: ; preds = %51
%55 = load float, float* %2
%56 = fdiv float %55, %52
%57 = fpext float %56 to double
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %57)
br label %65
59: ; preds = %51
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.19, i64 0, i64 0))
br label %65
61: ; preds = %31
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.18, i64 0, i64 0))
br label %65
63: ; preds = %1
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.16, i64 0, i64 0))
br label %65
65: ; preds = %33, %45, %54, %59, %61, %39, %63
%66 = call i32 (...) @clear_s()
br label %67
67: ; preds = %73, %65
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0))
%69 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* %7)
%70 = icmp eq i32 %69, 1
br i1 %70, label %71, label %73
71: ; preds = %67
%72 = load i8, i8* %7
switch i8 %72, label %73 [
i8 121, label %74
i8 110, label %76
]
73: ; preds = %71, %67
br label %67
74: ; preds = %71
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.17, i64 0, i64 0))
br label %79
76: ; preds = %71
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0))
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0))
br label %79
79: ; preds = %74, %76
%80 = phi i32 [ 1, %76 ], [ 0, %74 ]
ret i32 %80
}