#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 prime(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
void v2(void) {
  int nr;
  bool buffer;
  srand((unsigned)time(NULL));
  nr = rand();
  printf("Let's try with a random number, say %d\n", nr);
  buffer = prime(nr);
  printf("Interestingly.. %d is ", nr);
  if (buffer == true)
    puts("prime!\n");
  else
    puts("not prime!\n");
}


x86 assembly (clang, -O0):
<v2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x0,%al
call   1080 <rand@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe74(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
call   1070 <prime@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    11c6 <v2+0x66>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
jmp    11d2 <v2+0x72>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<v2>:
push   %rbp
push   %rbx
push   %rax
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%ebx
lea    0xe7f(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %ebx,%edi
call   1070 <prime@plt>
mov    %eax,%ebp
lea    0xe90(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
cmp    $0x1,%ebp
lea    0xe9a(%rip),%rax
lea    0xe8f(%rip),%rdi
cmove  %rax,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"Let's try with a random number, say %d\0A\00"
@.str.1 = [23 x i8] c"Interestingly.. %d is \00"
@.str.2 = [8 x i8] c"prime!\0A\00"
@.str.3 = [12 x i8] c"not prime!\0A\00"
define void @v2() {
%1 = alloca i32
%2 = alloca i32
%3 = call i64 @time(i32* null)
%4 = trunc i64 %3 to i32
%5 = call i32 @srand(i32 %4)
%6 = call i32 (...) @rand()
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %1
%10 = call i32 @prime(i32 %9)
store i32 %10, i32* %2
%11 = load i32, i32* %1
%12 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %19
17: ; preds = %0
%18 = call i32 @puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %19
19: ; preds = %17, %15
ret void
}

LLVM IR (-O2):
@.str = [40 x i8] c"Let's try with a random number, say %d\0A\00"
@.str.1 = [23 x i8] c"Interestingly.. %d is \00"
@.str.2 = [8 x i8] c"prime!\0A\00"
@.str.3 = [12 x i8] c"not prime!\0A\00"
define void @v2() {
%1 = tail call i64 @time(i32* null)
%2 = trunc i64 %1 to i32
%3 = tail call i32 @srand(i32 %2)
%4 = tail call i32 (...) @rand()
%5 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i32 @prime(i32 %4)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%8 = icmp eq i32 %6, 1
%9 = select i1 %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0)
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
ret void
}