#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 /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int p, d;
  bool isPrime;
  for (p = 2; p <= 50; ++p) {
    isPrime = true;
    for (d = 2; d < p; ++d) {
      if (p % d == 0)
        isPrime = false;
      if (isPrime != false)
        printf("%i ", p);
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
cmpl   $0x32,-0x8(%rbp)
jg     11a2 <main+0x92>
movl   $0x1,-0x10(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118f <main+0x7f>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1161 <main+0x51>
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     117c <main+0x6c>
mov    -0x8(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1181 <main+0x71>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113e <main+0x2e>
jmp    1194 <main+0x84>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1126 <main+0x16>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@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,%r12d
lea    0xecb(%rip),%r14
xor    %r15d,%r15d
jmp    114e <main+0x2e>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12d
add    $0xffffffff,%r15d
cmp    $0x33,%r12d
je     1192 <main+0x72>
cmp    $0x3,%r12d
jb     1140 <main+0x20>
mov    $0x2,%ebx
mov    $0x1,%ebp
jmp    1173 <main+0x53>
lea    (%r15,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x2,%eax
je     1140 <main+0x20>
mov    %r12d,%eax
xor    %edx,%edx
div    %ebx
test   %edx,%edx
cmove  %edx,%ebp
test   %ebp,%ebp
je     1160 <main+0x40>
mov    %r14,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1160 <main+0x40>
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 = [4 x i8] c"%i \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %2
br label %5
5: ; preds = %30, %0
%6 = load i32, i32* %2
%7 = icmp sle i32 %6, 50
br i1 %7, label %8, label %33
8: ; preds = %5
store i32 1, i32* %4
store i32 2, i32* %3
br label %9
9: ; preds = %26, %8
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = srem i32 %14, %15
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13
store i32 0, i32* %4
br label %19
19: ; preds = %18, %13
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32, i32* %2
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %22, %19
br label %26
26: ; preds = %25
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %9
29: ; preds = %9
br label %30
30: ; preds = %29
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %5
33: ; preds = %5
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

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