#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_c_to_phcpack(int);
int /*<<< orphan*/ adafinal();
int /*<<< orphan*/ adainit();
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  printf("\nTesting C to PHCpack...\n");
  adainit();
  {
    int fail, choice = 0;
    char skip_newline;
    do {
      fail = _ada_c_to_phcpack(choice);
      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    $0x10,%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
call   1060 <_ada_c_to_phcpack@plt>
mov    %eax,-0x8(%rbp)
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9d(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0xd(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1189 <main+0x29>
mov    $0x0,%al
call   1050 <adafinal@plt>
xor    %eax,%eax
add    $0x10,%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_c_to_phcpack@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 = [26 x i8] c"\0ATesting C to PHCpack...\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 i8
store i32 0, i32* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (...) @adainit()
store i32 0, i32* %3
br label %7
7: ; preds = %13, %0
%8 = load i32, i32* %3
%9 = call i32 @_ada_c_to_phcpack(i32 %8)
store i32 %9, i32* %2
%10 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%12 = call signext i8 (...) @getchar()
store i8 %12, i8* %4
br label %13
13: ; preds = %7
%14 = load i32, i32* %3
%15 = icmp sge i32 %14, 0
br i1 %15, label %7, label %16
16: ; preds = %13
%17 = 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 = [25 x i8] c"\0ATesting C to PHCpack...\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 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_c_to_phcpack(i32 %6)
%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
}