#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 strlen(char *);
int strtol(char *, char **, int);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("Usage: hex_to_single <hex value>\n");
    return 1;
  }
  char *end;
  int input = strtol(argv[1], &end, 10);
  if (end != argv[1] + strlen(argv[1])) {
    printf("Not a valid decimal value.\n");
    return 2;
  }
  float *floatValue = (float *)&input;
  printf("%f\n", *floatValue);
  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)
cmpl   $0x2,-0x8(%rbp)
je     116a <main+0x3a>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1200 <main+0xd0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rcx
mov    %eax,%edx
mov    -0x30(%rbp),%rax
movslq %edx,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
je     11d7 <main+0xa7>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1200 <main+0xd0>
lea    -0x1c(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    1194 <main+0x54>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,%r14d
mov    0x8(%rsp),%rbp
mov    0x8(%rbx),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
add    %rbx,%rax
cmp    %rax,%rbp
je     11a7 <main+0x67>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%eax
jmp    11c0 <main+0x80>
lea    0xe84(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    11c0 <main+0x80>
movd   %r14d,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe49(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Usage: hex_to_single <hex value>\0A\00"
@.str.1 = [28 x i8] c"Not a valid decimal value.\0A\00"
@.str.2 = [4 x i8] c"%f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca float*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %37
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strtol(i8* %16, i8** %6, i32 10)
store i32 %17, i32* %7
%18 = load i8*, i8** %6
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strlen(i8* %24)
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %21, i64 %26
%28 = icmp ne i8* %18, %27
br i1 %28, label %29, label %31
29: ; preds = %13
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
store i32 2, i32* %3
br label %37
31: ; preds = %13
%32 = bitcast i32* %7 to float*
store float* %32, float** %8
%33 = load float*, float** %8
%34 = load float, float* %33
%35 = fpext float %34 to double
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %35)
store i32 0, i32* %3
br label %37
37: ; preds = %31, %29, %11
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@.str.2 = [4 x i8] c"%f\0A\00"
@str = [27 x i8] c"Not a valid decimal value.\00"
@str.3 = [33 x i8] c"Usage: hex_to_single <hex value>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = icmp eq i32 %0, 2
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.3, i64 0, i64 0))
br label %26
7: ; preds = %2
%8 = bitcast i8** %3 to i8*
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @strtol(i8* %10, i8** %3, i32 10)
%12 = load i8*, i8** %3
%13 = load i8*, i8** %9
%14 = tail call i32 @strlen(i8* %13)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = icmp eq i8* %12, %16
br i1 %17, label %20, label %18
18: ; preds = %7
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %24
20: ; preds = %7
%21 = bitcast i32 %11 to float
%22 = fpext float %21 to double
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %22)
br label %24
24: ; preds = %20, %18
%25 = phi i32 [ 2, %18 ], [ 0, %20 ]
br label %26
26: ; preds = %24, %5
%27 = phi i32 [ 1, %5 ], [ %25, %24 ]
ret i32 %27
}