#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;
        break;
      }
    }
    if (isPrime) {
      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     11a7 <main+0x97>
movl   $0x1,-0x10(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1179 <main+0x69>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1166 <main+0x56>
movl   $0x0,-0x10(%rbp)
jmp    1179 <main+0x69>
jmp    116b <main+0x5b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113e <main+0x2e>
cmpl   $0x0,-0x10(%rbp)
je     1194 <main+0x84>
mov    -0x8(%rbp),%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1199 <main+0x89>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1126 <main+0x16>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x2,%ebx
lea    0xecf(%rip),%r14
xor    %r15d,%r15d
jmp    1158 <main+0x38>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
add    $0xffffffff,%r15d
cmp    $0x33,%ebx
je     1188 <main+0x68>
cmp    $0x3,%ebx
jb     1140 <main+0x20>
mov    $0x2,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
test   %edx,%edx
je     114c <main+0x2c>
add    $0x1,%ecx
lea    (%r15,%rcx,1),%eax
cmp    $0x2,%eax
jne    1170 <main+0x50>
jmp    1140 <main+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
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 = %20, %8
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %23
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 %23
19: ; preds = %13
br label %20
20: ; preds = %19
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %9
23: ; preds = %18, %9
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %2
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %26, %23
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, %13
%2 = phi i32 [ 2, %0 ], [ %14, %13 ]
%3 = icmp ugt i32 %2, 2
br i1 %3, label %6, label %11
4: ; preds = %6
%5 = icmp eq i32 %10, %2
br i1 %5, label %11, label %6
6: ; preds = %1, %4
%7 = phi i32 [ %10, %4 ], [ 2, %1 ]
%8 = urem i32 %2, %7
%9 = icmp eq i32 %8, 0
%10 = add nuw nsw i32 %7, 1
br i1 %9, label %13, label %4
11: ; preds = %4, %1
%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 = %6, %11
%14 = add nuw nsw i32 %2, 1
%15 = icmp eq i32 %14, 51
br i1 %15, label %16, label %1
16: ; preds = %13
%17 = tail call i32 @putchar(i32 10)
ret i32 0
}