#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 */
double mindiv(double, double);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, double *, double *);
int main(void) {
  double a, b;
  printf("Enter a\&b:\n");
  while (scanf("%lf%lf", &a, &b) == 2) {
    printf("%.3g - %.3g / %.3g * %.3g = %.3g .\n", a, b, a, b, mindiv(a, b));
    printf("\n");
    printf("Enter a\&b:\n");
  }
  printf("done!");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    11e7 <main+0xb7>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <mindiv@plt>
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movaps %xmm0,%xmm4
movsd  -0x20(%rbp),%xmm0
lea    0xe54(%rip),%rdi
mov    $0x5,%al
call   1040 <printf@plt>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    114d <main+0x1d>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xecd(%rip),%rdi
call   1040 <puts@plt>
lea    0xe90(%rip),%rdi
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
call   1070 <scanf@plt>
cmp    $0x2,%eax
jne    1200 <main+0xb0>
lea    0xe7e(%rip),%r14
lea    0xea1(%rip),%r15
lea    0xe69(%rip),%r12
lea    0x8(%rsp),%r13
mov    %rsp,%rbx
nop
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
call   1050 <mindiv@plt>
movaps %xmm0,%xmm4
mov    %r14,%rdi
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movaps %xmm0,%xmm2
movaps %xmm1,%xmm3
mov    $0x5,%al
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1070 <scanf@plt>
cmp    $0x2,%eax
je     11a0 <main+0x50>
lea    0xe24(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Enter a&b:\0A\00"
@.str.1 = [7 x i8] c"%lf%lf\00"
@.str.2 = [36 x i8] c"%.3g - %.3g / %.3g * %.3g = %.3g .\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [6 x i8] c"done!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %8, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double* %2, double* %3)
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %19
8: ; preds = %5
%9 = load double, double* %2
%10 = load double, double* %3
%11 = load double, double* %2
%12 = load double, double* %3
%13 = load double, double* %2
%14 = load double, double* %3
%15 = call double @mindiv(double %13, double %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), double %9, double %10, double %11, double %12, double %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %5
19: ; preds = %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%lf%lf\00"
@.str.2 = [36 x i8] c"%.3g - %.3g / %.3g * %.3g = %.3g .\0A\00"
@.str.4 = [6 x i8] c"done!\00"
@str.5 = [11 x i8] c"Enter a&b:\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = bitcast double* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.5, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double* %1, double* %2)
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %17
8: ; preds = %0, %8
%9 = load double, double* %1
%10 = load double, double* %2
%11 = call double @mindiv(double %9, double %10)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), double %9, double %10, double %9, double %10, double %11)
%13 = call i32 @putchar(i32 10)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.5, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double* %1, double* %2)
%16 = icmp eq i32 %15, 2
br i1 %16, label %8, label %17
17: ; preds = %8, %0
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}