#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 */
unsigned long nextprime(unsigned long);
int /*<<< orphan*/ printf(char *, int, unsigned long);
void *strtoul(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  unsigned long number;
  int i;
  int j;
  number = strtoul(argv[1], NULL, 10);
  j = strtoul(argv[2], NULL, 10);
  for (i = 1; i <= j; ++i) {
    number = nextprime(number);
    printf("%d: %ld\n", i, number);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %eax,-0x20(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     11ba <main+0x8a>
mov    -0x18(%rbp),%rdi
call   1040 <nextprime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rdx
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %rax,%r12
mov    0x10(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %rax,%r14
test   %r14d,%r14d
jle    11ab <main+0x7b>
neg    %r14d
mov    $0x1,%ebx
lea    0xe8b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
call   1040 <nextprime@plt>
mov    %rax,%r12
mov    %r15,%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1180 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d: %ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i8* @strtoul(i8* %11, i32* null, i32 10)
%13 = ptrtoint i8* %12 to i64
store i64 %13, i64* %6
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i8* @strtoul(i8* %16, i32* null, i32 10)
%18 = ptrtoint i8* %17 to i32
store i32 %18, i32* %8
store i32 1, i32* %7
br label %19
19: ; preds = %29, %2
%20 = load i32, i32* %7
%21 = load i32, i32* %8
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = load i64, i64* %6
%25 = call i64 @nextprime(i64 %24)
store i64 %25, i64* %6
%26 = load i32, i32* %7
%27 = load i64, i64* %6
%28 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %26, i64 %27)
br label %29
29: ; preds = %23
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %19
32: ; preds = %19
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d: %ld\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i8* @strtoul(i8* nocapture %4, i32* null, i32 10)
%6 = getelementptr inbounds i8*, i8** %1, i64 2
%7 = load i8*, i8** %6
%8 = tail call i8* @strtoul(i8* nocapture %7, i32* null, i32 10)
%9 = ptrtoint i8* %8 to i64
%10 = trunc i64 %9 to i32
%11 = icmp slt i32 %10, 1
br i1 %11, label %21, label %12
12: ; preds = %2
%13 = ptrtoint i8* %5 to i64
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ %17, %14 ], [ %13, %12 ]
%16 = phi i32 [ %19, %14 ], [ 1, %12 ]
%17 = tail call i64 @nextprime(i64 %15)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %16, i64 %17)
%19 = add nuw i32 %16, 1
%20 = icmp eq i32 %16, %10
br i1 %20, label %21, label %14
21: ; preds = %14, %2
ret i32 0
}