#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 printf(char *, int);
int jest_pierwsza(int n) {
  if (n < 2)
    return printf("Liczba %d nie jest pierwsza\n", n);
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0)
      return printf("Liczba %d nie jest liczba pierwsza\n", n);
  return printf("Liczba %d jest liszba pierwsza\n", n);
}


x86 assembly (clang, -O0):
<jest_pierwsza>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    113c <jest_pierwsza+0x2c>
mov    -0x8(%rbp),%esi
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
mov    %eax,-0x4(%rbp)
jmp    119f <jest_pierwsza+0x8f>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     118d <jest_pierwsza+0x7d>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    117a <jest_pierwsza+0x6a>
mov    -0x8(%rbp),%esi
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
mov    %eax,-0x4(%rbp)
jmp    119f <jest_pierwsza+0x8f>
jmp    117f <jest_pierwsza+0x6f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <jest_pierwsza+0x33>
mov    -0x8(%rbp),%esi
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jest_pierwsza>:
mov    %edi,%esi
cmp    $0x2,%edi
jge    1123 <jest_pierwsza+0x13>
lea    0xee2(%rip),%rdi
jmp    1030 <printf@plt>
lea    0xf17(%rip),%rdi
cmp    $0x4,%esi
jb     1155 <jest_pierwsza+0x45>
mov    $0x2,%ecx
lea    0xee2(%rip),%r8
nopl   0x0(%rax,%rax,1)
mov    %esi,%eax
cltd
idiv   %ecx
test   %edx,%edx
je     115a <jest_pierwsza+0x4a>
add    $0x1,%ecx
mov    %ecx,%eax
imul   %ecx,%eax
cmp    %esi,%eax
jle    1140 <jest_pierwsza+0x30>
jmp    1030 <printf@plt>
mov    %r8,%rdi
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [29 x i8] c"Liczba %d nie jest pierwsza\0A\00"
@.str.1 = [36 x i8] c"Liczba %d nie jest liczba pierwsza\0A\00"
@.str.2 = [32 x i8] c"Liczba %d jest liszba pierwsza\0A\00"
define i32 @jest_pierwsza(i32 %0) {
%2 = icmp slt i32 %0, 2
br i1 %2, label %13, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 4
br i1 %4, label %13, label %8
5: ; preds = %8
%6 = mul nsw i32 %12, %12
%7 = icmp sgt i32 %6, %0
br i1 %7, label %13, label %8
8: ; preds = %3, %5
%9 = phi i32 [ %12, %5 ], [ 2, %3 ]
%10 = srem i32 %0, %9
%11 = icmp eq i32 %10, 0
%12 = add nuw nsw i32 %9, 1
br i1 %11, label %13, label %5
13: ; preds = %5, %8, %3, %1
%14 = phi i8* [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), %8 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), %5 ]
%15 = tail call i32 @printf(i8* %14, i32 %0)
ret i32 %15
}