#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*/ error(int, int /*<<< orphan*/, char *, char *);
int sscanf(char *, char *, float *, int *);
int /*<<< orphan*/ strncasecmp(char *, char *, int);
float scan_u(char *str) {
  float a;
  int nch;
  if (sscanf(str, "%f%n", &a, &nch) == 1) {
    if (str[nch] == '\0' || str[nch] == ' ')
      return a;
    if (!strncasecmp(str + nch, "cm", 2))
      return a * 28.35;
    if (!strncasecmp(str + nch, "in", 2))
      return a * 72.0;
    if (!strncasecmp(str + nch, "pt", 2))
      return a;
  }
  error(1, 0, "\n++++ Unknown unit value \"%s\"", str);
  return 20;
}


x86 assembly (clang, -O0):
<scan_u>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xecd(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    125f <scan_u+0x12f>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1187 <scan_u+0x57>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1196 <scan_u+0x66>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1283 <scan_u+0x153>
mov    -0x10(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
lea    0xe71(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%eax
jne    11de <scan_u+0xae>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe34(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1283 <scan_u+0x153>
mov    -0x10(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
lea    0xe2c(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1226 <scan_u+0xf6>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdf4(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1283 <scan_u+0x153>
mov    -0x10(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
lea    0xde7(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%eax
jne    125a <scan_u+0x12a>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1283 <scan_u+0x153>
jmp    125f <scan_u+0x12f>
mov    -0x10(%rbp),%rcx
mov    $0x1,%edi
xor    %esi,%esi
lea    0xdb1(%rip),%rdx
call   1050 <error@plt>
movss  0xd92(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_u>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xed2(%rip),%rsi
mov    %rsp,%rdx
lea    0x4(%rsp),%rcx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    11ae <scan_u+0x7e>
movslq 0x4(%rsp),%r14
testb  $0xdf,(%rbx,%r14,1)
jne    1163 <scan_u+0x33>
movss  (%rsp),%xmm0
jmp    11cc <scan_u+0x9c>
add    %rbx,%r14
lea    0xea8(%rip),%rsi
mov    %r14,%rdi
mov    $0x2,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     11d4 <scan_u+0xa4>
lea    0xe93(%rip),%rsi
mov    %r14,%rdi
mov    $0x2,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     11eb <scan_u+0xbb>
lea    0xe7e(%rip),%rsi
mov    %r14,%rdi
mov    $0x2,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     115c <scan_u+0x2c>
lea    0xe69(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
mov    %rbx,%rcx
call   1050 <error@plt>
movss  0xe34(%rip),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe23(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
jmp    11cc <scan_u+0x9c>
movss  (%rsp),%xmm0
mulss  0xe0c(%rip),%xmm0
jmp    11cc <scan_u+0x9c>

LLVM IR (-O0):
@.str = [5 x i8] c"%f%n\00"
@.str.1 = [3 x i8] c"cm\00"
@.str.2 = [3 x i8] c"in\00"
@.str.3 = [3 x i8] c"pt\00"
@.str.4 = [30 x i8] c"\0A++++ Unknown unit value \22%s\22\00"
define float @scan_u(i8* %0) {
%2 = alloca float
%3 = alloca i8*
%4 = alloca float
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), float* %4, i32* %5)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %61
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %9
%18 = load i8*, i8** %3
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 32
br i1 %24, label %25, label %27
25: ; preds = %17, %9
%26 = load float, float* %4
store float %26, float* %2
br label %64
27: ; preds = %17
%28 = load i8*, i8** %3
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = call i32 @strncasecmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%33 = icmp ne i32 %32, 0
br i1 %33, label %39, label %34
34: ; preds = %27
%35 = load float, float* %4
%36 = fpext float %35 to double
%37 = fmul double %36, 2.835000e+01
%38 = fptrunc double %37 to float
store float %38, float* %2
br label %64
39: ; preds = %27
%40 = load i8*, i8** %3
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = call i32 @strncasecmp(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%45 = icmp ne i32 %44, 0
br i1 %45, label %51, label %46
46: ; preds = %39
%47 = load float, float* %4
%48 = fpext float %47 to double
%49 = fmul double %48, 7.200000e+01
%50 = fptrunc double %49 to float
store float %50, float* %2
br label %64
51: ; preds = %39
%52 = load i8*, i8** %3
%53 = load i32, i32* %5
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
%56 = call i32 @strncasecmp(i8* %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
%57 = icmp ne i32 %56, 0
br i1 %57, label %60, label %58
58: ; preds = %51
%59 = load float, float* %4
store float %59, float* %2
br label %64
60: ; preds = %51
br label %61
61: ; preds = %60, %1
%62 = load i8*, i8** %3
%63 = call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %62)
store float 2.000000e+01, float* %2
br label %64
64: ; preds = %61, %58, %46, %34, %25
%65 = load float, float* %2
ret float %65
}

LLVM IR (-O2):
@.str = [5 x i8] c"%f%n\00"
@.str.1 = [3 x i8] c"cm\00"
@.str.2 = [3 x i8] c"in\00"
@.str.3 = [3 x i8] c"pt\00"
@.str.4 = [30 x i8] c"\0A++++ Unknown unit value \22%s\22\00"
define float @scan_u(i8* %0) {
%2 = alloca float
%3 = alloca i32
%4 = bitcast float* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), float* %2, i32* %3)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %34
8: ; preds = %1
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
switch i8 %12, label %15 [
i8 0, label %13
i8 32, label %13
]
13: ; preds = %8, %8
%14 = load float, float* %2
br label %36
15: ; preds = %8
%16 = call i32 @strncasecmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load float, float* %2
%20 = fpext float %19 to double
%21 = fmul double %20, 2.835000e+01
%22 = fptrunc double %21 to float
br label %36
23: ; preds = %15
%24 = call i32 @strncasecmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load float, float* %2
%28 = fmul float %27, 7.200000e+01
br label %36
29: ; preds = %23
%30 = call i32 @strncasecmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = load float, float* %2
br label %36
34: ; preds = %29, %1
%35 = call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %36
36: ; preds = %34, %32, %26, %18, %13
%37 = phi float [ %14, %13 ], [ 2.000000e+01, %34 ], [ %33, %32 ], [ %28, %26 ], [ %22, %18 ]
ret float %37
}