#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 EOF;
int getfloat(double *);
int /*<<< orphan*/ printf(char *, double, int);
int main(int argc, char **argv) {
  double n;
  int res = getfloat(&n);
  while (res > 0 && res != EOF) {
    printf("n=%f res=%d\n", n, res);
    res = getfloat(&n);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
call   1040 <getfloat@plt>
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
jle    1163 <main+0x43>
mov    -0x1c(%rbp),%eax
mov    0x2e8d(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1173 <main+0x53>
jmp    1198 <main+0x78>
movsd  -0x18(%rbp),%xmm0
mov    -0x1c(%rbp),%esi
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
call   1040 <getfloat@plt>
mov    %eax,-0x1c(%rbp)
jmp    1142 <main+0x22>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
call   1040 <getfloat@plt>
test   %eax,%eax
jle    1171 <main+0x51>
mov    0x2eaa(%rip),%r15
cmp    (%r15),%eax
je     1171 <main+0x51>
lea    0xeb6(%rip),%r14
lea    0x8(%rsp),%rbx
nop
movsd  0x8(%rsp),%xmm0
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <getfloat@plt>
test   %eax,%eax
jle    1171 <main+0x51>
cmp    (%r15),%eax
jne    1150 <main+0x30>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [13 x i8] c"n=%f res=%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @getfloat(double* %6)
store i32 %8, i32* %7
br label %9
9: ; preds = %18, %2
%10 = load i32, i32* %7
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i32, i32* %7
%14 = load i32, i32* @EOF
%15 = icmp ne i32 %13, %14
br label %16
16: ; preds = %12, %9
%17 = phi i1 [ false, %9 ], [ %15, %12 ]
br i1 %17, label %18, label %23
18: ; preds = %16
%19 = load double, double* %6
%20 = load i32, i32* %7
%21 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %19, i32 %20)
%22 = call i32 @getfloat(double* %6)
store i32 %22, i32* %7
br label %9
23: ; preds = %16
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [13 x i8] c"n=%f res=%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
%5 = call i32 @getfloat(double* %3)
%6 = icmp sgt i32 %5, 0
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %5, %7
%9 = select i1 %6, i1 %8, i1 false
br i1 %9, label %10, label %19
10: ; preds = %2, %10
%11 = phi i32 [ %14, %10 ], [ %5, %2 ]
%12 = load double, double* %3
%13 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %12, i32 %11)
%14 = call i32 @getfloat(double* %3)
%15 = icmp sgt i32 %14, 0
%16 = load i32, i32* @EOF
%17 = icmp ne i32 %14, %16
%18 = select i1 %15, i1 %17, i1 false
br i1 %18, label %10, label %19
19: ; preds = %10, %2
ret i32 0
}