#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 */
scalar_t__ fabs(double);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, double, unsigned int);
scalar_t__ sscanf(char *, char *, double *);
int /*<<< orphan*/ stdin;
int main(void) {
  double d;
  unsigned i;
  char *s = malloc(500);
  while (fgets(s, 500, stdin) != NULL) {
    if (sscanf(s, "%lf\n", &d) && (i = (unsigned)fabs(d)) >= 5)
      printf("Greater than or equal to 5:\n\td = [%f]\n\ti = [%d]\n", d, i);
    else if (sscanf(s, "%lf\n", &d) && (i = (unsigned)fabs(d)) < 5)
      printf("Less than 5:\n\td = [%f]\n\ti = [%d]\n", d, i);
  }
  free(s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1f4,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
mov    $0x1f4,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     123d <main+0xdd>
mov    -0x20(%rbp),%rdi
lea    0xe57(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1080 <sscanf@plt>
cmp    $0x0,%rax
je     11eb <main+0x8b>
movsd  -0x10(%rbp),%xmm0
call   1060 <fabs@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x5,%eax
jb     11eb <main+0x8b>
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%esi
lea    0xe24(%rip),%rdi
call   1040 <printf@plt>
jmp    1238 <main+0xd8>
mov    -0x20(%rbp),%rdi
lea    0xe0a(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1080 <sscanf@plt>
cmp    $0x0,%rax
je     1233 <main+0xd3>
movsd  -0x10(%rbp),%xmm0
call   1060 <fabs@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x5,%eax
jae    1233 <main+0xd3>
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%esi
lea    0xe08(%rip),%rdi
call   1040 <printf@plt>
jmp    1238 <main+0xd8>
jmp    117d <main+0x1d>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1f4,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    0x2e69(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rax,%rdi
mov    $0x1f4,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     1232 <main+0xd2>
lea    0xe61(%rip),%r14
mov    %rsp,%r15
lea    0xe8d(%rip),%r12
lea    0xe55(%rip),%r13
jmp    11e4 <main+0x84>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%rsp),%xmm0
mov    %r13,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x1f4,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     1232 <main+0xd2>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1080 <sscanf@plt>
test   %rax,%rax
je     1206 <main+0xa6>
movsd  (%rsp),%xmm0
call   1060 <fabs@plt>
cmp    $0x5,%eax
jae    11c0 <main+0x60>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1080 <sscanf@plt>
test   %rax,%rax
je     11cf <main+0x6f>
movsd  (%rsp),%xmm0
call   1060 <fabs@plt>
cmp    $0x4,%eax
ja     11cf <main+0x6f>
movsd  (%rsp),%xmm0
mov    %r12,%rdi
jmp    11c8 <main+0x68>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [5 x i8] c"%lf\0A\00"
@.str.1 = [49 x i8] c"Greater than or equal to 5:\0A\09d = [%f]\0A\09i = [%d]\0A\00"
@.str.2 = [34 x i8] c"Less than 5:\0A\09d = [%f]\0A\09i = [%d]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i32
%4 = alloca i8*
store i32 0, i32* %1
%5 = call i8* @malloc(i32 500)
store i8* %5, i8** %4
br label %6
6: ; preds = %38, %0
%7 = load i8*, i8** %4
%8 = load i32, i32* @stdin
%9 = call i32* @fgets(i8* %7, i32 500, i32 %8)
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %39
11: ; preds = %6
%12 = load i8*, i8** %4
%13 = call i64 @sscanf(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double* %2)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %11
%16 = load double, double* %2
%17 = call i64 @fabs(double %16)
%18 = trunc i64 %17 to i32
store i32 %18, i32* %3
%19 = icmp uge i32 %18, 5
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load double, double* %2
%22 = load i32, i32* %3
%23 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), double %21, i32 %22)
br label %38
24: ; preds = %15, %11
%25 = load i8*, i8** %4
%26 = call i64 @sscanf(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double* %2)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = load double, double* %2
%30 = call i64 @fabs(double %29)
%31 = trunc i64 %30 to i32
store i32 %31, i32* %3
%32 = icmp ult i32 %31, 5
br i1 %32, label %33, label %37
33: ; preds = %28
%34 = load double, double* %2
%35 = load i32, i32* %3
%36 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), double %34, i32 %35)
br label %37
37: ; preds = %33, %28, %24
br label %38
38: ; preds = %37, %20
br label %6
39: ; preds = %6
%40 = load i8*, i8** %4
%41 = call i32 @free(i8* %40)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [5 x i8] c"%lf\0A\00"
@.str.1 = [49 x i8] c"Greater than or equal to 5:\0A\09d = [%f]\0A\09i = [%d]\0A\00"
@.str.2 = [34 x i8] c"Less than 5:\0A\09d = [%f]\0A\09i = [%d]\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call dereferenceable_or_null(500) i8* @malloc(i32 500)
%4 = load i32, i32* @stdin
%5 = call i32* @fgets(i8* %3, i32 500, i32 %4)
%6 = icmp eq i32* %5, null
br i1 %6, label %33, label %7
7: ; preds = %0, %29
%8 = call i64 @sscanf(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double* %1)
%9 = icmp eq i64 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %7
%11 = load double, double* %1
%12 = call i64 @fabs(double %11)
%13 = trunc i64 %12 to i32
%14 = icmp ugt i32 %13, 4
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load double, double* %1
%17 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), double %16, i32 %13)
br label %29
18: ; preds = %10, %7
%19 = call i64 @sscanf(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double* %1)
%20 = icmp eq i64 %19, 0
br i1 %20, label %29, label %21
21: ; preds = %18
%22 = load double, double* %1
%23 = call i64 @fabs(double %22)
%24 = trunc i64 %23 to i32
%25 = icmp ult i32 %24, 5
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load double, double* %1
%28 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), double %27, i32 %24)
br label %29
29: ; preds = %18, %21, %26, %15
%30 = load i32, i32* @stdin
%31 = call i32* @fgets(i8* %3, i32 500, i32 %30)
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %7
33: ; preds = %29, %0
%34 = call i32 @free(i8* %3)
ret i32 0
}