#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 scanf(char *, double *, double *, char *);
int /*<<< orphan*/ sync();
void Div(void) {
  double valA = 0, valB = 0;
  char end_symbol = 0;
  int res = 0;
  printf("Input two values for division:\n");
  res = scanf("%lf %lf%c", &valA, &valB, &end_symbol);
  sync();
  if (end_symbol != '\n') {
    printf("Incorrect values\n");
    return;
  }
  if (valB == 0) {
    printf("%lf / %lf = Infinity\n", valA, valB);
    return;
  }
  printf("%lf / %lf = %lf\n", valA, valB, valA / valB);
  return;
}


x86 assembly (clang, -O0):
<Div>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x11(%rbp),%rcx
call   1050 <scanf@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <sync@plt>
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
je     11a3 <Div+0x73>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fa <Div+0xca>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11d8 <Div+0xa8>
jp     11d8 <Div+0xa8>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xe70(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    11fa <Div+0xca>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
divsd  -0x10(%rbp),%xmm2
lea    0xe5f(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Div>:
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
movb   $0x0,0x7(%rsp)
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x7(%rsp),%rcx
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <sync@plt>
cmpb   $0xa,0x7(%rsp)
jne    11bb <Div+0x7b>
movsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
jne    11cc <Div+0x8c>
jp     11cc <Div+0x8c>
lea    0xe5b(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
add    $0x18,%rsp
ret
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
add    $0x18,%rsp
ret
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
lea    0xe45(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Input two values for division:\0A\00"
@.str.1 = [10 x i8] c"%lf %lf%c\00"
@.str.2 = [18 x i8] c"Incorrect values\0A\00"
@.str.3 = [22 x i8] c"%lf / %lf = Infinity\0A\00"
@.str.4 = [17 x i8] c"%lf / %lf = %lf\0A\00"
define void @Div() {
%1 = alloca double
%2 = alloca double
%3 = alloca i8
%4 = alloca i32
store double 0.000000e+00, double* %1
store double 0.000000e+00, double* %2
store i8 0, i8* %3
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double* %1, double* %2, i8* %3)
store i32 %6, i32* %4
%7 = call i32 (...) @sync()
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 10
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %27
13: ; preds = %0
%14 = load double, double* %2
%15 = fcmp oeq double %14, 0.000000e+00
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load double, double* %1
%18 = load double, double* %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), double %17, double %18)
br label %27
20: ; preds = %13
%21 = load double, double* %1
%22 = load double, double* %2
%23 = load double, double* %1
%24 = load double, double* %2
%25 = fdiv double %23, %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %21, double %22, double %25)
br label %27
27: ; preds = %20, %16, %11
ret void
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"%lf %lf%c\00"
@.str.3 = [22 x i8] c"%lf / %lf = Infinity\0A\00"
@.str.4 = [17 x i8] c"%lf / %lf = %lf\0A\00"
@str = [31 x i8] c"Input two values for division:\00"
@str.5 = [17 x i8] c"Incorrect values\00"
define void @Div() {
%1 = alloca double
%2 = alloca double
%3 = alloca i8
%4 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
%5 = bitcast double* %2 to i8*
store double 0.000000e+00, double* %2
store i8 0, i8* %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double* %1, double* %2, i8* %3)
%8 = call i32 (...) @sync()
%9 = load i8, i8* %3
%10 = icmp eq i8 %9, 10
br i1 %10, label %13, label %11
11: ; preds = %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.5, i64 0, i64 0))
br label %22
13: ; preds = %0
%14 = load double, double* %2
%15 = fcmp oeq double %14, 0.000000e+00
%16 = load double, double* %1
br i1 %15, label %17, label %19
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), double %16, double %14)
br label %22
19: ; preds = %13
%20 = fdiv double %16, %14
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %16, double %14, double %20)
br label %22
22: ; preds = %19, %17, %11
ret void
}