#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*/ assert(int);
int /*<<< orphan*/ printf(char *, char *);
int sprintf(char *, char *, ...);
void print_float(float f, int space) {
  static char pfb[128];
  assert(space < 128);
  pfb[0] = ' ';
  int len = (f >= 0) + sprintf(&pfb[f >= 0], "%f", f);
  if (len < space) {
    int ix = space - len;
    sprintf(&pfb[ix], "%s", pfb);
    for (int i = 0; i < ix; i++)
      pfb[i] = ' ';
  }
  pfb[space] = 0;
  printf("%s", pfb);
}


x86 assembly (clang, -O0):
<print_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
cmpl   $0x80,-0x8(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movb   $0x20,0x2ef5(%rip)
movss  -0x4(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
cltq
lea    0x2ec3(%rip),%rdi
add    %rax,%rdi
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe60(%rip),%rsi
mov    $0x1,%al
call   1050 <sprintf@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121e <print_float+0xee>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
movslq -0x10(%rbp),%rax
lea    0x2e7f(%rip),%rdi
add    %rax,%rdi
lea    0xe28(%rip),%rsi
lea    0x2e6e(%rip),%rdx
mov    $0x0,%al
call   1050 <sprintf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1219 <print_float+0xe9>
movslq -0x14(%rbp),%rcx
lea    0x2e49(%rip),%rax
movb   $0x20,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f0 <print_float+0xc0>
jmp    121e <print_float+0xee>
movslq -0x8(%rbp),%rcx
lea    0x2e27(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0xdcf(%rip),%rdi
lea    0x2e15(%rip),%rsi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_float>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
movss  %xmm0,0x4(%rsp)
xor    %edi,%edi
cmp    $0x80,%r15d
setl   %dil
call   1060 <assert@plt>
movb   $0x20,0x2ee7(%rip)
xorps  %xmm0,%xmm0
xor    %ebp,%ebp
movss  0x4(%rsp),%xmm1
ucomiss %xmm0,%xmm1
lea    0x2ed2(%rip),%r14
setae  %bpl
lea    (%r14,%rbp,1),%rdi
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe5c(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
mov    %eax,%ebx
add    %ebp,%ebx
cmp    %r15d,%ebx
jge    11e9 <print_float+0x99>
mov    %r15d,%eax
sub    %ebx,%eax
movslq %eax,%rbp
lea    (%r14,%rbp,1),%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
test   %ebp,%ebp
jle    11e9 <print_float+0x99>
not    %ebx
add    %r15d,%ebx
add    $0x1,%rbx
lea    0x2e84(%rip),%rdi
mov    $0x20,%esi
mov    %rbx,%rdx
call   1050 <memset@plt>
movslq %r15d,%rax
movb   $0x0,(%rax,%r14,1)
lea    0xe0b(%rip),%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@print_float.pfb = internal global [128 x i8] zeroinitializer
@.str = [3 x i8] c"%f\00"
@.str.1 = [3 x i8] c"%s\00"
define void @print_float(float %0, i32 %1) {
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store float %0, float* %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 128
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
store i8 32, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @print_float.pfb, i64 0, i64 0)
%12 = load float, float* %3
%13 = fcmp oge float %12, 0.000000e+00
%14 = zext i1 %13 to i32
%15 = load float, float* %3
%16 = fcmp oge float %15, 0.000000e+00
%17 = zext i1 %16 to i32
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [128 x i8], [128 x i8]* @print_float.pfb, i64 0, i64 %18
%20 = load float, float* %3
%21 = fpext float %20 to double
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %21)
%23 = add nsw i32 %14, %22
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %47
27: ; preds = %2
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = sub nsw i32 %28, %29
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [128 x i8], [128 x i8]* @print_float.pfb, i64 0, i64 %32
%34 = call i32 (i8*, i8*, ...) @sprintf(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([128 x i8], [128 x i8]* @print_float.pfb, i64 0, i64 0))
store i32 0, i32* %7
br label %35
35: ; preds = %43, %27
%36 = load i32, i32* %7
%37 = load i32, i32* %6
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %46
39: ; preds = %35
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [128 x i8], [128 x i8]* @print_float.pfb, i64 0, i64 %41
store i8 32, i8* %42
br label %43
43: ; preds = %39
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %35
46: ; preds = %35
br label %47
47: ; preds = %46, %2
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [128 x i8], [128 x i8]* @print_float.pfb, i64 0, i64 %49
store i8 0, i8* %50
%51 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([128 x i8], [128 x i8]* @print_float.pfb, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@print_float.pfb = internal global [128 x i8] zeroinitializer
@.str = [3 x i8] c"%f\00"
@.str.1 = [3 x i8] c"%s\00"
define void @print_float(float %0, i32 %1) {
%3 = icmp slt i32 %1, 128
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
store i8 32, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @print_float.pfb, i64 0, i64 0)
%6 = fcmp oge float %0, 0.000000e+00
%7 = zext i1 %6 to i32
%8 = zext i1 %6 to i64
%9 = getelementptr inbounds [128 x i8], [128 x i8]* @print_float.pfb, i64 0, i64 %8
%10 = fpext float %0 to double
%11 = tail call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %10)
%12 = add i32 %11, %7
%13 = icmp slt i32 %12, %1
br i1 %13, label %14, label %25
14: ; preds = %2
%15 = sub nsw i32 %1, %12
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [128 x i8], [128 x i8]* @print_float.pfb, i64 0, i64 %16
%18 = tail call i8* @strcpy(i8* %17, i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @print_float.pfb, i64 0, i64 0))
%19 = icmp sgt i32 %15, 0
br i1 %19, label %20, label %25
20: ; preds = %14
%21 = xor i32 %12, -1
%22 = add i32 %21, %1
%23 = zext i32 %22 to i64
%24 = add nuw nsw i64 %23, 1
br label %25
25: ; preds = %20, %14, %2
%26 = sext i32 %1 to i64
%27 = getelementptr inbounds [128 x i8], [128 x i8]* @print_float.pfb, i64 0, i64 %26
store i8 0, i8* %27
%28 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([128 x i8], [128 x i8]* @print_float.pfb, i64 0, i64 0))
ret void
}