#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 */
typedef int /*<<< orphan*/ time_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  if (argc < 2)
    return 1;
  int n, i, flag = 0;
  time_t t;
  srand((unsigned)time(&t));
  n = argv[1][0];
  for (i = 2; i <= n / 2; ++i) {
    if (n % i == 0) {
      flag = 1;
      break;
    }
  }
  if (flag == 0)
    printf("%d is a prime number.\n", n);
  else
    printf("%d is not a prime number.\n", n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    115c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    1209 <main+0xd9>
movl   $0x0,-0x1c(%rbp)
lea    -0x20(%rbp),%rdi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jg     11d5 <main+0xa5>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
cmp    $0x0,%edx
jne    11c2 <main+0x92>
movl   $0x1,-0x1c(%rbp)
jmp    11d5 <main+0xa5>
jmp    11c7 <main+0x97>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1188 <main+0x58>
cmpl   $0x0,-0x1c(%rbp)
jne    11f3 <main+0xc3>
mov    -0x14(%rbp),%esi
lea    0xe17(%rip),%rdi
call   1030 <printf@plt>
jmp    1202 <main+0xd2>
mov    -0x14(%rbp),%esi
lea    0xe1a(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x1,%eax
cmp    $0x2,%edi
jl     11b8 <main+0x88>
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0xc(%rsp),%rdi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    0x8(%rbx),%rax
movsbl (%rax),%esi
lea    0xe9f(%rip),%rdi
cmp    $0x4,%esi
jl     11ac <main+0x7c>
mov    %esi,%eax
shr    $0x7,%al
add    %sil,%al
sar    %al
movzbl %al,%eax
cmp    $0x3,%al
mov    $0x2,%ecx
cmovl  %ecx,%eax
movzbl %al,%ebx
neg    %ebx
lea    0xe8e(%rip),%r8
nopl   0x0(%rax)
mov    %esi,%eax
cltd
idiv   %ecx
test   %edx,%edx
je     11a9 <main+0x79>
lea    (%rbx,%rcx,1),%eax
add    $0x1,%eax
add    $0x1,%ecx
cmp    $0x1,%eax
jne    1190 <main+0x60>
jmp    11ac <main+0x7c>
mov    %r8,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"%d is a prime number.\0A\00"
@.str.1 = [27 x i8] c"%d is not a prime number.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 1, i32* %3
br label %48
13: ; preds = %2
store i32 0, i32* %8
%14 = call i64 @time(i32* %9)
%15 = trunc i64 %14 to i32
%16 = call i32 @srand(i32 %15)
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
store i32 %22, i32* %6
store i32 2, i32* %7
br label %23
23: ; preds = %35, %13
%24 = load i32, i32* %7
%25 = load i32, i32* %6
%26 = sdiv i32 %25, 2
%27 = icmp sle i32 %24, %26
br i1 %27, label %28, label %38
28: ; preds = %23
%29 = load i32, i32* %6
%30 = load i32, i32* %7
%31 = srem i32 %29, %30
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %28
store i32 1, i32* %8
br label %38
34: ; preds = %28
br label %35
35: ; preds = %34
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %23
38: ; preds = %33, %23
%39 = load i32, i32* %8
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* %6
%43 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %42)
br label %47
44: ; preds = %38
%45 = load i32, i32* %6
%46 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %44, %41
store i32 0, i32* %3
br label %48
48: ; preds = %47, %12
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [23 x i8] c"%d is a prime number.\0A\00"
@.str.1 = [27 x i8] c"%d is not a prime number.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp slt i32 %0, 2
br i1 %4, label %29, label %5
5: ; preds = %2
%6 = bitcast i32* %3 to i8*
%7 = call i64 @time(i32* %3)
%8 = trunc i64 %7 to i32
%9 = call i32 @srand(i32 %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp slt i8 %12, 4
br i1 %14, label %26, label %15
15: ; preds = %5
%16 = sdiv i8 %12, 2
%17 = call i8 @llvm.smax.i8(i8 %16, i8 2)
%18 = zext i8 %17 to i32
br label %22
19: ; preds = %22
%20 = add nuw nsw i32 %23, 1
%21 = icmp eq i32 %23, %18
br i1 %21, label %26, label %22
22: ; preds = %15, %19
%23 = phi i32 [ %20, %19 ], [ 2, %15 ]
%24 = srem i32 %13, %23
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %19
26: ; preds = %22, %19, %5
%27 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), %5 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), %19 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), %22 ]
%28 = call i32 @printf(i8* %27, i32 %13)
br label %29
29: ; preds = %2, %26
%30 = phi i32 [ 0, %26 ], [ 1, %2 ]
ret i32 %30
}