#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, float *);
int main(void) {
  float fah, cel;
  printf("pls input the temperature you wanna calculate: ");
  while (scanf("%f", &fah) != 1 || getchar() != '\n') {
    while (getchar() != '\n')
      ;
    printf("input invalid!\n");
    printf("pls input the temperature you wanna calculate: ");
  }
  cel = (5 * (fah - 32)) / 9;
  printf("It equals %5.2f\n", cel);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x1,%ecx
mov    %al,-0xd(%rbp)
jne    1180 <main+0x50>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1190 <main+0x60>
jmp    11ce <main+0x9e>
jmp    1195 <main+0x65>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11ad <main+0x7d>
jmp    1195 <main+0x65>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114d <main+0x1d>
movss  -0x8(%rbp),%xmm1
movss  0xe2d(%rip),%xmm0
subss  %xmm0,%xmm1
movss  0xe1d(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  0xe0d(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe43(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xebd(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xedc(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xee4(%rip),%r12
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1190 <main+0x50>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     11af <main+0x6f>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1190 <main+0x50>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <main+0x30>
movss  0x4(%rsp),%xmm0
addss  0xe43(%rip),%xmm0
mulss  0xe3f(%rip),%xmm0
divss  0xe3b(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe67(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [48 x i8] c"pls input the temperature you wanna calculate: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [16 x i8] c"input invalid!\0A\00"
@.str.3 = [17 x i8] c"It equals %5.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %20, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%7 = icmp ne i32 %6, 1
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = call signext i8 (...) @getchar()
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br label %12
12: ; preds = %8, %5
%13 = phi i1 [ true, %5 ], [ %11, %8 ]
br i1 %13, label %14, label %23
14: ; preds = %12
br label %15
15: ; preds = %19, %14
%16 = call signext i8 (...) @getchar()
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 10
br i1 %18, label %19, label %20
19: ; preds = %15
br label %15
20: ; preds = %15
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
br label %5
23: ; preds = %12
%24 = load float, float* %2
%25 = fsub float %24, 3.200000e+01
%26 = fmul float 5.000000e+00, %25
%27 = fdiv float %26, 9.000000e+00
store float %27, float* %3
%28 = load float, float* %3
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [48 x i8] c"pls input the temperature you wanna calculate: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.3 = [17 x i8] c"It equals %5.2f\0A\00"
@str = [15 x i8] c"input invalid!\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %14, %0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = call signext i8 (...) @getchar()
%9 = icmp eq i8 %8, 10
br i1 %9, label %17, label %10
10: ; preds = %4, %7
br label %11
11: ; preds = %10, %11
%12 = call signext i8 (...) @getchar()
%13 = icmp eq i8 %12, 10
br i1 %13, label %14, label %11
14: ; preds = %11
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
br label %4
17: ; preds = %7
%18 = load float, float* %1
%19 = fadd float %18, -3.200000e+01
%20 = fmul float %19, 5.000000e+00
%21 = fdiv float %20, 9.000000e+00
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %22)
ret i32 0
}