#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ *stdout;
void print_prime(const int start, const int end) {
  int i, j, k = 0;
  FILE *f = NULL;
  f = stdout;
  f = fopen("prime.txt", "w+");
  fprintf(f,
          "************************Print Prime*****************************\n");
  for (i = start; i <= end; ++i) {
    for (j = 2; j < i; ++j) {
      if (i % j == 0) {
        break;
      }
    }
    if (j == i) {
      k++;
      fprintf(f, "%d\t", i);
      if (k % 10 == 0) {
        fprintf(f, "\n");
      }
    }
  }
  fprintf(f, "\n*****************Print Prime Over*************************\n");
  fclose(f);
}


x86 assembly (clang, -O0):
<print_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2e8c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
lea    0xe9e(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1239 <print_prime+0x109>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d1 <print_prime+0xa1>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    11be <print_prime+0x8e>
jmp    11d1 <print_prime+0xa1>
jmp    11c3 <print_prime+0x93>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119d <print_prime+0x6d>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1226 <print_prime+0xf6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe5b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1221 <print_prime+0xf1>
mov    -0x20(%rbp),%rdi
lea    0xe33(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1226 <print_prime+0xf6>
jmp    122b <print_prime+0xfb>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118a <print_prime+0x5a>
mov    -0x20(%rbp),%rdi
lea    0xe0f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_prime>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r12d
mov    %edi,%ebx
lea    0xe9c(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xe93(%rip),%rdi
mov    $0x41,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1070 <fwrite@plt>
cmp    %r12d,%ebx
jle    11ba <print_prime+0x6a>
lea    0xebb(%rip),%rdi
mov    $0x3c,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1070 <fwrite@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
lea    0xe8e(%rip),%r15
xor    %ebp,%ebp
jmp    11da <print_prime+0x8a>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rbx),%eax
cmp    %r12d,%ebx
mov    %eax,%ebx
je     1191 <print_prime+0x41>
mov    $0x2,%ecx
cmp    $0x3,%ebx
jl     1210 <print_prime+0xc0>
mov    $0x2,%ecx
nopl   0x0(%rax)
mov    %ebx,%eax
cltd
idiv   %ecx
test   %edx,%edx
je     1210 <print_prime+0xc0>
add    $0x1,%ecx
cmp    %ecx,%ebx
jne    11f0 <print_prime+0xa0>
jmp    1214 <print_prime+0xc4>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %ebx,%ecx
jne    11d0 <print_prime+0x80>
add    $0x1,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
imul   $0xcccccccd,%ebp,%eax
add    $0x19999998,%eax
ror    %eax
cmp    $0x19999998,%eax
ja     11d0 <print_prime+0x80>
mov    $0xa,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
jmp    11d0 <print_prime+0x80>

LLVM IR (-O0):
@stdout = global i32* null
@.str = [10 x i8] c"prime.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [66 x i8] c"************************Print Prime*****************************\0A\00"
@.str.3 = [4 x i8] c"%d\09\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [61 x i8] c"\0A*****************Print Prime Over*************************\0A\00"
define void @print_prime(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %7
store i32* null, i32** %8
%9 = load i32*, i32** @stdout
store i32* %9, i32** %8
%10 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %8
%11 = load i32*, i32** %8
%12 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32, i32* %3
store i32 %13, i32* %5
br label %14
14: ; preds = %51, %2
%15 = load i32, i32* %5
%16 = load i32, i32* %4
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %54
18: ; preds = %14
store i32 2, i32* %6
br label %19
19: ; preds = %30, %18
%20 = load i32, i32* %6
%21 = load i32, i32* %5
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %33
23: ; preds = %19
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = srem i32 %24, %25
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23
br label %33
29: ; preds = %23
br label %30
30: ; preds = %29
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %19
33: ; preds = %28, %19
%34 = load i32, i32* %6
%35 = load i32, i32* %5
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %50
37: ; preds = %33
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
%40 = load i32*, i32** %8
%41 = load i32, i32* %5
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %7
%44 = srem i32 %43, 10
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %37
%47 = load i32*, i32** %8
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %49
49: ; preds = %46, %37
br label %50
50: ; preds = %49, %33
br label %51
51: ; preds = %50
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 1
store i32 %53, i32* %5
br label %14
54: ; preds = %14
%55 = load i32*, i32** %8
%56 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.5, i64 0, i64 0))
%57 = load i32*, i32** %8
%58 = call i32 @fclose(i32* %57)
ret void
}

LLVM IR (-O2):
@stdout = global i32* null
@.str = [10 x i8] c"prime.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [66 x i8] c"************************Print Prime*****************************\0A\00"
@.str.3 = [4 x i8] c"%d\09\00"
@.str.5 = [61 x i8] c"\0A*****************Print Prime Over*************************\0A\00"
define void @print_prime(i32 %0, i32 %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i64 @fwrite(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0), i64 65, i64 1, i32* %3)
%5 = icmp sgt i32 %0, %1
br i1 %5, label %31, label %6
6: ; preds = %2, %27
%7 = phi i32 [ %28, %27 ], [ 0, %2 ]
%8 = phi i32 [ %29, %27 ], [ %0, %2 ]
%9 = icmp sgt i32 %8, 2
br i1 %9, label %10, label %17
10: ; preds = %6, %14
%11 = phi i32 [ %15, %14 ], [ 2, %6 ]
%12 = srem i32 %8, %11
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = add nuw nsw i32 %11, 1
%16 = icmp eq i32 %15, %8
br i1 %16, label %20, label %10
17: ; preds = %10, %6
%18 = phi i32 [ 2, %6 ], [ %11, %10 ]
%19 = icmp eq i32 %18, %8
br i1 %19, label %20, label %27
20: ; preds = %14, %17
%21 = add nsw i32 %7, 1
%22 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%23 = srem i32 %21, 10
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = tail call i32 @fputc(i32 10, i32* %3)
br label %27
27: ; preds = %17, %25, %20
%28 = phi i32 [ %21, %25 ], [ %21, %20 ], [ %7, %17 ]
%29 = add i32 %8, 1
%30 = icmp eq i32 %8, %1
br i1 %30, label %31, label %6
31: ; preds = %27, %2
%32 = tail call i64 @fwrite(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.5, i64 0, i64 0), i64 60, i64 1, i32* %3)
%33 = tail call i32 @fclose(i32* %3)
ret void
}