#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 EXIT_FAILURE;
int EXIT_SUCCESS;
double atof(char *);
int /*<<< orphan*/ printf(char *, double, double);
double sqrt(double);
int main(int argc, char *argv[]) {
  double val;
  if (argc != 2) {
    return EXIT_FAILURE;
  }
  val = atof(argv[1]);
  printf("The square root of %f is: %f\n", val, sqrt(val));
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1161 <main+0x31>
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a7 <main+0x77>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jne    1153 <main+0x23>
mov    0x8(%rsi),%rdi
call   1030 <atof@plt>
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jb     115c <main+0x2c>
sqrtsd %xmm2,%xmm1
jmp    1173 <main+0x43>
mov    0x2e86(%rip),%rax
jmp    118a <main+0x5a>
movapd %xmm2,%xmm0
movsd  %xmm2,(%rsp)
call   1050 <sqrt@plt>
movsd  (%rsp),%xmm2
movapd %xmm0,%xmm1
lea    0xe86(%rip),%rdi
movapd %xmm2,%xmm0
call   1040 <printf@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [30 x i8] c"The square root of %f is: %f\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load i32, i32* @EXIT_FAILURE
store i32 %10, i32* %3
br label %21
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call double @atof(i8* %14)
store double %15, double* %6
%16 = load double, double* %6
%17 = load double, double* %6
%18 = call double @sqrt(double %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), double %16, double %18)
%20 = load i32, i32* @EXIT_SUCCESS
store i32 %20, i32* %3
br label %21
21: ; preds = %11, %9
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [30 x i8] c"The square root of %f is: %f\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call double @atof(i8* %6)
%8 = tail call double @sqrt(double %7)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), double %7, double %8)
br label %10
10: ; preds = %2, %4
%11 = phi i32* [ @EXIT_SUCCESS, %4 ], [ @EXIT_FAILURE, %2 ]
%12 = load i32, i32* %11
ret i32 %12
}