#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);
int check_prime(int num) {
  for (int j = 2; j < num; j++) {
    if (num % j == 0) {
      break;
    }
    if (num % j != 0) {
      if (j == num - 1) {
        printf("%d ", num);
      }
    }
  }
}


x86 assembly (clang, -O0):
<check_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118b <check_prime+0x7b>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1143 <check_prime+0x33>
jmp    118b <check_prime+0x7b>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
je     1178 <check_prime+0x68>
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1173 <check_prime+0x63>
mov    -0x8(%rbp),%esi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
jmp    1178 <check_prime+0x68>
jmp    117d <check_prime+0x6d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1122 <check_prime+0x12>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_prime>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jl     1168 <check_prime+0x58>
mov    %edi,%r15d
mov    %edi,%ebx
neg    %ebx
mov    $0x2,%ebp
lea    0xed1(%rip),%r14
jmp    1149 <check_prime+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %ebx,%eax
add    %ebp,%eax
je     1168 <check_prime+0x58>
mov    %r15d,%eax
cltd
idiv   %ebp
test   %edx,%edx
je     1168 <check_prime+0x58>
lea    (%rbx,%rbp,1),%eax
cmp    $0xffffffff,%eax
jne    1140 <check_prime+0x30>
mov    %r14,%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
jmp    1140 <check_prime+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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