#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 */
typedef int uint8_t;

/* Variables and functions */
double bit_array_to_double_diy_big(int *);
double bit_array_to_double_native(int *);
int detect_endian();
double log(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int /*<<< orphan*/ show(double, char *);
double sqrt(int);
int main() {
  int detect = detect_endian();
  printf("Detect endianness of your PC's architecture: %s\n\n",
         detect == 0 ? "undefined (force little endian)"
                     : (detect == 1 ? "little-endian" : "big-endian"));
  show(sqrt(-1), "sqrt(-1)");
  double t = 0.;
  show(1. / t, "1/0");
  show(log(0), "log(0)");
  show(0.0, "0.0");
  show(-0.0, "-0.0");
  show(1.0, "1.0");
  show(0.1, "0.1");
  printf("The smallest positive number\n");
  uint8_t min_pos[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
  show(bit_array_to_double_native(min_pos), "native converter from bit array");
  show(bit_array_to_double_diy_big(min_pos), "diy converter from bit array");
  printf("The smallest positive number greater than 1\n");
  uint8_t min_gt_1_pos[] = {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
                            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
  show(bit_array_to_double_native(min_gt_1_pos),
       "native converter from bit array");
  show(bit_array_to_double_diy_big(min_gt_1_pos),
       "diy converter from bit array");
  double f;
  printf("Enter a double: ");
  scanf("%lf", &f);
  show(f, "user's input");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <detect_endian@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11d9 <main+0x39>
lea    0xe7d(%rip),%rax
mov    %rax,-0x220(%rbp)
jmp    11f8 <main+0x58>
mov    -0x8(%rbp),%edx
lea    0xe95(%rip),%rax
lea    0xe80(%rip),%rcx
cmp    $0x1,%edx
cmove  %rcx,%rax
mov    %rax,-0x220(%rbp)
mov    -0x220(%rbp),%rsi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <sqrt@plt>
lea    0xe65(%rip),%rdi
call   1070 <show@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xdd5(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
lea    0xe4d(%rip),%rdi
call   1070 <show@plt>
xor    %edi,%edi
call   10b0 <log@plt>
lea    0xe3e(%rip),%rdi
call   1070 <show@plt>
xorps  %xmm0,%xmm0
lea    0xe37(%rip),%rdi
call   1070 <show@plt>
movsd  0xda2(%rip),%xmm0
lea    0xe22(%rip),%rdi
call   1070 <show@plt>
movsd  0xd86(%rip),%xmm0
lea    0xe13(%rip),%rdi
call   1070 <show@plt>
movsd  0xd6a(%rip),%xmm0
lea    0xe03(%rip),%rdi
call   1070 <show@plt>
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
movl   $0x1,-0x14(%rbp)
lea    -0x110(%rbp),%rdi
call   1090 <bit_array_to_double_native@plt>
lea    0xde5(%rip),%rdi
call   1070 <show@plt>
lea    -0x110(%rbp),%rdi
call   1050 <bit_array_to_double_diy_big@plt>
lea    0xded(%rip),%rdi
call   1070 <show@plt>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x210(%rbp),%rdi
lea    0xe3a(%rip),%rsi
mov    $0x100,%edx
call   1080 <memcpy@plt>
lea    -0x210(%rbp),%rdi
call   1090 <bit_array_to_double_native@plt>
lea    0xd8f(%rip),%rdi
call   1070 <show@plt>
lea    -0x210(%rbp),%rdi
call   1050 <bit_array_to_double_diy_big@plt>
lea    0xd97(%rip),%rdi
call   1070 <show@plt>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdd8(%rip),%rdi
lea    -0x218(%rbp),%rsi
call   10a0 <scanf@plt>
movsd  -0x218(%rbp),%xmm0
ff
lea    0xdc1(%rip),%rdi
call   1070 <show@plt>
xor    %eax,%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x210,%rsp
xor    %eax,%eax
call   1030 <detect_endian@plt>
cmp    $0x1,%eax
lea    0xeb5(%rip),%rcx
lea    0xebc(%rip),%rdx
cmove  %rcx,%rdx
test   %eax,%eax
lea    0xe81(%rip),%rsi
cmovne %rdx,%rsi
lea    0xe44(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <sqrt@plt>
lea    0xe97(%rip),%rdi
call   1070 <show@plt>
lea    0xe94(%rip),%rdi
movsd  0xdf8(%rip),%xmm0
call   1070 <show@plt>
xor    %edi,%edi
call   10b0 <log@plt>
lea    0xe7d(%rip),%rdi
call   1070 <show@plt>
lea    0xe79(%rip),%rdi
xorps  %xmm0,%xmm0
call   1070 <show@plt>
lea    0xe69(%rip),%rdi
movsd  0xdca(%rip),%xmm0
call   1070 <show@plt>
lea    0xe5a(%rip),%rdi
movsd  0xdbe(%rip),%xmm0
call   1070 <show@plt>
lea    0xe4a(%rip),%rdi
movsd  0xdb2(%rip),%xmm0
call   1070 <show@plt>
lea    0xe99(%rip),%rdi
call   1040 <puts@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x1,0x10c(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1090 <bit_array_to_double_native@plt>
lea    0xda8(%rip),%r14
mov    %r14,%rdi
call   1070 <show@plt>
mov    %rbx,%rdi
call   1060 <bit_array_to_double_diy_big@plt>
lea    0xdb1(%rip),%r15
mov    %r15,%rdi
call   1070 <show@plt>
lea    0xdfe(%rip),%rdi
call   1040 <puts@plt>
lea    0xe2a(%rip),%rsi
lea    0x110(%rsp),%rbx
mov    $0x100,%edx
mov    %rbx,%rdi
call   1080 <memcpy@plt>
mov    %rbx,%rdi
call   1090 <bit_array_to_double_native@plt>
mov    %r14,%rdi
call   1070 <show@plt>
mov    %rbx,%rdi
call   1060 <bit_array_to_double_diy_big@plt>
mov    %r15,%rdi
call   1070 <show@plt>
lea    0xd77(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd7a(%rip),%rdi
lea    0x8(%rsp),%rsi
call   10a0 <scanf@plt>
movsd  0x8(%rsp),%xmm0
lea    0xd67(%rip),%rdi
call   1070 <show@plt>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [50 x i8] c"Detect endianness of your PC's architecture: %s\0A\0A\00"
@.str.1 = [32 x i8] c"undefined (force little endian)\00"
@.str.2 = [14 x i8] c"little-endian\00"
@.str.3 = [11 x i8] c"big-endian\00"
@.str.4 = [9 x i8] c"sqrt(-1)\00"
@.str.5 = [4 x i8] c"1/0\00"
@.str.6 = [7 x i8] c"log(0)\00"
@.str.7 = [4 x i8] c"0.0\00"
@.str.8 = [5 x i8] c"-0.0\00"
@.str.9 = [4 x i8] c"1.0\00"
@.str.10 = [4 x i8] c"0.1\00"
@.str.11 = [30 x i8] c"The smallest positive number\0A\00"
@.str.12 = [32 x i8] c"native converter from bit array\00"
@.str.13 = [29 x i8] c"diy converter from bit array\00"
@.str.14 = [45 x i8] c"The smallest positive number greater than 1\0A\00"
@__const.main.min_gt_1_pos = [64 x i32] [i32 0, i32 0, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1]
@.str.15 = [17 x i8] c"Enter a double: \00"
@.str.16 = [4 x i8] c"%lf\00"
@.str.17 = [13 x i8] c"user's input\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca [64 x i32]
%5 = alloca [64 x i32]
%6 = alloca double
store i32 0, i32* %1
%7 = call i32 (...) @detect_endian()
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %0
br label %16
11: ; preds = %0
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 1
%14 = zext i1 %13 to i64
%15 = select i1 %13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0)
br label %16
16: ; preds = %11, %10
%17 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), %10 ], [ %15, %11 ]
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call double @sqrt(i32 -1)
%20 = call i32 @show(double %19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
store double 0.000000e+00, double* %3
%21 = load double, double* %3
%22 = fdiv double 1.000000e+00, %21
%23 = call i32 @show(double %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%24 = call double @log(i32 0)
%25 = call i32 @show(double %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%26 = call i32 @show(double 0.000000e+00, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%27 = call i32 @show(double -0.000000e+00, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%28 = call i32 @show(double 1.000000e+00, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%29 = call i32 @show(double 1.000000e-01, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0))
%31 = bitcast [64 x i32]* %4 to i8*
%32 = bitcast i8* %31 to [64 x i32]*
%33 = getelementptr inbounds [64 x i32], [64 x i32]* %32, i32 0, i32 63
store i32 1, i32* %33
%34 = getelementptr inbounds [64 x i32], [64 x i32]* %4, i64 0, i64 0
%35 = call double @bit_array_to_double_native(i32* %34)
%36 = call i32 @show(double %35, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.12, i64 0, i64 0))
%37 = getelementptr inbounds [64 x i32], [64 x i32]* %4, i64 0, i64 0
%38 = call double @bit_array_to_double_diy_big(i32* %37)
%39 = call i32 @show(double %38, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0))
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.14, i64 0, i64 0))
%41 = bitcast [64 x i32]* %5 to i8*
%42 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 0
%43 = call double @bit_array_to_double_native(i32* %42)
%44 = call i32 @show(double %43, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.12, i64 0, i64 0))
%45 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 0
%46 = call double @bit_array_to_double_diy_big(i32* %45)
%47 = call i32 @show(double %46, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0))
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.15, i64 0, i64 0))
%49 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0), double* %6)
%50 = load double, double* %6
%51 = call i32 @show(double %50, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [50 x i8] c"Detect endianness of your PC's architecture: %s\0A\0A\00"
@.str.1 = [32 x i8] c"undefined (force little endian)\00"
@.str.2 = [14 x i8] c"little-endian\00"
@.str.3 = [11 x i8] c"big-endian\00"
@.str.4 = [9 x i8] c"sqrt(-1)\00"
@.str.5 = [4 x i8] c"1/0\00"
@.str.6 = [7 x i8] c"log(0)\00"
@.str.7 = [4 x i8] c"0.0\00"
@.str.8 = [5 x i8] c"-0.0\00"
@.str.9 = [4 x i8] c"1.0\00"
@.str.10 = [4 x i8] c"0.1\00"
@.str.12 = [32 x i8] c"native converter from bit array\00"
@.str.13 = [29 x i8] c"diy converter from bit array\00"
@__const.main.min_gt_1_pos = [64 x i32] [i32 0, i32 0, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1]
@.str.15 = [17 x i8] c"Enter a double: \00"
@.str.16 = [4 x i8] c"%lf\00"
@.str.17 = [13 x i8] c"user's input\00"
@str = [29 x i8] c"The smallest positive number\00"
@str.18 = [44 x i8] c"The smallest positive number greater than 1\00"
define i32 @main() {
%1 = alloca [64 x i32]
%2 = alloca [64 x i32]
%3 = alloca double
%4 = tail call i32 (...) @detect_endian()
%5 = icmp eq i32 %4, 0
%6 = icmp eq i32 %4, 1
%7 = select i1 %6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0)
%8 = select i1 %5, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %7
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call double @sqrt(i32 -1)
%11 = tail call i32 @show(double %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%12 = tail call i32 @show(double 0x7FF0000000000000, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%13 = tail call double @log(i32 0)
%14 = tail call i32 @show(double %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%15 = tail call i32 @show(double 0.000000e+00, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%16 = tail call i32 @show(double -0.000000e+00, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%17 = tail call i32 @show(double 1.000000e+00, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%18 = tail call i32 @show(double 1.000000e-01, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%20 = bitcast [64 x i32]* %1 to i8*
%21 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 63
store i32 1, i32* %21
%22 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 0
%23 = call double @bit_array_to_double_native(i32* %22)
%24 = call i32 @show(double %23, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.12, i64 0, i64 0))
%25 = call double @bit_array_to_double_diy_big(i32* %22)
%26 = call i32 @show(double %25, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0))
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.18, i64 0, i64 0))
%28 = bitcast [64 x i32]* %2 to i8*
%29 = getelementptr inbounds [64 x i32], [64 x i32]* %2, i64 0, i64 0
%30 = call double @bit_array_to_double_native(i32* %29)
%31 = call i32 @show(double %30, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.12, i64 0, i64 0))
%32 = call double @bit_array_to_double_diy_big(i32* %29)
%33 = call i32 @show(double %32, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0))
%34 = bitcast double* %3 to i8*
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.15, i64 0, i64 0))
%36 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0), double* %3)
%37 = load double, double* %3
%38 = call i32 @show(double %37, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0))
ret i32 0
}