#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 count_prime(int *);
int /*<<< orphan*/ printf(char *, ...);
void display(int arr[]) {
  int i;
  int c = count_prime(arr);
  printf("There are %d prime numbers between 1 to 100 printed as follows :\n",
         c);
  for (i = 0; i < 100; i++)
    if (arr[i] != 0) {
      printf("%d", arr[i]);
      c--;
      if (c != 0)
        printf(", ");
      else
        printf(".\n");
    }
}


x86 assembly (clang, -O0):
<display>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <count_prime@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    11d1 <display+0xb1>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     11be <display+0x9e>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11ab <display+0x8b>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b9 <display+0x99>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11be <display+0x9e>
jmp    11c3 <display+0xa3>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1150 <display+0x30>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r13
call   1050 <count_prime@plt>
mov    %eax,%ebp
lea    0xeb4(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee6(%rip),%r14
lea    0xee5(%rip),%r15
lea    0xedb(%rip),%r12
xor    %ebx,%ebx
jmp    1184 <display+0x54>
xchg   %ax,%ax
mov    %r15,%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
add    $0x1,%rbx
cmp    $0x64,%rbx
je     11a8 <display+0x78>
mov    0x0(%r13,%rbx,4),%esi
test   %esi,%esi
je     117a <display+0x4a>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebp
je     1170 <display+0x40>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    117a <display+0x4a>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [66 x i8] c"There are %d prime numbers between 1 to 100 printed as follows :\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c", \00"
@.str.3 = [3 x i8] c".\0A\00"
define void @display(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = call i32 @count_prime(i32* %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i32 %7)
store i32 0, i32* %3
br label %9
9: ; preds = %36, %1
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 100
br i1 %11, label %12, label %39
12: ; preds = %9
%13 = load i32*, i32** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %35
19: ; preds = %12
%20 = load i32*, i32** %2
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %4
%27 = add nsw i32 %26, -1
store i32 %27, i32* %4
%28 = load i32, i32* %4
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %19
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %34
32: ; preds = %19
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
br label %35
35: ; preds = %34, %12
br label %36
36: ; preds = %35
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %9
39: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [66 x i8] c"There are %d prime numbers between 1 to 100 printed as follows :\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c", \00"
@str = [2 x i8] c".\00"
define void @display(i32* %0) {
%2 = tail call i32 @count_prime(i32* %0)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i32 %2)
br label %4
4: ; preds = %1, %18
%5 = phi i64 [ 0, %1 ], [ %20, %18 ]
%6 = phi i32 [ %2, %1 ], [ %19, %18 ]
%7 = getelementptr inbounds i32, i32* %0, i64 %5
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %4
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%12 = add nsw i32 %6, -1
%13 = icmp eq i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %18
16: ; preds = %10
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %18
18: ; preds = %4, %16, %14
%19 = phi i32 [ %12, %14 ], [ 0, %16 ], [ %6, %4 ]
%20 = add nuw nsw i64 %5, 1
%21 = icmp eq i64 %20, 100
br i1 %21, label %22, label %4
22: ; preds = %18
ret void
}