#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__ prime(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(char);
int main() {
  int i;
  int colcnt = 0;
  for (i = 2; i <= 50000; i++)
    if (prime(i)) {
      colcnt++;
      if (colcnt % 9 == 0) {
        printf("%5d\n", i);
        colcnt = 0;
      } else
        printf("%5d ", i);
    }
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x2,-0x8(%rbp)
cmpl   $0xc350,-0x8(%rbp)
jg     11cb <main+0x9b>
mov    -0x8(%rbp),%edi
call   1050 <prime@plt>
cmp    $0x0,%rax
je     11b8 <main+0x88>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x9,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11a4 <main+0x74>
mov    -0x8(%rbp),%esi
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
jmp    11b3 <main+0x83>
mov    -0x8(%rbp),%esi
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
jmp    11b8 <main+0x88>
jmp    11bd <main+0x8d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114d <main+0x1d>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x2,%ebx
xor    %ebp,%ebp
lea    0xeba(%rip),%r14
lea    0xeb8(%rip),%r15
jmp    1165 <main+0x35>
nop
mov    %ebx,%esi
call   1040 <printf@plt>
mov    %r12d,%ebp
add    $0x1,%ebx
cmp    $0xc351,%ebx
je     1194 <main+0x64>
mov    %ebx,%edi
call   1050 <prime@plt>
test   %rax,%rax
je     115a <main+0x2a>
add    $0x1,%ebp
imul   $0x38e38e39,%ebp,%eax
add    $0xe38e38e,%eax
xor    %r12d,%r12d
mov    %r14,%rdi
cmp    $0x1c71c71d,%eax
jb     1150 <main+0x20>
mov    %r15,%rdi
mov    %ebp,%r12d
jmp    1150 <main+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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