#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*/ fprintf(int /*<<< orphan*/, char *, double);
int fscanf(int /*<<< orphan*/, char *, double *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int UpperB(double upper) {
  double value;
  fprintf(stderr, "Using upper bound: %lf\n", upper);
  while (fscanf(stdin, "%lf\n", &value) == 1)
    fprintf(stdout, "%lf\n", value > upper ? upper : value);
  return 0;
}


x86 assembly (clang, -O0):
<UpperB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    0x2ea4(%rip),%rax
mov    (%rax),%edi
movsd  -0x8(%rbp),%xmm0
lea    0xebe(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    0xebc(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <fscanf@plt>
cmp    $0x1,%eax
jne    11b7 <UpperB+0x97>
mov    0x2e60(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1194 <UpperB+0x74>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    119e <UpperB+0x7e>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
lea    0xe66(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1147 <UpperB+0x27>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UpperB>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2ea6(%rip),%rax
mov    (%rax),%edi
lea    0xec5(%rip),%rsi
movsd  %xmm0,0x10(%rsp)
call   1040 <fprintf@plt>
mov    0x2e9b(%rip),%r15
mov    (%r15),%edi
lea    0xebc(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1030 <fscanf@plt>
cmp    $0x1,%eax
jne    11ab <UpperB+0x8b>
mov    0x2e63(%rip),%r12
lea    0xe9f(%rip),%rbx
lea    0x8(%rsp),%r14
nopl   0x0(%rax)
mov    (%r12),%edi
movsd  0x10(%rsp),%xmm0
minsd  0x8(%rsp),%xmm0
mov    %rbx,%rsi
call   1040 <fprintf@plt>
mov    (%r15),%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <fscanf@plt>
cmp    $0x1,%eax
je     1180 <UpperB+0x60>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"Using upper bound: %lf\0A\00"
@stdin = global i32 0
@.str.1 = [5 x i8] c"%lf\0A\00"
@stdout = global i32 0
define i32 @UpperB(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
%4 = load i32, i32* @stderr
%5 = load double, double* %2
%6 = call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), double %5)
br label %7
7: ; preds = %20, %1
%8 = load i32, i32* @stdin
%9 = call i32 @fscanf(i32 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %3)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = load i32, i32* @stdout
%13 = load double, double* %3
%14 = load double, double* %2
%15 = fcmp ogt double %13, %14
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = load double, double* %2
br label %20
18: ; preds = %11
%19 = load double, double* %3
br label %20
20: ; preds = %18, %16
%21 = phi double [ %17, %16 ], [ %19, %18 ]
%22 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %21)
br label %7
23: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"Using upper bound: %lf\0A\00"
@stdin = global i32 0
@.str.1 = [5 x i8] c"%lf\0A\00"
@stdout = global i32 0
define i32 @UpperB(double %0) {
%2 = alloca double
%3 = bitcast double* %2 to i8*
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), double %0)
%6 = load i32, i32* @stdin
%7 = call i32 @fscanf(i32 %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %2)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %18
9: ; preds = %1, %9
%10 = load i32, i32* @stdout
%11 = load double, double* %2
%12 = fcmp ogt double %11, %0
%13 = select i1 %12, double %0, double %11
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %13)
%15 = load i32, i32* @stdin
%16 = call i32 @fscanf(i32 %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %2)
%17 = icmp eq i32 %16, 1
br i1 %17, label %9, label %18
18: ; preds = %9, %1
ret i32 0
}