#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 _ada_use_c2phc(int, int *, int *, double *);
int /*<<< orphan*/ adafinal();
int /*<<< orphan*/ adainit();
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  printf("\nTesting using PHCpack from within C ...\n");
  adainit();
  {
    int fail, choice = 0;
    int *a, *b;
    double *c;
    char skip_newline;
    do {
      fail = _ada_use_c2phc(choice, a, b, c);
      printf("Give a number (0 for menu, -1 to exit) : ");
      scanf("%d", &choice);
      skip_newline = getchar();
    } while (choice >= 0);
  }
  adafinal();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1080 <adainit@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1060 <_ada_use_c2phc@plt>
mov    %eax,-0x8(%rbp)
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x29(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1189 <main+0x29>
mov    $0x0,%al
call   1050 <adafinal@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1090 <adainit@plt>
movl   $0x0,0xc(%rsp)
lea    0xe65(%rip),%r14
lea    0xe88(%rip),%r15
lea    0xc(%rsp),%rbx
xor    %edi,%edi
nopl   0x0(%rax)
call   1070 <_ada_use_c2phc@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
jns    11b0 <main+0x40>
xor    %eax,%eax
call   1060 <adafinal@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [42 x i8] c"\0ATesting using PHCpack from within C ...\0A\00"
@.str.1 = [42 x i8] c"Give a number (0 for menu, -1 to exit) : \00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca double*
%7 = alloca i8
store i32 0, i32* %1
%8 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @adainit()
store i32 0, i32* %3
br label %10
10: ; preds = %19, %0
%11 = load i32, i32* %3
%12 = load i32*, i32** %4
%13 = load i32*, i32** %5
%14 = load double*, double** %6
%15 = call i32 @_ada_use_c2phc(i32 %11, i32* %12, i32* %13, double* %14)
store i32 %15, i32* %2
%16 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%18 = call signext i8 (...) @getchar()
store i8 %18, i8* %7
br label %19
19: ; preds = %10
%20 = load i32, i32* %3
%21 = icmp sge i32 %20, 0
br i1 %21, label %10, label %22
22: ; preds = %19
%23 = call i32 (...) @adafinal()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [42 x i8] c"Give a number (0 for menu, -1 to exit) : \00"
@.str.2 = [3 x i8] c"%d\00"
@str = [41 x i8] c"\0ATesting using PHCpack from within C ...\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (...) @adainit()
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %5
5: ; preds = %5, %0
%6 = phi i32 [ %11, %5 ], [ 0, %0 ]
%7 = call i32 @_ada_use_c2phc(i32 %6, i32* undef, i32* undef, double* undef)
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%10 = call signext i8 (...) @getchar()
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, -1
br i1 %12, label %5, label %13
13: ; preds = %5
%14 = call i32 (...) @adafinal()
ret i32 0
}