#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 /*<<< orphan*/ scanf(char *, double *);
int /*<<< orphan*/ sqrt(double);
int main(void) {
  double value;
  do {
    printf("input a number, negative to quit:");
    scanf("%lf", &value);
    if (value < 0)
      break;
    printf("the sqrt(%.2lf)=%.2lf\n", value, sqrt(value));
  } while (1);
  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    0xece(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1170 <main+0x40>
jmp    11a8 <main+0x78>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  -0x18(%rbp),%xmm0
mov    %eax,%esi
lea    0xe94(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%al
test   $0x1,%al
jne    113f <main+0xf>
jmp    11a8 <main+0x78>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     11d2 <main+0xa2>
lea    0xeb5(%rip),%r14
lea    0xe88(%rip),%r15
lea    0xea3(%rip),%r12
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm0,0x10(%rsp)
call   1050 <sqrt@plt>
mov    %r14,%rdi
movsd  0x10(%rsp),%xmm0
mov    %eax,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
xorpd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm0
ucomisd %xmm0,%xmm1
jbe    1190 <main+0x60>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [34 x i8] c"input a number, negative to quit:\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [23 x i8] c"the sqrt(%.2lf)=%.2lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
store i32 0, i32* %1
br label %3
3: ; preds = %14, %0
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%6 = load double, double* %2
%7 = fcmp olt double %6, 0.000000e+00
br i1 %7, label %8, label %9
8: ; preds = %3
br label %15
9: ; preds = %3
%10 = load double, double* %2
%11 = load double, double* %2
%12 = call i32 @sqrt(double %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %10, i32 %12)
br label %14
14: ; preds = %9
br i1 true, label %3, label %15
15: ; preds = %14, %8
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"input a number, negative to quit:\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [23 x i8] c"the sqrt(%.2lf)=%.2lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = load double, double* %1
%6 = fcmp olt double %5, 0.000000e+00
br i1 %6, label %15, label %7
7: ; preds = %0, %7
%8 = phi double [ %13, %7 ], [ %5, %0 ]
%9 = call i32 @sqrt(double %8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %8, i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%13 = load double, double* %1
%14 = fcmp olt double %13, 0.000000e+00
br i1 %14, label %15, label %7
15: ; preds = %7, %0
ret i32 0
}