#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 cos(double);
int /*<<< orphan*/ printf(char *, int);
int main() {
  double pi = 3.1415926535;
  int a = 1;
  int i;
  for (i = 0; i < 3; i++)
    if (a = cos(pi * i / 2))
      printf("%d", 1);
    else
      printf("%d", 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    11b6 <main+0x96>
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe9e(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <cos@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     1195 <main+0x75>
lea    0xe8a(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
jmp    11a3 <main+0x83>
lea    0xe74(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
jmp    11a8 <main+0x88>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <main+0x2a>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xorps  %xmm0,%xmm0
call   1040 <cos@plt>
xor    %esi,%esi
test   %eax,%eax
setne  %sil
lea    0xed8(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
movsd  0xeb8(%rip),%xmm0
call   1040 <cos@plt>
xor    %esi,%esi
test   %eax,%eax
setne  %sil
mov    %rbx,%rdi
call   1030 <printf@plt>
movsd  0xea3(%rip),%xmm0
call   1040 <cos@plt>
xor    %esi,%esi
test   %eax,%eax
setne  %sil
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store double 0x400921FB54411744, double* %2
store i32 1, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %21, %0
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 3
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = load double, double* %2
%10 = load i32, i32* %4
%11 = sitofp i32 %10 to double
%12 = fmul double %9, %11
%13 = fdiv double %12, 2.000000e+00
%14 = call i32 @cos(double %13)
store i32 %14, i32* %3
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %8
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 1)
br label %20
18: ; preds = %8
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 0)
br label %20
20: ; preds = %18, %16
br label %21
21: ; preds = %20
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %5
24: ; preds = %5
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = tail call i32 @cos(double 0.000000e+00)
%2 = icmp ne i32 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @cos(double 0x3FF921FB54411744)
%6 = icmp ne i32 %5, 0
%7 = zext i1 %6 to i32
%8 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 @cos(double 0x400921FB54411744)
%10 = icmp ne i32 %9, 0
%11 = zext i1 %10 to i32
%12 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %11)
ret i32 0
}