#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 *);
float strtod(char *, char **);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("Usage: single_to_hex <floating point value>\n");
    return 1;
  }
  char *end;
  float input = strtod(argv[1], &end);
  if (end != argv[1] + strlen(argv[1])) {
    printf("Not a valid floating point value.\n");
    return 2;
  }
  int *intValue = (int *)&input;
  printf("%X\n", *intValue);
  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   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f7 <main+0xc7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <strtod@plt>
movss  %xmm0,-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   1040 <strlen@plt>
mov    -0x38(%rbp),%rcx
mov    %eax,%edx
mov    -0x30(%rbp),%rax
movslq %edx,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
je     11d4 <main+0xa4>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    11f7 <main+0xc7>
lea    -0x1c(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jne    1191 <main+0x51>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0x10(%rsp),%rsi
call   1040 <strtod@plt>
movd   %xmm0,0xc(%rsp)
mov    0x10(%rsp),%r14
mov    0x8(%rbx),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
add    %rbx,%rax
cmp    %rax,%r14
je     11a4 <main+0x64>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%ebx
jmp    11be <main+0x7e>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
jmp    11be <main+0x7e>
movd   0xc(%rsp),%xmm0
movd   %xmm0,%esi
lea    0xe4b(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Usage: single_to_hex <floating point value>\0A\00"
@.str.1 = [35 x i8] c"Not a valid floating point value.\0A\00"
@.str.2 = [4 x i8] c"%X\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca float
%8 = alloca i32*
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 ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %36
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call float @strtod(i8* %16, i8** %6)
store float %17, float* %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 ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
store i32 2, i32* %3
br label %36
31: ; preds = %13
%32 = bitcast float* %7 to i32*
store i32* %32, i32** %8
%33 = load i32*, i32** %8
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %34)
store i32 0, i32* %3
br label %36
36: ; preds = %31, %29, %11
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str.2 = [4 x i8] c"%X\0A\00"
@str = [34 x i8] c"Not a valid floating point value.\00"
@str.3 = [44 x i8] c"Usage: single_to_hex <floating point 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 ([44 x i8], [44 x i8]* @str.3, i64 0, i64 0))
br label %25
7: ; preds = %2
%8 = bitcast i8** %3 to i8*
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call float @strtod(i8* %10, i8** %3)
%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 ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %23
20: ; preds = %7
%21 = bitcast float %11 to i32
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %18
%24 = phi i32 [ 2, %18 ], [ 0, %20 ]
br label %25
25: ; preds = %23, %5
%26 = phi i32 [ 1, %5 ], [ %24, %23 ]
ret i32 %26
}