#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ Warn(char *, float);
float atof(char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
char *strtok(char *, char *);
int read_kT(FILE *schedfp, float *ret_kT) {
  char buffer[256];
  char *sptr;
  float kT;
  do {
    if (fgets(buffer, 256, schedfp) == NULL)
      return 0;
  } while (*buffer == '#' || (sptr = strtok(buffer, " \t\n")) == NULL);
  kT = atof(sptr);
  if (kT > 10.0) {
    Warn("Trying to melt it? kT reset from %.2f to 10.0", kT);
    kT = 10.0;
  }
  if (kT < 0.1) {
    Warn("kT < 0.1 may cause numerical problems; reset from %.2f to 0.1", kT);
    kT = 0.1;
  }
  *ret_kT = kT;
  return 1;
}


x86 assembly (clang, -O0):
<read_kT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    117e <read_kT+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    127f <read_kT+0x13f>
jmp    1183 <read_kT+0x43>
movsbl -0x120(%rbp),%ecx
mov    $0x1,%al
cmp    $0x23,%ecx
mov    %al,-0x12d(%rbp)
je     11c2 <read_kT+0x82>
lea    -0x120(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x128(%rbp)
cmp    $0x0,%rax
sete   %al
mov    %al,-0x12d(%rbp)
mov    -0x12d(%rbp),%al
test   $0x1,%al
jne    1153 <read_kT+0x13>
mov    -0x128(%rbp),%rdi
call   1030 <atof@plt>
movss  %xmm0,-0x12c(%rbp)
ff
movss  -0x12c(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  0xe08(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1226 <read_kT+0xe6>
movss  -0x12c(%rbp),%xmm0
ff
lea    0xe0b(%rip),%rdi
call   1050 <Warn@plt>
movss  0xdf2(%rip),%xmm0
movss  %xmm0,-0x12c(%rbp)
ff
movss  -0x12c(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm1
movsd  0xdce(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1268 <read_kT+0x128>
movss  -0x12c(%rbp),%xmm0
ff
lea    0xdf7(%rip),%rdi
call   1050 <Warn@plt>
movss  0xdb4(%rip),%xmm0
movss  %xmm0,-0x12c(%rbp)
ff
movss  -0x12c(%rbp),%xmm0
ff
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_kT>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
xor    %r15d,%r15d
test   %rax,%rax
je     1201 <read_kT+0xc1>
mov    %rsp,%rbp
lea    0xe95(%rip),%r12
jmp    1195 <read_kT+0x55>
nopl   (%rax)
mov    %rbp,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1201 <read_kT+0xc1>
cmpb   $0x23,(%rsp)
je     1180 <read_kT+0x40>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
je     1180 <read_kT+0x40>
mov    %rax,%rdi
call   1030 <atof@plt>
ucomiss 0xe46(%rip),%xmm0
jbe    11d0 <read_kT+0x90>
lea    0xe51(%rip),%rdi
call   1050 <Warn@plt>
movss  0xe30(%rip),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe2c(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    11f6 <read_kT+0xb6>
lea    0xe59(%rip),%rdi
call   1050 <Warn@plt>
movss  0xe0e(%rip),%xmm0
movss  %xmm0,(%r14)
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c" \09\0A\00"
@.str.1 = [46 x i8] c"Trying to melt it? kT reset from %.2f to 10.0\00"
@.str.2 = [62 x i8] c"kT < 0.1 may cause numerical problems; reset from %.2f to 0.1\00"
define i32 @read_kT(i32* %0, float* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca float*
%6 = alloca [256 x i8]
%7 = alloca i8*
%8 = alloca float
store i32* %0, i32** %4
store float* %1, float** %5
br label %9
9: ; preds = %25, %2
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%11 = load i32*, i32** %4
%12 = call i32* @fgets(i8* %10, i32 256, i32* %11)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %9
store i32 0, i32* %3
br label %46
15: ; preds = %9
br label %16
16: ; preds = %15
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 35
br i1 %20, label %25, label %21
21: ; preds = %16
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%23 = call i8* @strtok(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %23, i8** %7
%24 = icmp eq i8* %23, null
br label %25
25: ; preds = %21, %16
%26 = phi i1 [ true, %16 ], [ %24, %21 ]
br i1 %26, label %9, label %27
27: ; preds = %25
%28 = load i8*, i8** %7
%29 = call float @atof(i8* %28)
store float %29, float* %8
%30 = load float, float* %8
%31 = fpext float %30 to double
%32 = fcmp ogt double %31, 1.000000e+01
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = load float, float* %8
%35 = call i32 @Warn(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), float %34)
store float 1.000000e+01, float* %8
br label %36
36: ; preds = %33, %27
%37 = load float, float* %8
%38 = fpext float %37 to double
%39 = fcmp olt double %38, 1.000000e-01
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load float, float* %8
%42 = call i32 @Warn(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0), float %41)
store float 0x3FB99999A0000000, float* %8
br label %43
43: ; preds = %40, %36
%44 = load float, float* %8
%45 = load float*, float** %5
store float %44, float* %45
store i32 1, i32* %3
br label %46
46: ; preds = %43, %14
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [4 x i8] c" \09\0A\00"
@.str.1 = [46 x i8] c"Trying to melt it? kT reset from %.2f to 10.0\00"
@.str.2 = [62 x i8] c"kT < 0.1 may cause numerical problems; reset from %.2f to 0.1\00"
define i32 @read_kT(i32* nocapture %0, float* nocapture writeonly %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32* @fgets(i8* %4, i32 256, i32* %0)
%6 = icmp eq i32* %5, null
br i1 %6, label %29, label %7
7: ; preds = %2, %13
%8 = load i8, i8* %4
%9 = icmp eq i8 %8, 35
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10, %7
%14 = call i32* @fgets(i8* %4, i32 256, i32* %0)
%15 = icmp eq i32* %14, null
br i1 %15, label %29, label %7
16: ; preds = %10
%17 = call float @atof(i8* %11)
%18 = fcmp ogt float %17, 1.000000e+01
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @Warn(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), float %17)
br label %21
21: ; preds = %19, %16
%22 = phi float [ 1.000000e+01, %19 ], [ %17, %16 ]
%23 = fpext float %22 to double
%24 = fcmp olt double %23, 1.000000e-01
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @Warn(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0), float %22)
br label %27
27: ; preds = %25, %21
%28 = phi float [ 0x3FB99999A0000000, %25 ], [ %22, %21 ]
store float %28, float* %1
br label %29
29: ; preds = %13, %2, %27
%30 = phi i32 [ 1, %27 ], [ 0, %2 ], [ 0, %13 ]
ret i32 %30
}