#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*/ sprintf(char *, char *, ...);
char *kelvin_to_TTTa(char *target, double T) {
  int ix;
  if (T == (1.7e38)) {
    sprintf(target, "///");
    return target;
  }
  ix = (int)(10.0 * (T - 273.15));
  if (ix >= 0) {
    ix &= ~1;
  } else {
    ix = (-ix);
    ix |= 1;
  }
  sprintf(target, "%03d", ix);
  return target;
}


x86 assembly (clang, -O0):
<kelvin_to_TTTa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xed2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    115d <kelvin_to_TTTa+0x4d>
jp     115d <kelvin_to_TTTa+0x4d>
mov    -0x10(%rbp),%rdi
lea    0xecf(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c7 <kelvin_to_TTTa+0xb7>
movsd  -0x18(%rbp),%xmm1
movsd  0xea6(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xe92(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     1199 <kelvin_to_TTTa+0x89>
mov    -0x1c(%rbp),%eax
and    $0xfffffffe,%eax
mov    %eax,-0x1c(%rbp)
jmp    11aa <kelvin_to_TTTa+0x9a>
xor    %eax,%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kelvin_to_TTTa>:
push   %rbx
mov    %rdi,%rbx
ucomisd 0xee4(%rip),%xmm0
jne    1128 <kelvin_to_TTTa+0x18>
jp     1128 <kelvin_to_TTTa+0x18>
movl   $0x2f2f2f,(%rbx)
jmp    115e <kelvin_to_TTTa+0x4e>
addsd  0xed8(%rip),%xmm0
mulsd  0xed8(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,%ecx
and    $0xfffffffe,%ecx
mov    %eax,%edx
neg    %edx
or     $0x1,%edx
test   %eax,%eax
cmovns %ecx,%edx
lea    0xec4(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"///\00"
@.str.1 = [5 x i8] c"%03d\00"
define i8* @kelvin_to_TTTa(i8* %0, double %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca double
%6 = alloca i32
store i8* %0, i8** %4
store double %1, double* %5
%7 = load double, double* %5
%8 = fcmp oeq double %7, 1.700000e+38
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = call i32 (i8*, i8*, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %4
store i8* %12, i8** %3
br label %33
13: ; preds = %2
%14 = load double, double* %5
%15 = fsub double %14, 2.731500e+02
%16 = fmul double 1.000000e+01, %15
%17 = fptosi double %16 to i32
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp sge i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = load i32, i32* %6
%22 = and i32 %21, -2
store i32 %22, i32* %6
br label %28
23: ; preds = %13
%24 = load i32, i32* %6
%25 = sub nsw i32 0, %24
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = or i32 %26, 1
store i32 %27, i32* %6
br label %28
28: ; preds = %23, %20
%29 = load i8*, i8** %4
%30 = load i32, i32* %6
%31 = call i32 (i8*, i8*, ...) @sprintf(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = load i8*, i8** %4
store i8* %32, i8** %3
br label %33
33: ; preds = %28, %9
%34 = load i8*, i8** %3
ret i8* %34
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%03d\00"
define i8* @kelvin_to_TTTa(i8* returned writeonly %0, double %1) {
%3 = fcmp oeq double %1, 1.700000e+38
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = bitcast i8* %0 to i32*
store i32 3092271, i32* %5
br label %16
6: ; preds = %2
%7 = fadd double %1, -2.731500e+02
%8 = fmul double %7, 1.000000e+01
%9 = fptosi double %8 to i32
%10 = icmp sgt i32 %9, -1
%11 = and i32 %9, -2
%12 = sub nsw i32 0, %9
%13 = or i32 %12, 1
%14 = select i1 %10, i32 %11, i32 %13
%15 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %6, %4
ret i8* %0
}