#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 main() {
  double a = 0.0;
  for (int i = 0; i < 100; i++)
    a += 0.1;
  for (int i = 0; i < 100; i++)
    a -= 0.1;
  if (a > 0.0) {
    printf("positive branch taken\n");
  } else {
    printf("negative branch taken\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    1158 <main+0x48>
movsd  0xec0(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112e <main+0x1e>
movl   $0x0,-0x18(%rbp)
cmpl   $0x64,-0x18(%rbp)
jge    118d <main+0x7d>
movsd  -0x10(%rbp),%xmm0
movsd  0xe8a(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115f <main+0x4f>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11b0 <main+0xa0>
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
jmp    11bc <main+0xac>
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xorpd  %xmm0,%xmm0
mov    $0x64,%eax
movsd  0xede(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
add    $0xfffffff6,%eax
jne    1130 <main+0x20>
mov    $0x64,%eax
movsd  0xe9e(%rip),%xmm1
nopw   0x0(%rax,%rax,1)
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
add    $0xfffffff6,%eax
jne    1170 <main+0x60>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
lea    0xe7a(%rip),%rax
lea    0xe5d(%rip),%rdi
cmova  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"positive branch taken\0A\00"
@.str.1 = [23 x i8] c"negative branch taken\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store i32 0, i32* %3
br label %5
5: ; preds = %11, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 100
br i1 %7, label %8, label %14
8: ; preds = %5
%9 = load double, double* %2
%10 = fadd double %9, 1.000000e-01
store double %10, double* %2
br label %11
11: ; preds = %8
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
br label %5
14: ; preds = %5
store i32 0, i32* %4
br label %15
15: ; preds = %21, %14
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 100
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load double, double* %2
%20 = fsub double %19, 1.000000e-01
store double %20, double* %2
br label %21
21: ; preds = %18
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %15
24: ; preds = %15
%25 = load double, double* %2
%26 = fcmp ogt double %25, 0.000000e+00
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %31
29: ; preds = %24
%30 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29, %27
ret i32 0
}

LLVM IR (-O2):
@str = [22 x i8] c"negative branch taken\00"
@str.2 = [22 x i8] c"positive branch taken\00"
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 0, %0 ], [ %14, %1 ]
%3 = phi double [ 0.000000e+00, %0 ], [ %13, %1 ]
%4 = fadd double %3, 1.000000e-01
%5 = fadd double %4, 1.000000e-01
%6 = fadd double %5, 1.000000e-01
%7 = fadd double %6, 1.000000e-01
%8 = fadd double %7, 1.000000e-01
%9 = fadd double %8, 1.000000e-01
%10 = fadd double %9, 1.000000e-01
%11 = fadd double %10, 1.000000e-01
%12 = fadd double %11, 1.000000e-01
%13 = fadd double %12, 1.000000e-01
%14 = add nuw nsw i32 %2, 10
%15 = icmp eq i32 %14, 100
br i1 %15, label %20, label %1
16: ; preds = %20
%17 = fcmp ogt double %32, 0.000000e+00
%18 = select i1 %17, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0)
%19 = tail call i32 @puts(i8* dereferenceable(1) %18)
ret i32 0
20: ; preds = %1, %20
%21 = phi i32 [ %33, %20 ], [ 0, %1 ]
%22 = phi double [ %32, %20 ], [ %13, %1 ]
%23 = fadd double %22, -1.000000e-01
%24 = fadd double %23, -1.000000e-01
%25 = fadd double %24, -1.000000e-01
%26 = fadd double %25, -1.000000e-01
%27 = fadd double %26, -1.000000e-01
%28 = fadd double %27, -1.000000e-01
%29 = fadd double %28, -1.000000e-01
%30 = fadd double %29, -1.000000e-01
%31 = fadd double %30, -1.000000e-01
%32 = fadd double %31, -1.000000e-01
%33 = add nuw nsw i32 %21, 10
%34 = icmp eq i32 %33, 100
br i1 %34, label %16, label %20
}