#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, is_prime;
  for (p = 2; p <= 50; ++p) {
    if (p % 2 == 0 && p != 0) {
      is_prime = 0;
    }
    is_prime = 1;
    for (d = 2; d < p && is_prime == 1; ++d) {
      if (p % d == 0) {
        is_prime = 0;
      }
    }
    if (is_prime != 0) {
      printf("%i ", p);
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
cmpl   $0x32,-0x8(%rbp)
jg     11e6 <main+0xd6>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1155 <main+0x45>
cmpl   $0x0,-0x8(%rbp)
je     1155 <main+0x45>
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x11(%rbp)
jge    117e <main+0x6e>
cmpl   $0x1,-0x10(%rbp)
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    118e <main+0x7e>
jmp    11b8 <main+0xa8>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11a5 <main+0x95>
movl   $0x0,-0x10(%rbp)
jmp    11aa <main+0x9a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1163 <main+0x53>
cmpl   $0x0,-0x10(%rbp)
je     11d3 <main+0xc3>
mov    -0x8(%rbp),%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d8 <main+0xc8>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1126 <main+0x16>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x2,%ebx
lea    0xed0(%rip),%r14
jmp    1154 <main+0x34>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    $0x33,%ebx
je     117a <main+0x5a>
cmp    $0x3,%ebx
jb     1140 <main+0x20>
mov    $0x3,%ecx
xchg   %ax,%ax
lea    -0x1(%rcx),%esi
mov    %ebx,%eax
xor    %edx,%edx
div    %esi
cmp    %ebx,%ecx
jae    1174 <main+0x54>
add    $0x1,%ecx
test   %edx,%edx
jne    1160 <main+0x40>
test   %edx,%edx
jne    1140 <main+0x20>
jmp    114c <main+0x2c>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
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 = %43, %0
%6 = load i32, i32* %2
%7 = icmp sle i32 %6, 50
br i1 %7, label %8, label %46
8: ; preds = %5
%9 = load i32, i32* %2
%10 = srem i32 %9, 2
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 0, i32* %4
br label %16
16: ; preds = %15, %12, %8
store i32 1, i32* %4
store i32 2, i32* %3
br label %17
17: ; preds = %33, %16
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 1
br label %24
24: ; preds = %21, %17
%25 = phi i1 [ false, %17 ], [ %23, %21 ]
br i1 %25, label %26, label %36
26: ; preds = %24
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = srem i32 %27, %28
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %26
store i32 0, i32* %4
br label %32
32: ; preds = %31, %26
br label %33
33: ; preds = %32
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %17
36: ; preds = %24
%37 = load i32, i32* %4
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load i32, i32* %2
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %39, %36
br label %43
43: ; preds = %42
%44 = load i32, i32* %2
%45 = add nsw i32 %44, 1
store i32 %45, i32* %2
br label %5
46: ; preds = %5
%47 = 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, %14
%2 = phi i32 [ 2, %0 ], [ %15, %14 ]
%3 = icmp ugt i32 %2, 2
br i1 %3, label %4, label %12
4: ; preds = %1, %4
%5 = phi i32 [ %8, %4 ], [ 2, %1 ]
%6 = urem i32 %2, %5
%7 = icmp ne i32 %6, 0
%8 = add nuw nsw i32 %5, 1
%9 = icmp ult i32 %8, %2
%10 = and i1 %9, %7
br i1 %10, label %4, label %11
11: ; preds = %4
br i1 %7, label %12, label %14
12: ; preds = %1, %11
%13 = 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 %14
14: ; preds = %11, %12
%15 = add nuw nsw i32 %2, 1
%16 = icmp eq i32 %15, 51
br i1 %16, label %17, label %1
17: ; preds = %14
%18 = tail call i32 @putchar(i32 10)
ret i32 0
}