#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 /*<<< orphan*/ act_on_choice(unsigned long, unsigned long);
int /*<<< orphan*/ do_output(unsigned long, char *);
unsigned long get_choice();
unsigned long get_unsignedlong(char *, int);
int /*<<< orphan*/ openfile(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ set_random();
int main() {
  char filename[100];
  unsigned long numpoints, choice;
  set_random();
  openfile(filename);
  numpoints = get_unsignedlong("Enter the # of points : ", 1000000);
  choice = get_choice();
  act_on_choice(choice, numpoints);
  do_output(numpoints, filename);
  printf("datagen finished properly with data in %s\n", filename);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <set_random@plt>
lea    -0x70(%rbp),%rdi
call   1030 <openfile@plt>
lea    0xe67(%rip),%rdi
mov    $0xf4240,%esi
call   1070 <get_unsignedlong@plt>
mov    %rax,-0x78(%rbp)
mov    $0x0,%al
call   1080 <get_choice@plt>
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   1050 <act_on_choice@plt>
mov    -0x78(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1090 <do_output@plt>
lea    -0x70(%rbp),%rsi
lea    0xe42(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
xor    %eax,%eax
call   1040 <set_random@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <openfile@plt>
lea    0xe70(%rip),%rdi
mov    $0xf4240,%esi
call   1070 <get_unsignedlong@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <get_choice@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <act_on_choice@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <do_output@plt>
lea    0xe58(%rip),%rdi
mov    %r14,%rsi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Enter the # of points : \00"
@.str.1 = [43 x i8] c"datagen finished properly with data in %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
%5 = call i32 (...) @set_random()
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = call i32 @openfile(i8* %6)
%8 = call i64 @get_unsignedlong(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 1000000)
store i64 %8, i64* %3
%9 = call i64 (...) @get_choice()
store i64 %9, i64* %4
%10 = load i64, i64* %4
%11 = load i64, i64* %3
%12 = call i32 @act_on_choice(i64 %10, i64 %11)
%13 = load i64, i64* %3
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = call i32 @do_output(i64 %13, i8* %14)
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Enter the # of points : \00"
@.str.1 = [43 x i8] c"datagen finished properly with data in %s\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @set_random()
%4 = call i32 @openfile(i8* %2)
%5 = call i64 @get_unsignedlong(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 1000000)
%6 = call i64 (...) @get_choice()
%7 = call i32 @act_on_choice(i64 %6, i64 %5)
%8 = call i32 @do_output(i64 %5, i8* %2)
%9 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i32 0
}