#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 *, int, double, double);
int main(void) {
  double s = 100, r = 50;
  printf("[%2d]s=%10g, r=%10g\n", 1, s, r);
  for (int i = 2; i <= 10; i++) {
    s = s + r * 2;
    r = r / 2;
    printf("[%2d]s=%10g, r=%10g\n", i, s, r);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xee1(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xecc(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xece(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
movl   $0x2,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jg     11b9 <main+0xa9>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe87(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%esi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115b <main+0x4b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xf88(%rip),%rbx
movsd  0xee0(%rip),%xmm0
movsd  0xee0(%rip),%xmm1
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
movsd  0xed3(%rip),%xmm0
movsd  0xed3(%rip),%xmm1
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
movsd  0xec6(%rip),%xmm0
movsd  0xec6(%rip),%xmm1
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
movsd  0xeb9(%rip),%xmm0
movsd  0xeb9(%rip),%xmm1
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
movsd  0xeac(%rip),%xmm0
movsd  0xeac(%rip),%xmm1
mov    %rbx,%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
movsd  0xe9f(%rip),%xmm0
movsd  0xe9f(%rip),%xmm1
mov    %rbx,%rdi
mov    $0x6,%esi
call   1030 <printf@plt>
movsd  0xe92(%rip),%xmm0
movsd  0xe92(%rip),%xmm1
mov    %rbx,%rdi
mov    $0x7,%esi
call   1030 <printf@plt>
movsd  0xe85(%rip),%xmm0
movsd  0xe85(%rip),%xmm1
mov    %rbx,%rdi
mov    $0x8,%esi
call   1030 <printf@plt>
movsd  0xe78(%rip),%xmm0
movsd  0xe78(%rip),%xmm1
mov    %rbx,%rdi
mov    $0x9,%esi
call   1030 <printf@plt>
movsd  0xe6b(%rip),%xmm0
movsd  0xe6b(%rip),%xmm1
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"[%2d]s=%10g, r=%10g\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store i32 0, i32* %1
store double 1.000000e+02, double* %2
store double 5.000000e+01, double* %3
%5 = load double, double* %2
%6 = load double, double* %3
%7 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 1, double %5, double %6)
store i32 2, i32* %4
br label %8
8: ; preds = %21, %0
%9 = load i32, i32* %4
%10 = icmp sle i32 %9, 10
br i1 %10, label %11, label %24
11: ; preds = %8
%12 = load double, double* %2
%13 = load double, double* %3
%14 = call double @llvm.fmuladd.f64(double %13, double 2.000000e+00, double %12)
store double %14, double* %2
%15 = load double, double* %3
%16 = fdiv double %15, 2.000000e+00
store double %16, double* %3
%17 = load i32, i32* %4
%18 = load double, double* %2
%19 = load double, double* %3
%20 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %17, double %18, double %19)
br label %21
21: ; preds = %11
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %8
24: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"[%2d]s=%10g, r=%10g\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 1, double 1.000000e+02, double 5.000000e+01)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 2, double 2.000000e+02, double 2.500000e+01)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 3, double 2.500000e+02, double 1.250000e+01)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 4, double 2.750000e+02, double 6.250000e+00)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 5, double 2.875000e+02, double 3.125000e+00)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 6, double 2.937500e+02, double 1.562500e+00)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 7, double 2.968750e+02, double 7.812500e-01)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 8, double 0x4072A70000000000, double 3.906250e-01)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 9, double 0x4072B38000000000, double 0x3FC9000000000000)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 10, double 0x4072B9C000000000, double 0x3FB9000000000000)
ret i32 0
}