#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 awalPrima, akhirPrima, tidakPrima, i;
  printf("Program ini akan menampilkan angka prima dari 1-N\n");
  printf("Sampai angka berapa akan ditampilkan? ");
  scanf("%d", &akhirPrima);
  awalPrima = 2;
  while (awalPrima < akhirPrima) {
    tidakPrima = 0;
    for (i = 2; i <= awalPrima / 2; ++i) {
      if (awalPrima % i == 0) {
        tidakPrima = 1;
        break;
      }
    }
    if (tidakPrima == 0) {
      printf("%d ", awalPrima);
    }
    ++awalPrima;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf08(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f2 <main+0xd2>
movl   $0x0,-0x10(%rbp)
movl   $0x2,-0x14(%rbp)
mov    -0x14(%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     11c9 <main+0xa9>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
jne    11b6 <main+0x96>
movl   $0x1,-0x10(%rbp)
jmp    11c9 <main+0xa9>
jmp    11bb <main+0x9b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117c <main+0x5c>
cmpl   $0x0,-0x10(%rbp)
jne    11e4 <main+0xc4>
mov    -0x8(%rbp),%esi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1162 <main+0x42>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xece(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ecx
cmp    $0x3,%ecx
jl     11ce <main+0x9e>
mov    $0x2,%ebx
lea    0xeb2(%rip),%r14
mov    $0x2,%ebp
jmp    1197 <main+0x67>
nop
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%ecx
add    $0x1,%ebp
cmp    %ecx,%ebp
jge    11ce <main+0x9e>
mov    %ebp,%esi
shr    %esi
cmp    $0x3,%esi
cmovb  %ebx,%esi
cmp    $0x4,%ebp
jb     1180 <main+0x50>
neg    %esi
mov    $0x2,%edi
nopl   (%rax)
mov    %ebp,%eax
xor    %edx,%edx
div    %edi
test   %edx,%edx
je     1190 <main+0x60>
lea    (%rsi,%rdi,1),%eax
add    $0x1,%eax
mov    %edi,%edx
add    $0x1,%edx
mov    %edx,%edi
cmp    $0x1,%eax
jne    11b0 <main+0x80>
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [51 x i8] c"Program ini akan menampilkan angka prima dari 1-N\0A\00"
@.str.1 = [39 x i8] c"Sampai angka berapa akan ditampilkan? \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
store i32 2, i32* %2
br label %9
9: ; preds = %35, %0
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %38
13: ; preds = %9
store i32 0, i32* %4
store i32 2, i32* %5
br label %14
14: ; preds = %26, %13
%15 = load i32, i32* %5
%16 = load i32, i32* %2
%17 = sdiv i32 %16, 2
%18 = icmp sle i32 %15, %17
br i1 %18, label %19, label %29
19: ; preds = %14
%20 = load i32, i32* %2
%21 = load i32, i32* %5
%22 = srem i32 %20, %21
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19
store i32 1, i32* %4
br label %29
25: ; preds = %19
br label %26
26: ; preds = %25
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %14
29: ; preds = %24, %14
%30 = load i32, i32* %4
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* %2
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %32, %29
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
store i32 %37, i32* %2
br label %9
38: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [39 x i8] c"Sampai angka berapa akan ditampilkan? \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d \00"
@str = [50 x i8] c"Program ini akan menampilkan angka prima dari 1-N\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 2
br i1 %7, label %8, label %28
8: ; preds = %0, %24
%9 = phi i32 [ %25, %24 ], [ %6, %0 ]
%10 = phi i32 [ %26, %24 ], [ 2, %0 ]
%11 = lshr i32 %10, 1
%12 = call i32 @llvm.umax.i32(i32 %11, i32 2)
%13 = icmp ult i32 %10, 4
br i1 %13, label %21, label %17
14: ; preds = %17
%15 = add nuw nsw i32 %18, 1
%16 = icmp eq i32 %18, %12
br i1 %16, label %21, label %17
17: ; preds = %8, %14
%18 = phi i32 [ %15, %14 ], [ 2, %8 ]
%19 = urem i32 %10, %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %14
21: ; preds = %14, %8
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%23 = load i32, i32* %1
br label %24
24: ; preds = %17, %21
%25 = phi i32 [ %23, %21 ], [ %9, %17 ]
%26 = add nuw nsw i32 %10, 1
%27 = icmp slt i32 %26, %25
br i1 %27, label %8, label %28
28: ; preds = %24, %0
ret i32 0
}