#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, i, count = 0, jest_pierwsza;
  printf("Podaj liczbę calkowitą: ");
  scanf("%d\n", &n);
  for (i = 2; i <= n / 2; i++) {
    if (n % i == 0) {
      count++;
      break;
    }
  }
  if (count == 0 && n != 1) {
    jest_pierwsza = 1;
  } else {
    jest_pierwsza = 0;
  }
  printf("Podana liczba \"%d\" jest %s\n", n,
         jest_pierwsza ? "pierwsza" : "złożona");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jg     11aa <main+0x8a>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1197 <main+0x77>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11aa <main+0x8a>
jmp    119c <main+0x7c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115b <main+0x3b>
cmpl   $0x0,-0x10(%rbp)
jne    11ca <main+0xaa>
cmpl   $0x1,-0x8(%rbp)
je     11ca <main+0xaa>
movl   $0x1,-0x14(%rbp)
jmp    11d1 <main+0xb1>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%ecx
lea    0xe66(%rip),%rdx
lea    0xe56(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%r9d
mov    $0x1,%al
cmp    $0x4,%r9d
jl     1199 <main+0x79>
mov    %r9d,%r8d
shr    $0x1f,%r8d
add    %r9d,%r8d
sar    %r8d
cmp    $0x3,%r8d
mov    $0x2,%ecx
mov    $0x2,%edi
cmovge %r8d,%edi
test   $0x1,%r9b
jne    1180 <main+0x60>
xor    %eax,%eax
jmp    1199 <main+0x79>
cs nopw 0x0(%rax,%rax,1)
mov    %ecx,%esi
cmp    %ecx,%edi
je     1193 <main+0x73>
lea    0x1(%rsi),%ecx
mov    %r9d,%eax
cltd
idiv   %ecx
test   %edx,%edx
jne    1180 <main+0x60>
cmp    %r8d,%esi
setge  %al
lea    0xe9b(%rip),%rdx
lea    0xe9d(%rip),%rcx
test   %al,%al
cmove  %rcx,%rdx
cmp    $0x1,%r9d
cmove  %rcx,%rdx
lea    0xe63(%rip),%rdi
mov    %r9d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Podaj liczb\C4\99 calkowit\C4\85: \00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [28 x i8] c"Podana liczba \22%d\22 jest %s\0A\00"
@.str.3 = [9 x i8] c"pierwsza\00"
@.str.4 = [10 x i8] c"z\C5\82o\C5\BCona\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 2, i32* %3
br label %8
8: ; preds = %22, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = sdiv i32 %10, 2
%12 = icmp sle i32 %9, %11
br i1 %12, label %13, label %25
13: ; preds = %8
%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 %21
18: ; preds = %13
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %25
21: ; preds = %13
br label %22
22: ; preds = %21
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %8
25: ; preds = %18, %8
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i32, i32* %2
%30 = icmp ne i32 %29, 1
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 1, i32* %5
br label %33
32: ; preds = %28, %25
store i32 0, i32* %5
br label %33
33: ; preds = %32, %31
%34 = load i32, i32* %2
%35 = load i32, i32* %5
%36 = icmp ne i32 %35, 0
%37 = zext i1 %36 to i64
%38 = select i1 %36, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %34, i8* %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Podaj liczb\C4\99 calkowit\C4\85: \00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [28 x i8] c"Podana liczba \22%d\22 jest %s\0A\00"
@.str.3 = [9 x i8] c"pierwsza\00"
@.str.4 = [10 x i8] c"z\C5\82o\C5\BCona\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = sdiv i32 %5, 2
%7 = icmp slt i32 %5, 4
br i1 %7, label %21, label %8
8: ; preds = %0
%9 = call i32 @llvm.smax.i32(i32 %6, i32 2)
%10 = and i32 %5, 1
%11 = icmp eq i32 %10, 0
br i1 %11, label %21, label %12
12: ; preds = %8, %16
%13 = phi i32 [ %14, %16 ], [ 2, %8 ]
%14 = add nuw nsw i32 %13, 1
%15 = icmp eq i32 %13, %9
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = srem i32 %5, %14
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %12
19: ; preds = %12, %16
%20 = icmp sge i32 %13, %6
br label %21
21: ; preds = %19, %8, %0
%22 = phi i1 [ true, %0 ], [ false, %8 ], [ %20, %19 ]
%23 = icmp ne i32 %5, 1
%24 = and i1 %23, %22
%25 = select i1 %24, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %5, i8* %25)
ret i32 0
}