#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main() {
  float *p = NULL;
  p = (float *)malloc(sizeof(char));
  if (p == NULL) {
    printf("malloc memory failed!");
    return 0;
  }
  scanf("%f", p);
  printf("%.2f", *p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117a <main+0x4a>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ab <main+0x7b>
mov    -0x10(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x1,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     116a <main+0x3a>
mov    %rax,%rbx
lea    0xecc(%rip),%rdi
mov    %rax,%rsi
call   1050 <scanf@plt>
movss  (%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xeb8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1178 <main+0x48>
lea    0xe8f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"malloc memory failed!\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [5 x i8] c"%.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float*
store i32 0, i32* %1
store float* null, float** %2
%3 = call i64 @malloc(i32 1)
%4 = inttoptr i64 %3 to float*
store float* %4, float** %2
%5 = load float*, float** %2
%6 = icmp eq float* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %16
9: ; preds = %0
%10 = load float*, float** %2
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %10)
%12 = load float*, float** %2
%13 = load float, float* %12
%14 = fpext float %13 to double
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %14)
store i32 0, i32* %1
br label %16
16: ; preds = %9, %7
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str = [22 x i8] c"malloc memory failed!\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [5 x i8] c"%.2f\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 1)
%2 = inttoptr i64 %1 to float*
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %11
6: ; preds = %0
%7 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%8 = load float, float* %2
%9 = fpext float %8 to double
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %9)
br label %11
11: ; preds = %6, %4
ret i32 0
}