#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*/ printf(char *, ...);
double round(double);
void printdouble(double *d) {
  int i;
  for (i = 0; i < 5; ++i)
    if (d[i] != round(d[i]))
      printf("non-integer!!! yikes!\n");
  printf("0");
  for (i = 0; i < 5; ++i)
    printf("+%.0f", d[i]);
}


x86 assembly (clang, -O0):
<printdouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jge    119f <printdouble+0x7f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <round@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jne    117e <printdouble+0x5e>
jp     117e <printdouble+0x5e>
jmp    118c <printdouble+0x6c>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1191 <printdouble+0x71>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <printdouble+0x13>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jge    11e7 <printdouble+0xc7>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe47(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b4 <printdouble+0x94>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printdouble>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
movsd  %xmm0,(%rsp)
call   1060 <round@plt>
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    1162 <printdouble+0x22>
jnp    116e <printdouble+0x2e>
lea    0xe9d(%rip),%rdi
call   1040 <puts@plt>
movsd  0x8(%rbx),%xmm0
movsd  %xmm0,(%rsp)
call   1060 <round@plt>
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    118a <printdouble+0x4a>
jnp    1196 <printdouble+0x56>
lea    0xe75(%rip),%rdi
call   1040 <puts@plt>
movsd  0x10(%rbx),%xmm0
movsd  %xmm0,(%rsp)
call   1060 <round@plt>
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    11b2 <printdouble+0x72>
jnp    11be <printdouble+0x7e>
lea    0xe4d(%rip),%rdi
call   1040 <puts@plt>
movsd  0x18(%rbx),%xmm0
movsd  %xmm0,(%rsp)
call   1060 <round@plt>
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    11da <printdouble+0x9a>
jnp    11e6 <printdouble+0xa6>
lea    0xe25(%rip),%rdi
call   1040 <puts@plt>
movsd  0x20(%rbx),%xmm0
movsd  %xmm0,(%rsp)
call   1060 <round@plt>
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    1202 <printdouble+0xc2>
jnp    120e <printdouble+0xce>
lea    0xdfd(%rip),%rdi
call   1040 <puts@plt>
mov    $0x30,%edi
call   1030 <putchar@plt>
movsd  (%rbx),%xmm0
lea    0xddd(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x8(%rbx),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x10(%rbx),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x18(%rbx),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x20(%rbx),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"non-integer!!! yikes!\0A\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [6 x i8] c"+%.0f\00"
define void @printdouble(double* %0) {
%2 = alloca double*
%3 = alloca i32
store double* %0, double** %2
store i32 0, i32* %3
br label %4
4: ; preds = %23, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 5
br i1 %6, label %7, label %26
7: ; preds = %4
%8 = load double*, double** %2
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds double, double* %8, i64 %10
%12 = load double, double* %11
%13 = load double*, double** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = call double @llvm.round.f64(double %17)
%19 = fcmp une double %12, %18
br i1 %19, label %20, label %22
20: ; preds = %7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %7
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %4
26: ; preds = %4
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %28
28: ; preds = %38, %26
%29 = load i32, i32* %3
%30 = icmp slt i32 %29, 5
br i1 %30, label %31, label %41
31: ; preds = %28
%32 = load double*, double** %2
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = load double, double* %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %36)
br label %38
38: ; preds = %31
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %28
41: ; preds = %28
ret void
}

LLVM IR (-O2):
@.str.2 = [6 x i8] c"+%.0f\00"
@str = [22 x i8] c"non-integer!!! yikes!\00"
define void @printdouble(double* nocapture %0) {
%2 = load double, double* %0
%3 = tail call double @llvm.round.f64(double %2)
%4 = fcmp une double %2, %3
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %7
7: ; preds = %1, %5
%8 = getelementptr inbounds double, double* %0, i64 1
%9 = load double, double* %8
%10 = tail call double @llvm.round.f64(double %9)
%11 = fcmp une double %9, %10
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %14
14: ; preds = %12, %7
%15 = getelementptr inbounds double, double* %0, i64 2
%16 = load double, double* %15
%17 = tail call double @llvm.round.f64(double %16)
%18 = fcmp une double %16, %17
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %21
21: ; preds = %19, %14
%22 = getelementptr inbounds double, double* %0, i64 3
%23 = load double, double* %22
%24 = tail call double @llvm.round.f64(double %23)
%25 = fcmp une double %23, %24
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %28
28: ; preds = %26, %21
%29 = getelementptr inbounds double, double* %0, i64 4
%30 = load double, double* %29
%31 = tail call double @llvm.round.f64(double %30)
%32 = fcmp une double %30, %31
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %35
35: ; preds = %33, %28
%36 = tail call i32 @putchar(i32 48)
%37 = load double, double* %0
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %37)
%39 = load double, double* %8
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %39)
%41 = load double, double* %15
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %41)
%43 = load double, double* %22
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %43)
%45 = load double, double* %29
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %45)
ret void
}