#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 *, int, int, double);
int main() {
  double f;
  int rc;
  int w1 = 8;
  while ((rc = getfloat(&f)) != EOF && rc != 0) {
    printf("getfloat returned: %*i  and retrieved: %g\n", w1, rc, f);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x8,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <getfloat@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
xor    %eax,%eax
mov    0x2e9b(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x19(%rbp)
je     1162 <main+0x42>
cmpl   $0x0,-0x14(%rbp)
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1172 <main+0x52>
jmp    118e <main+0x6e>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
movsd  -0x10(%rbp),%xmm0
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
jmp    1136 <main+0x16>
xor    %eax,%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
je     1176 <main+0x56>
mov    0x2eaa(%rip),%r15
cmp    (%r15),%eax
je     1176 <main+0x56>
lea    0xeb6(%rip),%r14
lea    0x8(%rsp),%rbx
nop
movsd  0x8(%rsp),%xmm0
mov    %r14,%rdi
mov    $0x8,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <getfloat@plt>
test   %eax,%eax
je     1176 <main+0x56>
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 = [43 x i8] c"getfloat returned: %*i and retrieved: %g\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 8, i32* %4
br label %5
5: ; preds = %14, %0
%6 = call i32 @getfloat(double* %2)
store i32 %6, i32* %3
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 0
br label %12
12: ; preds = %9, %5
%13 = phi i1 [ false, %5 ], [ %11, %9 ]
br i1 %13, label %14, label %19
14: ; preds = %12
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = load double, double* %2
%18 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16, double %17)
br label %5
19: ; preds = %12
ret i32 0
}

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