#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 */
double cos(double);
int /*<<< orphan*/ printf(char *, ...);
double sin(double);
int main() {
  double range, value;
  int count, offset, sp, row, col;
  char screen[15][31];
  printf("Array example - "
         "Sine/Cosine curve using Matrix\n\n");
  for (row = 0; row < 15; row++)
    for (col = 0; col < 31; col++)
      screen[row][col] = ' ';
  range = 0.0;
  for (count = 0; count < 31; count++) {
    value = cos(range);
    offset = (value + 1.0) * 7.0;
    screen[offset][count] = '*';
    value = sin(range);
    offset = (value + 1.0) * 7.0;
    screen[offset][count] = '#';
    range += 0.5;
  }
  for (row = 0; row < 15; row++) {
    for (col = 0; col < 31; col++)
      printf("%c ", screen[row][col]);
    printf("\n");
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0xf,-0x28(%rbp)
jge    11ad <main+0x7d>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x1f,-0x2c(%rbp)
jge    119a <main+0x6a>
movslq -0x28(%rbp),%rcx
lea    -0x200(%rbp),%rax
imul   $0x1f,%rcx,%rcx
add    %rcx,%rax
movslq -0x2c(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1168 <main+0x38>
jmp    119f <main+0x6f>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1157 <main+0x27>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1f,-0x1c(%rbp)
jge    1278 <main+0x148>
movsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xe33(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xe1e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
movslq -0x20(%rbp),%rcx
lea    -0x200(%rbp),%rax
imul   $0x1f,%rcx,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
movb   $0x2a,(%rax,%rcx,1)
movsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xdea(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xdd5(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
movslq -0x20(%rbp),%rcx
lea    -0x200(%rbp),%rax
imul   $0x1f,%rcx,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
movb   $0x23,(%rax,%rcx,1)
movsd  0xda0(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11bc <main+0x8c>
movl   $0x0,-0x28(%rbp)
cmpl   $0xf,-0x28(%rbp)
jge    12ec <main+0x1bc>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x1f,-0x2c(%rbp)
jge    12d0 <main+0x1a0>
movslq -0x28(%rbp),%rcx
lea    -0x200(%rbp),%rax
imul   $0x1f,%rcx,%rcx
add    %rcx,%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1290 <main+0x160>
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    127f <main+0x14f>
lea    0xd54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1e8,%rsp
lea    0xea7(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%rbx
mov    $0x1d1,%edx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1060 <memset@plt>
xorpd  %xmm0,%xmm0
mov    $0x1f,%r14d
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
call   1080 <cos@plt>
movsd  0xe47(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe43(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cltq
mov    %rax,%rcx
shl    $0x5,%rcx
sub    %rax,%rcx
movb   $0x2a,(%rbx,%rcx,1)
movsd  0x8(%rsp),%xmm0
call   1070 <sin@plt>
addsd  0xe10(%rip),%xmm0
mulsd  0xe10(%rip),%xmm0
cvttsd2si %xmm0,%eax
movsd  0x8(%rsp),%xmm0
cltq
mov    %rax,%rcx
shl    $0x5,%rcx
sub    %rax,%rcx
movb   $0x23,(%rbx,%rcx,1)
addsd  0xdf6(%rip),%xmm0
add    $0x1,%rbx
add    $0xffffffffffffffff,%r14
jne    11a0 <main+0x40>
lea    0x10(%rsp),%r12
lea    0xde4(%rip),%r14
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
mov    $0xffffffffffffffe1,%rbx
nopw   0x0(%rax,%rax,1)
movsbl 0x1f(%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
inc    %rbx
jne    1250 <main+0xf0>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
add    $0x1f,%r12
cmp    $0xf,%r15
jne    1240 <main+0xe0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x1e8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [49 x i8] c"Array example - Sine/Cosine curve using Matrix\0A\0A\00"
@.str.1 = [4 x i8] c"%c \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [15 x [31 x i8]]
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %11
11: ; preds = %29, %0
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 15
br i1 %13, label %14, label %32
14: ; preds = %11
store i32 0, i32* %8
br label %15
15: ; preds = %25, %14
%16 = load i32, i32* %8
%17 = icmp slt i32 %16, 31
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [15 x [31 x i8]], [15 x [31 x i8]]* %9, i64 0, i64 %20
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [31 x i8], [31 x i8]* %21, i64 0, i64 %23
store i8 32, i8* %24
br label %25
25: ; preds = %18
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %8
br label %15
28: ; preds = %15
br label %29
29: ; preds = %28
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %11
32: ; preds = %11
store double 0.000000e+00, double* %2
store i32 0, i32* %4
br label %33
33: ; preds = %63, %32
%34 = load i32, i32* %4
%35 = icmp slt i32 %34, 31
br i1 %35, label %36, label %66
36: ; preds = %33
%37 = load double, double* %2
%38 = call double @cos(double %37)
store double %38, double* %3
%39 = load double, double* %3
%40 = fadd double %39, 1.000000e+00
%41 = fmul double %40, 7.000000e+00
%42 = fptosi double %41 to i32
store i32 %42, i32* %5
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [15 x [31 x i8]], [15 x [31 x i8]]* %9, i64 0, i64 %44
%46 = load i32, i32* %4
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [31 x i8], [31 x i8]* %45, i64 0, i64 %47
store i8 42, i8* %48
%49 = load double, double* %2
%50 = call double @sin(double %49)
store double %50, double* %3
%51 = load double, double* %3
%52 = fadd double %51, 1.000000e+00
%53 = fmul double %52, 7.000000e+00
%54 = fptosi double %53 to i32
store i32 %54, i32* %5
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [15 x [31 x i8]], [15 x [31 x i8]]* %9, i64 0, i64 %56
%58 = load i32, i32* %4
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [31 x i8], [31 x i8]* %57, i64 0, i64 %59
store i8 35, i8* %60
%61 = load double, double* %2
%62 = fadd double %61, 5.000000e-01
store double %62, double* %2
br label %63
63: ; preds = %36
%64 = load i32, i32* %4
%65 = add nsw i32 %64, 1
store i32 %65, i32* %4
br label %33
66: ; preds = %33
store i32 0, i32* %7
br label %67
67: ; preds = %89, %66
%68 = load i32, i32* %7
%69 = icmp slt i32 %68, 15
br i1 %69, label %70, label %92
70: ; preds = %67
store i32 0, i32* %8
br label %71
71: ; preds = %84, %70
%72 = load i32, i32* %8
%73 = icmp slt i32 %72, 31
br i1 %73, label %74, label %87
74: ; preds = %71
%75 = load i32, i32* %7
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [15 x [31 x i8]], [15 x [31 x i8]]* %9, i64 0, i64 %76
%78 = load i32, i32* %8
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [31 x i8], [31 x i8]* %77, i64 0, i64 %79
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %82)
br label %84
84: ; preds = %74
%85 = load i32, i32* %8
%86 = add nsw i32 %85, 1
store i32 %86, i32* %8
br label %71
87: ; preds = %71
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %89
89: ; preds = %87
%90 = load i32, i32* %7
%91 = add nsw i32 %90, 1
store i32 %91, i32* %7
br label %67
92: ; preds = %67
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%c \00"
@str = [48 x i8] c"Array example - Sine/Cosine curve using Matrix\0A\00"
define i32 @main() {
%1 = alloca [15 x [31 x i8]]
%2 = getelementptr inbounds [15 x [31 x i8]], [15 x [31 x i8]]* %1, i64 0, i64 0, i64 0
%3 = getelementptr inbounds [15 x [31 x i8]], [15 x [31 x i8]]* %1, i64 0, i64 0, i64 0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %0, %5
%6 = phi i64 [ 0, %0 ], [ %21, %5 ]
%7 = phi double [ 0.000000e+00, %0 ], [ %20, %5 ]
%8 = tail call double @cos(double %7)
%9 = fadd double %8, 1.000000e+00
%10 = fmul double %9, 7.000000e+00
%11 = fptosi double %10 to i32
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [15 x [31 x i8]], [15 x [31 x i8]]* %1, i64 0, i64 %12, i64 %6
store i8 42, i8* %13
%14 = tail call double @sin(double %7)
%15 = fadd double %14, 1.000000e+00
%16 = fmul double %15, 7.000000e+00
%17 = fptosi double %16 to i32
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [15 x [31 x i8]], [15 x [31 x i8]]* %1, i64 0, i64 %18, i64 %6
store i8 35, i8* %19
%20 = fadd double %7, 5.000000e-01
%21 = add nuw nsw i64 %6, 1
%22 = icmp eq i64 %21, 31
br i1 %22, label %23, label %5
23: ; preds = %5, %33
%24 = phi i64 [ %35, %33 ], [ 0, %5 ]
br label %25
25: ; preds = %23, %25
%26 = phi i64 [ 0, %23 ], [ %31, %25 ]
%27 = getelementptr inbounds [15 x [31 x i8]], [15 x [31 x i8]]* %1, i64 0, i64 %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = add nuw nsw i64 %26, 1
%32 = icmp eq i64 %31, 31
br i1 %32, label %33, label %25
33: ; preds = %25
%34 = tail call i32 @putchar(i32 10)
%35 = add nuw nsw i64 %24, 1
%36 = icmp eq i64 %35, 15
br i1 %36, label %37, label %23
37: ; preds = %33
%38 = tail call i32 @putchar(i32 10)
ret i32 0
}