#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 func(double, double);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, double *);
int main(void) {
  double first, second;
  printf("Enter your first float number (q to exit):\n");
  while (scanf("%lf", &first) == 1) {
    printf("Enter your second float number (q to exit):\n");
    while (scanf("%lf", &second) == 1) {
      printf("The result is %f\n", func(first, second));
      break;
    }
    printf("Enter your first float number (q to exit):\n");
  }
  printf("Thank you!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11bd <main+0x8d>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11aa <main+0x7a>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <func@plt>
lea    0xeba(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114d <main+0x1d>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xef8(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    11ed <main+0xad>
lea    0xeaa(%rip),%r14
lea    0xe82(%rip),%rbx
lea    0x10(%rsp),%r15
lea    0xe7a(%rip),%r12
lea    0xebc(%rip),%r13
lea    0x8(%rsp),%rbp
jmp    11b8 <main+0x78>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    11ed <main+0xad>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    11a0 <main+0x60>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1050 <func@plt>
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11a0 <main+0x60>
lea    0xe22(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Enter your first float number (q to exit):\0A\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [45 x i8] c"Enter your second float number (q to exit):\0A\00"
@.str.3 = [18 x i8] c"The result is %f\0A\00"
@.str.4 = [12 x i8] c"Thank you!\0A\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 ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %18, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %8
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load double, double* %2
%15 = load double, double* %3
%16 = call double @func(double %14, double %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), double %16)
br label %18
18: ; preds = %13, %10
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %5
20: ; preds = %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%lf\00"
@.str.3 = [18 x i8] c"The result is %f\0A\00"
@str.5 = [11 x i8] c"Thank you!\00"
@str.6 = [44 x i8] c"Enter your second float number (q to exit):\00"
@str.7 = [43 x i8] c"Enter your first float number (q to exit):\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 ([43 x i8], [43 x i8]* @str.7, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %21
8: ; preds = %0, %17
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.6, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = load double, double* %1
%14 = load double, double* %2
%15 = call double @func(double %13, double %14)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), double %15)
br label %17
17: ; preds = %12, %8
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.7, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%20 = icmp eq i32 %19, 1
br i1 %20, label %8, label %21
21: ; preds = %17, %0
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.5, i64 0, i64 0))
ret i32 0
}