#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 */
scalar_t__ is_prime(int);
int /*<<< orphan*/ printf(char *, int, int);
int main(void) {
  int counter = 1, i;
  for (i = 0; i <= 541; i++) {
    if (is_prime(i)) {
      printf("prime %d: %d\n", counter, i);
      counter++;
    }
    if (counter == 101)
      break;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x21d,-0xc(%rbp)
jg     1199 <main+0x79>
mov    -0xc(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     1177 <main+0x57>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x65,-0x8(%rbp)
jne    1186 <main+0x66>
jmp    1199 <main+0x79>
jmp    118b <main+0x6b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%ebx
xor    %ebp,%ebp
lea    0xece(%rip),%r14
jmp    114b <main+0x2b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebp
cmp    $0x21e,%ebp
je     116b <main+0x4b>
mov    %ebp,%edi
call   1040 <is_prime@plt>
test   %rax,%rax
je     1140 <main+0x20>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    $0x65,%ebx
jne    1140 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"prime %d: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %22, %0
%5 = load i32, i32* %3
%6 = icmp sle i32 %5, 541
br i1 %6, label %7, label %25
7: ; preds = %4
%8 = load i32, i32* %3
%9 = call i64 @is_prime(i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13)
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
br label %17
17: ; preds = %11, %7
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 101
br i1 %19, label %20, label %21
20: ; preds = %17
br label %25
21: ; preds = %17
br label %22
22: ; preds = %21
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %4
25: ; preds = %20, %4
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [14 x i8] c"prime %d: %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %10
%2 = phi i32 [ 0, %0 ], [ %12, %10 ]
%3 = phi i32 [ 1, %0 ], [ %11, %10 ]
%4 = tail call i64 @is_prime(i32 %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %2)
%8 = add nsw i32 %3, 1
%9 = icmp eq i32 %8, 101
br i1 %9, label %14, label %10
10: ; preds = %1, %6
%11 = phi i32 [ %8, %6 ], [ %3, %1 ]
%12 = add nuw nsw i32 %2, 1
%13 = icmp eq i32 %12, 542
br i1 %13, label %14, label %1
14: ; preds = %6, %10
ret i32 0
}