#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*/ _ada_print_poly(int, char *);
int /*<<< orphan*/ adafinal();
int /*<<< orphan*/ adainit();
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, ...);
int main() {
  int i, n;
  char ch, s[80];
  printf("Give number of variables : ");
  scanf("%d", &n);
  printf("Give a polynomial in %d variables, terminate with ';' :\n", n);
  i = 0;
  ch = ' ';
  while (scanf("%c", &ch) == 1) {
    s[i++] = ch;
    if (ch == ';')
      break;
  }
  s[i] = '\0';
  printf("The polynomial read : %s\n", s);
  printf("Calling Ada... \n");
  adainit();
  _ada_print_poly(n, s);
  adafinal();
  printf("... done with the call.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea8(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0xc(%rbp),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
movb   $0x20,-0xd(%rbp)
lea    0xeb6(%rip),%rdi
lea    -0xd(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    11e1 <main+0x91>
mov    -0xd(%rbp),%cl
mov    -0x8(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
cltq
mov    %cl,-0x60(%rbp,%rax,1)
movsbl -0xd(%rbp),%eax
cmp    $0x3b,%eax
jne    11dc <main+0x8c>
jmp    11e1 <main+0x91>
jmp    119b <main+0x4b>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
lea    -0x60(%rbp),%rsi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <adainit@plt>
mov    -0xc(%rbp),%edi
lea    -0x60(%rbp),%rsi
call   1030 <_ada_print_poly@plt>
mov    $0x0,%al
call   1050 <adafinal@plt>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x20,0xb(%rsp)
lea    0xeb0(%rip),%r14
lea    0xb(%rsp),%r15
xor    %ebx,%ebx
nop
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    11d3 <main+0x73>
movzbl 0xb(%rsp),%eax
mov    %al,0x10(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x3b,%al
jne    11b0 <main+0x50>
movslq %ebx,%rax
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xe79(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe7d(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1080 <adainit@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   1030 <_ada_print_poly@plt>
xor    %eax,%eax
call   1060 <adafinal@plt>
lea    0xe67(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Give number of variables : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [57 x i8] c"Give a polynomial in %d variables, terminate with ';' :\0A\00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [26 x i8] c"The polynomial read : %s\0A\00"
@.str.5 = [17 x i8] c"Calling Ada... \0A\00"
@.str.6 = [25 x i8] c"... done with the call.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca [80 x i8]
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i32 %8)
store i32 0, i32* %2
store i8 32, i8* %4
br label %10
10: ; preds = %23, %0
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %24
13: ; preds = %10
%14 = load i8, i8* %4
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
%17 = sext i32 %15 to i64
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 %17
store i8 %14, i8* %18
%19 = load i8, i8* %4
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 59
br i1 %21, label %22, label %23
22: ; preds = %13
br label %24
23: ; preds = %13
br label %10
24: ; preds = %22, %10
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 %26
store i8 0, i8* %27
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%31 = call i32 (...) @adainit()
%32 = load i32, i32* %3
%33 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%34 = call i32 @_ada_print_poly(i32 %32, i8* %33)
%35 = call i32 (...) @adafinal()
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Give number of variables : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [57 x i8] c"Give a polynomial in %d variables, terminate with ';' :\0A\00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [26 x i8] c"The polynomial read : %s\0A\00"
@str = [16 x i8] c"Calling Ada... \00"
@str.7 = [24 x i8] c"... done with the call.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [80 x i8]
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i32 %8)
store i8 32, i8* %2
br label %10
10: ; preds = %14, %0
%11 = phi i64 [ %16, %14 ], [ 0, %0 ]
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i8, i8* %2
%16 = add nuw i64 %11, 1
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %11
store i8 %15, i8* %17
%18 = icmp eq i8 %15, 59
br i1 %18, label %19, label %10
19: ; preds = %14, %10
%20 = phi i64 [ %16, %14 ], [ %11, %10 ]
%21 = shl i64 %20, 32
%22 = ashr exact i64 %21, 32
%23 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %22
store i8 0, i8* %23
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%26 = call i32 (...) @adainit()
%27 = load i32, i32* %1
%28 = call i32 @_ada_print_poly(i32 %27, i8* %5)
%29 = call i32 (...) @adafinal()
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.7, i64 0, i64 0))
ret i32 0
}