#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(char *);
int /*<<< orphan*/ printf(char const *);
int scanf(char *, ...);
void get_input(const char *msg, double *var) {
  const int INPUT_THRESHOLD = 5;
  for (int i = 0; i < INPUT_THRESHOLD; i++) {
    printf(msg);
    if (scanf("%lf", var) != 1)
      scanf("%*s");
    else
      return;
  }
  error("Too many tries\n");
}


x86 assembly (clang, -O0):
<get_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x5,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x5,-0x18(%rbp)
jge    11a7 <get_input+0x77>
mov    -0x8(%rbp),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
cmp    $0x1,%eax
je     118f <get_input+0x5f>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    1194 <get_input+0x64>
jmp    11b3 <get_input+0x83>
jmp    1199 <get_input+0x69>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114e <get_input+0x1e>
lea    0xe5a(%rip),%rdi
call   1050 <error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_input>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmp    $0x1,%eax
je     120d <get_input+0xdd>
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0xe8a(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmp    $0x1,%eax
je     120d <get_input+0xdd>
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0xe5a(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmp    $0x1,%eax
je     120d <get_input+0xdd>
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0xe2e(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmp    $0x1,%eax
je     120d <get_input+0xdd>
lea    0xe1c(%rip),%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0xe02(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    1215 <get_input+0xe5>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xde8(%rip),%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xdde(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <error@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [4 x i8] c"%*s\00"
@.str.2 = [16 x i8] c"Too many tries\0A\00"
define void @get_input(i8* %0, double* %1) {
%3 = alloca i8*
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store double* %1, double** %4
store i32 5, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %20, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 5
br i1 %9, label %10, label %23
10: ; preds = %7
%11 = load i8*, i8** %3
%12 = call i32 @printf(i8* %11)
%13 = load double*, double** %4
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %13)
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %19
18: ; preds = %10
br label %25
19: ; preds = %16
br label %20
20: ; preds = %19
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %7
23: ; preds = %7
%24 = call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %23, %18
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [4 x i8] c"%*s\00"
@.str.2 = [16 x i8] c"Too many tries\0A\00"
define void @get_input(i8* nocapture %0, double* %1) {
%3 = tail call i32 @printf(i8* dereferenceable(1) %0)
%4 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %29, label %6
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @printf(i8* dereferenceable(1) %0)
%9 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%10 = icmp eq i32 %9, 1
br i1 %10, label %29, label %11
11: ; preds = %6
%12 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @printf(i8* dereferenceable(1) %0)
%14 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%15 = icmp eq i32 %14, 1
br i1 %15, label %29, label %16
16: ; preds = %11
%17 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @printf(i8* dereferenceable(1) %0)
%19 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%20 = icmp eq i32 %19, 1
br i1 %20, label %29, label %21
21: ; preds = %16
%22 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%23 = tail call i32 @printf(i8* dereferenceable(1) %0)
%24 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%25 = icmp eq i32 %24, 1
br i1 %25, label %29, label %26
26: ; preds = %21
%27 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%28 = tail call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %2, %6, %11, %16, %21, %26
ret void
}