#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  scalar_t__ rm_eo;
  int /*<<< orphan*/ rm_so;
};
typedef TYPE_1__ regmatch_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ rematch(char *, char *, size_t, TYPE_1__ *);
int /*<<< orphan*/ stderr;
scalar_t__ str2num(char *);
char *substring(char *, int /*<<< orphan*/, scalar_t__);
int t_extract(char *in, float *temp) {
  char re[] = "^(-?[0-9]+\\.?[0-9]*) *([cCfF])$";
  size_t nmatch = 3;
  regmatch_t pmatch[nmatch];
  char *temp_type, *temp_val;
  int value;
  if (rematch(in, re, nmatch, pmatch)) {
    temp_val = substring(in, pmatch[1].rm_so, pmatch[1].rm_eo - 1);
    *temp = (float)str2num(temp_val);
    temp_type = substring(in, pmatch[2].rm_so, pmatch[2].rm_eo - 1);
    if (*temp_type == 'c' || *temp_type == 'C')
      value = 'C';
    if (*temp_type == 'f' || *temp_type == 'F')
      value = 'F';
  } else {
    fprintf(stderr, "t_extract: Bad temperature entry.\n");
    exit(1);
  }
  free(temp_type);
  free(temp_val);
  return value;
}


x86 assembly (clang, -O0):
<t_extract>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movaps 0xe99(%rip),%xmm0
movaps %xmm0,-0x20(%rbp)
movaps 0xe7e(%rip),%xmm0
movaps %xmm0,-0x30(%rbp)
movq   $0x3,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rdx
shl    $0x4,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1060 <rematch@plt>
cmp    $0x0,%rax
je     1270 <t_extract+0x110>
mov    -0x68(%rbp),%rax
mov    -0x8(%rbp),%rdi
mov    0x18(%rax),%esi
mov    0x10(%rax),%rdx
sub    $0x1,%rdx
call   1040 <substring@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
call   1080 <str2num@plt>
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
cvtsi2ss %rcx,%xmm0
mov    -0x10(%rbp),%rcx
movss  %xmm0,(%rcx)
mov    -0x8(%rbp),%rdi
mov    0x28(%rax),%esi
mov    0x20(%rax),%rdx
sub    $0x1,%rdx
call   1040 <substring@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
je     123d <t_extract+0xdd>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x43,%eax
jne    1244 <t_extract+0xe4>
movl   $0x43,-0x5c(%rbp)
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x66,%eax
je     1264 <t_extract+0x104>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x46,%eax
jne    126b <t_extract+0x10b>
movl   $0x46,-0x5c(%rbp)
jmp    128f <t_extract+0x12f>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
lea    0xda0(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x5c(%rbp),%eax
mov    -0x40(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t_extract>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%r12
movaps 0xe95(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe79(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0x30(%rsp),%rsi
mov    %rsp,%rcx
mov    $0x3,%edx
call   1060 <rematch@plt>
test   %rax,%rax
je     1219 <t_extract+0xb9>
mov    0x18(%rsp),%esi
mov    0x10(%rsp),%rdx
add    $0xffffffffffffffff,%rdx
mov    %rbx,%rdi
call   1040 <substring@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1080 <str2num@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,(%r14)
mov    0x28(%rsp),%esi
mov    0x20(%rsp),%rdx
add    $0xffffffffffffffff,%rdx
mov    %rbx,%rdi
call   1040 <substring@plt>
mov    (%rax),%cl
and    $0xdf,%cl
xor    %edx,%edx
cmp    $0x46,%cl
sete   %dl
lea    (%rdx,%rdx,2),%ebx
add    $0x43,%ebx
mov    %rax,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rsp
mov    %ebx,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
lea    0xdf7(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64, i32 }
@__const.t_extract.re = [32 x i8] c"^(-?[0-9]+\\.?[0-9]*) *([cCfF])$\00"
@stderr = global i32 0
@.str = [35 x i8] c"t_extract: Bad temperature entry.\0A\00"
define i32 @t_extract(i8* %0, float* %1) {
%3 = alloca i8*
%4 = alloca float*
%5 = alloca [32 x i8]
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %3
store float* %1, float** %4
%12 = bitcast [32 x i8]* %5 to i8*
store i64 3, i64* %6
%13 = load i64, i64* %6
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %7
%15 = alloca %struct.TYPE_3__, i64 %13
store i64 %13, i64* %8
%16 = load i8*, i8** %3
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%18 = load i64, i64* %6
%19 = call i64 @rematch(i8* %16, i8* %17, i64 %18, %struct.TYPE_3__* %15)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %66
21: ; preds = %2
%22 = load i8*, i8** %3
%23 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %15, i64 1
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %23, i32 0, i32 1
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %15, i64 1
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %26, i32 0, i32 0
%28 = load i64, i64* %27
%29 = sub nsw i64 %28, 1
%30 = call i8* @substring(i8* %22, i32 %25, i64 %29)
store i8* %30, i8** %10
%31 = load i8*, i8** %10
%32 = call i64 @str2num(i8* %31)
%33 = sitofp i64 %32 to float
%34 = load float*, float** %4
store float %33, float* %34
%35 = load i8*, i8** %3
%36 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %15, i64 2
%37 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %36, i32 0, i32 1
%38 = load i32, i32* %37
%39 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %15, i64 2
%40 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %39, i32 0, i32 0
%41 = load i64, i64* %40
%42 = sub nsw i64 %41, 1
%43 = call i8* @substring(i8* %35, i32 %38, i64 %42)
store i8* %43, i8** %9
%44 = load i8*, i8** %9
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 99
br i1 %47, label %53, label %48
48: ; preds = %21
%49 = load i8*, i8** %9
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 67
br i1 %52, label %53, label %54
53: ; preds = %48, %21
store i32 67, i32* %11
br label %54
54: ; preds = %53, %48
%55 = load i8*, i8** %9
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 102
br i1 %58, label %64, label %59
59: ; preds = %54
%60 = load i8*, i8** %9
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 70
br i1 %63, label %64, label %65
64: ; preds = %59, %54
store i32 70, i32* %11
br label %65
65: ; preds = %64, %59
br label %70
66: ; preds = %2
%67 = load i32, i32* @stderr
%68 = call i32 @fprintf(i32 %67, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %65
%71 = load i8*, i8** %9
%72 = call i32 @free(i8* %71)
%73 = load i8*, i8** %10
%74 = call i32 @free(i8* %73)
%75 = load i32, i32* %11
%76 = load i8*, i8** %7
ret i32 %75
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i32 }
@__const.t_extract.re = [32 x i8] c"^(-?[0-9]+\\.?[0-9]*) *([cCfF])$\00"
@stderr = global i32 0
@.str = [35 x i8] c"t_extract: Bad temperature entry.\0A\00"
define i32 @t_extract(i8* %0, float* nocapture writeonly %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = tail call i8* @llvm.stacksave()
%6 = alloca [3 x %struct.TYPE_3__]
%7 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %6, i64 0, i64 0
%8 = call i64 @rematch(i8* %0, i8* %4, i64 3, %struct.TYPE_3__* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %31, label %10
10: ; preds = %2
%11 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %6, i64 0, i64 1, i32 1
%12 = load i32, i32* %11
%13 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %6, i64 0, i64 1, i32 0
%14 = load i64, i64* %13
%15 = add nsw i64 %14, -1
%16 = call i8* @substring(i8* %0, i32 %12, i64 %15)
%17 = call i64 @str2num(i8* %16)
%18 = sitofp i64 %17 to float
store float %18, float* %1
%19 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %6, i64 0, i64 2, i32 1
%20 = load i32, i32* %19
%21 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %6, i64 0, i64 2, i32 0
%22 = load i64, i64* %21
%23 = add nsw i64 %22, -1
%24 = call i8* @substring(i8* %0, i32 %20, i64 %23)
%25 = load i8, i8* %24
%26 = and i8 %25, -33
%27 = icmp eq i8 %26, 70
%28 = select i1 %27, i32 70, i32 67
%29 = call i32 @free(i8* %24)
%30 = call i32 @free(i8* %16)
ret i32 %28
31: ; preds = %2
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
}