#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 *, int, float);
float gridmove();
int /*<<< orphan*/ stderr;
void grid_deform(int count) {
  int i;
  float maxdiff;
  for (i = 0; i < count; i++) {
    maxdiff = gridmove();
    fprintf(stderr, "iter %3i: %10.2e\n", i, maxdiff);
    if (maxdiff < 1e-7)
      break;
  }
}


x86 assembly (clang, -O0):
<grid_deform>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    119a <grid_deform+0x7a>
mov    $0x0,%al
call   1040 <gridmove@plt>
movss  %xmm0,-0xc(%rbp)
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
movss  -0xc(%rbp),%xmm0
lea    0xea6(%rip),%rsi
call   1030 <fprintf@plt>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe88(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1187 <grid_deform+0x67>
jmp    119a <grid_deform+0x7a>
jmp    118c <grid_deform+0x6c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <grid_deform+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grid_deform>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
jle    1190 <grid_deform+0x70>
mov    %edi,%r15d
mov    $0x1,%ebx
mov    0x2ea1(%rip),%r12
lea    0xec2(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
lea    -0x1(%rbx),%ebp
xor    %eax,%eax
call   1040 <gridmove@plt>
movss  %xmm0,0xc(%rsp)
mov    (%r12),%edi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <fprintf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe80(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1190 <grid_deform+0x70>
lea    0x1(%rbx),%eax
cmp    %r15d,%ebx
mov    %eax,%ebx
jl     1150 <grid_deform+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [18 x i8] c"iter %3i: %10.2e\0A\00"
define void @grid_deform(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
store i32 %0, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %20, %1
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %23
9: ; preds = %5
%10 = call float (...) @gridmove()
store float %10, float* %4
%11 = load i32, i32* @stderr
%12 = load i32, i32* %3
%13 = load float, float* %4
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %12, float %13)
%15 = load float, float* %4
%16 = fpext float %15 to double
%17 = fcmp olt double %16, 0x3E7AD7F29ABCAF48
br i1 %17, label %18, label %19
18: ; preds = %9
br label %23
19: ; preds = %9
br label %20
20: ; preds = %19
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %5
23: ; preds = %18, %5
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c"iter %3i: %10.2e\0A\00"
define void @grid_deform(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %13
3: ; preds = %1, %3
%4 = phi i32 [ %10, %3 ], [ 0, %1 ]
%5 = tail call float (...) @gridmove()
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4, float %5)
%8 = fpext float %5 to double
%9 = fcmp uge double %8, 0x3E7AD7F29ABCAF48
%10 = add nuw nsw i32 %4, 1
%11 = icmp slt i32 %10, %0
%12 = select i1 %9, i1 %11, i1 false
br i1 %12, label %3, label %13
13: ; preds = %3, %1
ret void
}