#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, double, long);
int /*<<< orphan*/ show_usage(char *);
int /*<<< orphan*/ stderr;
double strtod(char const *, char **);
unsigned long strtoul(char const *, char **, int);
int main(int argc, char **argv, char **envp) {
  double fvalue;
  unsigned long ulvalue;
  long lvalue;
  const char *str;
  char *endptr;
  if (argc != 2) {
    fprintf(stderr, "\nExpected a single argument\n");
    show_usage(argv[0]);
  }
  str = argv[1];
  if (str[0] == '0') {
    endptr = NULL;
    ulvalue = strtoul(str, &endptr, 16);
    if (!endptr || *endptr != '\0') {
      fprintf(stderr, "\nHexadecimal argument not fully converted\n");
      show_usage(argv[0]);
    }
    if (ulvalue >= 0x80000000)
      lvalue = ~ulvalue + 1;
    else
      lvalue = ulvalue;
    fvalue = ((double)lvalue) / 65536.0;
    printf("0x%08lx -> %10.5f\n", ulvalue, fvalue);
  } else {
    endptr = NULL;
    fvalue = strtod(str, &endptr);
    if (!endptr || *endptr != '\0') {
      fprintf(stderr, "\nFloating point argument not fully converted\n");
      show_usage(argv[0]);
    }
    lvalue = 65536.0 * fvalue;
    printf("%10.5f -> 0x%08lx\n", fvalue, lvalue);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1195 <main+0x45>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xeac(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <show_usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    128c <main+0x13c>
movq   $0x0,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x10,%edx
call   1070 <strtoul@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     11ea <main+0x9a>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     120b <main+0xbb>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <show_usage@plt>
mov    $0x80000000,%eax
cmp    %rax,-0x28(%rbp)
jb     122f <main+0xdf>
mov    -0x28(%rbp),%rax
xor    $0xffffffffffffffff,%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1237 <main+0xe7>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
cvtsi2sdq -0x30(%rbp),%xmm0
movsd  0xdbb(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movaps 0xdbb(%rip),%xmm1
movq   -0x28(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xdba(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si -0x20(%rbp),%rsi
lea    0xdf6(%rip),%rdi
call   1040 <printf@plt>
jmp    130d <main+0x1bd>
movq   $0x0,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x20(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     12c1 <main+0x171>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12e2 <main+0x192>
mov    0x2d18(%rip),%rax
mov    (%rax),%edi
lea    0xdba(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <show_usage@plt>
movsd  0xd16(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x30(%rbp),%rsi
lea    0xdb1(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
cmp    $0x2,%edi
je     117c <main+0x2c>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    0xec1(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%r14),%rdi
call   1060 <show_usage@plt>
mov    0x8(%r14),%rdi
cmpb   $0x30,(%rdi)
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rsi
jne    121d <main+0xcd>
mov    $0x10,%edx
call   1070 <strtoul@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rax
test   %rax,%rax
je     11b3 <main+0x63>
cmpb   $0x0,(%rax)
je     11d0 <main+0x80>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%r14),%rdi
call   1060 <show_usage@plt>
mov    %rbx,%rax
neg    %rax
cmp    $0x7fffffff,%rbx
cmovbe %rbx,%rax
cvtsi2sd %rax,%xmm1
mulsd  0xe1a(%rip),%xmm1
movq   %rbx,%xmm2
punpckldq 0xe15(%rip),%xmm2
subpd  0xe1d(%rip),%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
addsd  %xmm2,%xmm0
cvttsd2si %xmm1,%rsi
lea    0xe5d(%rip),%rdi
jmp    1272 <main+0x122>
call   1030 <strtod@plt>
mov    0x8(%rsp),%rax
test   %rax,%rax
je     1231 <main+0xe1>
cmpb   $0x0,(%rax)
je     125a <main+0x10a>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
movsd  %xmm0,0x10(%rsp)
call   1050 <fprintf@plt>
mov    (%r14),%rdi
call   1060 <show_usage@plt>
movsd  0x10(%rsp),%xmm0
movapd %xmm0,%xmm1
mulsd  0xd9a(%rip),%xmm1
cvttsd2si %xmm1,%rsi
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"\0AExpected a single argument\0A\00"
@.str.1 = [43 x i8] c"\0AHexadecimal argument not fully converted\0A\00"
@.str.2 = [19 x i8] c"0x%08lx -> %10.5f\0A\00"
@.str.3 = [46 x i8] c"\0AFloating point argument not fully converted\0A\00"
@.str.4 = [19 x i8] c"%10.5f -> 0x%08lx\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca double
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i8*
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%13 = load i32, i32* %5
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %22
15: ; preds = %3
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%18 = load i8**, i8*** %6
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @show_usage(i8* %20)
br label %22
22: ; preds = %15, %3
%23 = load i8**, i8*** %6
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
store i8* %25, i8** %11
%26 = load i8*, i8** %11
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 48
br i1 %30, label %31, label %66
31: ; preds = %22
store i8* null, i8** %12
%32 = load i8*, i8** %11
%33 = call i64 @strtoul(i8* %32, i8** %12, i32 16)
store i64 %33, i64* %9
%34 = load i8*, i8** %12
%35 = icmp ne i8* %34, null
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = load i8*, i8** %12
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %48
41: ; preds = %36, %31
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%44 = load i8**, i8*** %6
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = call i32 @show_usage(i8* %46)
br label %48
48: ; preds = %41, %36
%49 = load i64, i64* %9
%50 = icmp uge i64 %49, 2147483648
br i1 %50, label %51, label %55
51: ; preds = %48
%52 = load i64, i64* %9
%53 = xor i64 %52, -1
%54 = add i64 %53, 1
store i64 %54, i64* %10
br label %57
55: ; preds = %48
%56 = load i64, i64* %9
store i64 %56, i64* %10
br label %57
57: ; preds = %55, %51
%58 = load i64, i64* %10
%59 = sitofp i64 %58 to double
%60 = fdiv double %59, 6.553600e+04
store double %60, double* %8
%61 = load i64, i64* %9
%62 = uitofp i64 %61 to double
%63 = load double, double* %8
%64 = fptosi double %63 to i64
%65 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %62, i64 %64)
br label %90
66: ; preds = %22
store i8* null, i8** %12
%67 = load i8*, i8** %11
%68 = call double @strtod(i8* %67, i8** %12)
store double %68, double* %8
%69 = load i8*, i8** %12
%70 = icmp ne i8* %69, null
br i1 %70, label %71, label %76
71: ; preds = %66
%72 = load i8*, i8** %12
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %83
76: ; preds = %71, %66
%77 = load i32, i32* @stderr
%78 = call i32 @fprintf(i32 %77, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
%79 = load i8**, i8*** %6
%80 = getelementptr inbounds i8*, i8** %79, i64 0
%81 = load i8*, i8** %80
%82 = call i32 @show_usage(i8* %81)
br label %83
83: ; preds = %76, %71
%84 = load double, double* %8
%85 = fmul double 6.553600e+04, %84
%86 = fptosi double %85 to i64
store i64 %86, i64* %10
%87 = load double, double* %8
%88 = load i64, i64* %10
%89 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), double %87, i64 %88)
br label %90
90: ; preds = %83, %57
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"\0AExpected a single argument\0A\00"
@.str.1 = [43 x i8] c"\0AHexadecimal argument not fully converted\0A\00"
@.str.2 = [19 x i8] c"0x%08lx -> %10.5f\0A\00"
@.str.3 = [46 x i8] c"\0AFloating point argument not fully converted\0A\00"
@.str.4 = [19 x i8] c"%10.5f -> 0x%08lx\0A\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture readnone %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = icmp eq i32 %0, 2
br i1 %6, label %12, label %7
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%10 = load i8*, i8** %1
%11 = tail call i32 @show_usage(i8* %10)
br label %12
12: ; preds = %7, %3
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 48
store i8* null, i8** %4
br i1 %16, label %17, label %38
17: ; preds = %12
%18 = call i64 @strtoul(i8* %14, i8** %4, i32 16)
%19 = load i8*, i8** %4
%20 = icmp eq i8* %19, null
br i1 %20, label %24, label %21
21: ; preds = %17
%22 = load i8, i8* %19
%23 = icmp eq i8 %22, 0
br i1 %23, label %29, label %24
24: ; preds = %21, %17
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%27 = load i8*, i8** %1
%28 = tail call i32 @show_usage(i8* %27)
br label %29
29: ; preds = %24, %21
%30 = icmp ugt i64 %18, 2147483647
%31 = sub i64 0, %18
%32 = select i1 %30, i64 %31, i64 %18
%33 = sitofp i64 %32 to double
%34 = fmul double %33, 0x3EF0000000000000
%35 = uitofp i64 %18 to double
%36 = fptosi double %34 to i64
%37 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %35, i64 %36)
br label %54
38: ; preds = %12
%39 = call double @strtod(i8* %14, i8** %4)
%40 = load i8*, i8** %4
%41 = icmp eq i8* %40, null
br i1 %41, label %45, label %42
42: ; preds = %38
%43 = load i8, i8* %40
%44 = icmp eq i8 %43, 0
br i1 %44, label %50, label %45
45: ; preds = %42, %38
%46 = load i32, i32* @stderr
%47 = tail call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
%48 = load i8*, i8** %1
%49 = tail call i32 @show_usage(i8* %48)
br label %50
50: ; preds = %45, %42
%51 = fmul double %39, 6.553600e+04
%52 = fptosi double %51 to i64
%53 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), double %39, i64 %52)
br label %54
54: ; preds = %50, %29
ret i32 0
}