#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*/ sqrtByReference(double *);
int /*<<< orphan*/ sqrtByValue(double);
int main() {
  double n = 21.0;
  printf("val of n is %f\n", n);
  sqrtByValue(n);
  printf("val of n is %f\n", n);
  sqrtByReference(&n);
  printf("val of n is %f\n", n);
  printf("Value has been changed!");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  0xec0(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    0xeb7(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x8(%rbp),%xmm0
call   1040 <sqrtByValue@plt>
movsd  -0x8(%rbp),%xmm0
lea    0xe9a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    -0x8(%rbp),%rdi
call   1050 <sqrtByReference@plt>
movsd  -0x8(%rbp),%xmm0
lea    0xe7e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movabs $0x4035000000000000,%rax
mov    %rax,0x8(%rsp)
lea    0xebd(%rip),%rbx
movsd  0xead(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe9b(%rip),%xmm0
call   1040 <sqrtByValue@plt>
mov    %rbx,%rdi
movsd  0xe8b(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0x8(%rsp),%rdi
call   1050 <sqrtByReference@plt>
movsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"val of n is %f\0A\00"
@.str.1 = [24 x i8] c"Value has been changed!\00"
define i32 @main() {
%1 = alloca double
store double 2.100000e+01, double* %1
%2 = load double, double* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %2)
%4 = load double, double* %1
%5 = call i32 @sqrtByValue(double %4)
%6 = load double, double* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %6)
%8 = call i32 @sqrtByReference(double* %1)
%9 = load double, double* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"val of n is %f\0A\00"
@.str.1 = [24 x i8] c"Value has been changed!\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
store double 2.100000e+01, double* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double 2.100000e+01)
%4 = tail call i32 @sqrtByValue(double 2.100000e+01)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double 2.100000e+01)
%6 = call i32 @sqrtByReference(double* %1)
%7 = load double, double* %1
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %7)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}