#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 */
typedef int /*<<< orphan*/ map;

/* Variables and functions */
int /*<<< orphan*/ bzero(char **, int);
double cos(double);
int /*<<< orphan*/ printf(char *, ...);
int print_cos() {
  char map[31][100];
  bzero(map, sizeof(map));
  int i = 0;
  for (i = 0; i < 100; i++) {
    double x = i * 0.08;
    double y = cos(x) * 15.0;
    int ypos = (int)(y + 0.5);
    map[15 - ypos][i] = '.';
  }
  for (i = 0; i < 31; i++) {
    int j = 0;
    for (j = 0; j < 100; j++) {
      if (15 == i) {
        printf("*");
      } else if (0 == map[i][j]) {
        printf(" ");
      } else {
        printf("%c", map[i][j]);
      }
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<print_cos>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc40,%rsp
lea    -0xc20(%rbp),%rdi
mov    $0xc1c,%esi
call   1050 <bzero@plt>
movl   $0x0,-0xc24(%rbp)
movl   $0x0,-0xc24(%rbp)
cmpl   $0x64,-0xc24(%rbp)
jge    11ff <print_cos+0xcf>
cvtsi2sdl -0xc24(%rbp),%xmm0
ff
movsd  0xe93(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xc30(%rbp)
ff
movsd  -0xc30(%rbp),%xmm0
ff
call   1040 <cos@plt>
movsd  0xe6a(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xc38(%rbp)
ff
movsd  0xe4e(%rip),%xmm0
addsd  -0xc38(%rbp),%xmm0
ff
cvttsd2si %xmm0,%eax
mov    %eax,-0xc3c(%rbp)
mov    $0xf,%eax
sub    -0xc3c(%rbp),%eax
movslq %eax,%rcx
lea    -0xc20(%rbp),%rax
imul   $0x64,%rcx,%rcx
add    %rcx,%rax
movslq -0xc24(%rbp),%rcx
movb   $0x2e,(%rax,%rcx,1)
mov    -0xc24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc24(%rbp)
jmp    1160 <print_cos+0x30>
movl   $0x0,-0xc24(%rbp)
cmpl   $0x1f,-0xc24(%rbp)
jge    1306 <print_cos+0x1d6>
movl   $0x0,-0xc40(%rbp)
movl   $0x0,-0xc40(%rbp)
cmpl   $0x64,-0xc40(%rbp)
jge    12e4 <print_cos+0x1b4>
mov    $0xf,%eax
cmp    -0xc24(%rbp),%eax
jne    125b <print_cos+0x12b>
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12cb <print_cos+0x19b>
movslq -0xc24(%rbp),%rcx
lea    -0xc20(%rbp),%rax
imul   $0x64,%rcx,%rcx
add    %rcx,%rax
movslq -0xc40(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1298 <print_cos+0x168>
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c6 <print_cos+0x196>
movslq -0xc24(%rbp),%rcx
lea    -0xc20(%rbp),%rax
imul   $0x64,%rcx,%rcx
add    %rcx,%rax
movslq -0xc40(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12cb <print_cos+0x19b>
jmp    12d0 <print_cos+0x1a0>
mov    -0xc40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc40(%rbp)
jmp    122a <print_cos+0xfa>
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc24(%rbp)
jmp    1209 <print_cos+0xd9>
xor    %eax,%eax
add    $0xc40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_cos>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xc20,%rsp
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0xc1c,%esi
call   1050 <bzero@plt>
lea    0x5dd(%rsp),%r14
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
movsd  0xe90(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <cos@plt>
movsd  0xe87(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe83(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cltq
imul   $0xffffffffffffff9c,%rax,%rax
movb   $0x2e,-0x1(%r14,%rax,1)
mov    %r15d,%eax
or     $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe4a(%rip),%xmm0
call   1040 <cos@plt>
mulsd  0xe45(%rip),%xmm0
addsd  0xe45(%rip),%xmm0
cvttsd2si %xmm0,%eax
cltq
imul   $0xffffffffffffff9c,%rax,%rax
movb   $0x2e,(%r14,%rax,1)
add    $0x2,%r15
add    $0x2,%r14
cmp    $0x64,%r15
jne    1160 <print_cos+0x30>
xor    %ebx,%ebx
mov    $0x20,%r14d
jmp    1218 <print_cos+0xe8>
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
add    $0x64,%r12
cmp    $0x1f,%rbx
je     1256 <print_cos+0x126>
mov    $0xffffffffffffff9c,%rbp
jmp    123a <print_cos+0x10a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1030 <putchar@plt>
inc    %rbp
je     1200 <print_cos+0xd0>
mov    $0x2a,%edi
cmp    $0xf,%rbx
je     1230 <print_cos+0x100>
movzbl 0x64(%r12,%rbp,1),%eax
test   %al,%al
cmove  %r14d,%eax
movsbl %al,%edi
jmp    1230 <print_cos+0x100>
xor    %eax,%eax
add    $0xc20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"*\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @print_cos() {
%1 = alloca [31 x [100 x i8]]
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = getelementptr inbounds [31 x [100 x i8]], [31 x [100 x i8]]* %1, i64 0, i64 0
%8 = bitcast [100 x i8]* %7 to i8**
%9 = call i32 @bzero(i8** %8, i32 3100)
store i32 0, i32* %2
store i32 0, i32* %2
br label %10
10: ; preds = %30, %0
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 100
br i1 %12, label %13, label %33
13: ; preds = %10
%14 = load i32, i32* %2
%15 = sitofp i32 %14 to double
%16 = fmul double %15, 8.000000e-02
store double %16, double* %3
%17 = load double, double* %3
%18 = call double @cos(double %17)
%19 = fmul double %18, 1.500000e+01
store double %19, double* %4
%20 = load double, double* %4
%21 = fadd double %20, 5.000000e-01
%22 = fptosi double %21 to i32
store i32 %22, i32* %5
%23 = load i32, i32* %5
%24 = sub nsw i32 15, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [31 x [100 x i8]], [31 x [100 x i8]]* %1, i64 0, i64 %25
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %26, i64 0, i64 %28
store i8 46, i8* %29
br label %30
30: ; preds = %13
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %10
33: ; preds = %10
store i32 0, i32* %2
br label %34
34: ; preds = %75, %33
%35 = load i32, i32* %2
%36 = icmp slt i32 %35, 31
br i1 %36, label %37, label %78
37: ; preds = %34
store i32 0, i32* %6
store i32 0, i32* %6
br label %38
38: ; preds = %70, %37
%39 = load i32, i32* %6
%40 = icmp slt i32 %39, 100
br i1 %40, label %41, label %73
41: ; preds = %38
%42 = load i32, i32* %2
%43 = icmp eq i32 15, %42
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %69
46: ; preds = %41
%47 = load i32, i32* %2
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [31 x [100 x i8]], [31 x [100 x i8]]* %1, i64 0, i64 %48
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %49, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 0, %54
br i1 %55, label %56, label %58
56: ; preds = %46
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %68
58: ; preds = %46
%59 = load i32, i32* %2
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [31 x [100 x i8]], [31 x [100 x i8]]* %1, i64 0, i64 %60
%62 = load i32, i32* %6
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [100 x i8], [100 x i8]* %61, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %58, %56
br label %69
69: ; preds = %68, %44
br label %70
70: ; preds = %69
%71 = load i32, i32* %6
%72 = add nsw i32 %71, 1
store i32 %72, i32* %6
br label %38
73: ; preds = %38
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %75
75: ; preds = %73
%76 = load i32, i32* %2
%77 = add nsw i32 %76, 1
store i32 %77, i32* %2
br label %34
78: ; preds = %34
ret i32 0
}

LLVM IR (-O2):
define i32 @print_cos() {
%1 = alloca [31 x [100 x i8]]
%2 = getelementptr inbounds [31 x [100 x i8]], [31 x [100 x i8]]* %1, i64 0, i64 0, i64 0
%3 = bitcast [31 x [100 x i8]]* %1 to i8**
%4 = call i32 @bzero(i8** %3, i32 3100)
br label %5
5: ; preds = %5, %0
%6 = phi i64 [ 0, %0 ], [ %28, %5 ]
%7 = trunc i64 %6 to i32
%8 = sitofp i32 %7 to double
%9 = fmul double %8, 8.000000e-02
%10 = tail call double @cos(double %9)
%11 = fmul double %10, 1.500000e+01
%12 = fadd double %11, 5.000000e-01
%13 = fptosi double %12 to i32
%14 = sub nsw i32 15, %13
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [31 x [100 x i8]], [31 x [100 x i8]]* %1, i64 0, i64 %15, i64 %6
store i8 46, i8* %16
%17 = or i64 %6, 1
%18 = trunc i64 %17 to i32
%19 = sitofp i32 %18 to double
%20 = fmul double %19, 8.000000e-02
%21 = tail call double @cos(double %20)
%22 = fmul double %21, 1.500000e+01
%23 = fadd double %22, 5.000000e-01
%24 = fptosi double %23 to i32
%25 = sub nsw i32 15, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [31 x [100 x i8]], [31 x [100 x i8]]* %1, i64 0, i64 %26, i64 %17
store i8 46, i8* %27
%28 = add nuw nsw i64 %6, 2
%29 = icmp eq i64 %28, 100
br i1 %29, label %30, label %5
30: ; preds = %5, %46
%31 = phi i64 [ %48, %46 ], [ 0, %5 ]
%32 = icmp eq i64 %31, 15
br label %33
33: ; preds = %30, %41
%34 = phi i64 [ 0, %30 ], [ %44, %41 ]
br i1 %32, label %41, label %35
35: ; preds = %33
%36 = getelementptr inbounds [31 x [100 x i8]], [31 x [100 x i8]]* %1, i64 0, i64 %31, i64 %34
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 0
%39 = select i1 %38, i8 32, i8 %37
%40 = sext i8 %39 to i32
br label %41
41: ; preds = %35, %33
%42 = phi i32 [ 42, %33 ], [ %40, %35 ]
%43 = tail call i32 @putchar(i32 %42)
%44 = add nuw nsw i64 %34, 1
%45 = icmp eq i64 %44, 100
br i1 %45, label %46, label %33
46: ; preds = %41
%47 = tail call i32 @putchar(i32 10)
%48 = add nuw nsw i64 %31, 1
%49 = icmp eq i64 %48, 31
br i1 %49, label %50, label %30
50: ; preds = %46
ret i32 0
}