#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 arithderivative(int *, int);
int atoi(char *);
int prime(int *, int, int (*)(int *, int), int);
int primegen(int *, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  int num, arithder;
  int primes[20];
  int primeseed[50];
  num = atoi(argv[1]);
  int primelen = primegen(primeseed, 50);
  int len = prime(primes, num, primegen, primelen);
  if (len == 1) {
    arithder = 1;
  } else {
    arithder = arithderivative(primes, len);
  }
  printf("%d", arithder);
  return arithder;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    -0x140(%rbp),%rdi
mov    $0x32,%esi
call   1070 <primegen@plt>
mov    %eax,-0x144(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x144(%rbp),%ecx
mov    0x2e54(%rip),%rdx
call   1040 <prime@plt>
mov    %eax,-0x148(%rbp)
cmpl   $0x1,-0x148(%rbp)
jne    11b8 <main+0x78>
movl   $0x1,-0x18(%rbp)
jmp    11ca <main+0x8a>
lea    -0x70(%rbp),%rdi
mov    -0x148(%rbp),%esi
call   1060 <arithderivative@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe2c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x120,%rsp
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
lea    0x50(%rsp),%rdi
mov    $0x32,%esi
call   1070 <primegen@plt>
mov    0x2e7f(%rip),%rdx
mov    %rsp,%rdi
mov    %ebx,%esi
mov    %eax,%ecx
call   1040 <prime@plt>
mov    $0x1,%ebx
cmp    $0x1,%eax
je     118b <main+0x4b>
mov    %rsp,%rdi
mov    %eax,%esi
call   1060 <arithderivative@plt>
mov    %eax,%ebx
lea    0xe6e(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x120,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\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 [20 x i32]
%9 = alloca [50 x i32]
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %6
%16 = getelementptr inbounds [50 x i32], [50 x i32]* %9, i64 0, i64 0
%17 = call i32 @primegen(i32* %16, i32 50)
store i32 %17, i32* %10
%18 = getelementptr inbounds [20 x i32], [20 x i32]* %8, i64 0, i64 0
%19 = load i32, i32* %6
%20 = load i32, i32* %10
%21 = call i32 @prime(i32* %18, i32 %19, i32 (i32*, i32)* @primegen, i32 %20)
store i32 %21, i32* %11
%22 = load i32, i32* %11
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %25
24: ; preds = %2
store i32 1, i32* %7
br label %29
25: ; preds = %2
%26 = getelementptr inbounds [20 x i32], [20 x i32]* %8, i64 0, i64 0
%27 = load i32, i32* %11
%28 = call i32 @arithderivative(i32* %26, i32 %27)
store i32 %28, i32* %7
br label %29
29: ; preds = %25, %24
%30 = load i32, i32* %7
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %7
ret i32 %32
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i32]
%4 = alloca [50 x i32]
%5 = bitcast [20 x i32]* %3 to i8*
%6 = bitcast [50 x i32]* %4 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%11 = call i32 @primegen(i32* %10, i32 50)
%12 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%13 = call i32 @prime(i32* %12, i32 %9, i32 (i32*, i32)* @primegen, i32 %11)
%14 = icmp eq i32 %13, 1
br i1 %14, label %17, label %15
15: ; preds = %2
%16 = call i32 @arithderivative(i32* %12, i32 %13)
br label %17
17: ; preds = %2, %15
%18 = phi i32 [ %16, %15 ], [ 1, %2 ]
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
ret i32 %18
}