#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*/ adafinal();
int /*<<< orphan*/ adainit();
int /*<<< orphan*/ printf(char *, ...);
int read_line(char *);
int scan_number_of_variables(int, char *, int *);
int strlen(char *);
int main(void) {
  char pols[80];
  int nb, nbc, k, dim, fail;
  adainit();
  printf("Give one string with all polyomials in the system,\n");
  printf("each polynomial is terminated by a semi colon;\n");
  printf("Enter your system : ");
  nb = read_line(pols);
  nbc = strlen(pols);
  printf("Number of characters : %d\n", nb);
  printf("Number of characters : %d\n", nbc);
  printf("Your system : ");
  for (k = 0; k < nb; k++)
    printf("%c", pols[k]);
  printf("\n");
  fail = scan_number_of_variables(nb, pols, &dim);
  printf("fail : %d, dimension : %d\n", fail, dim);
  adafinal();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <adainit@plt>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1080 <read_line@plt>
mov    %eax,-0x64(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x68(%rbp)
mov    -0x64(%rbp),%esi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x68(%rbp),%esi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    1223 <main+0xc3>
movslq -0x6c(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    11f2 <main+0x92>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x64(%rbp),%edi
lea    -0x60(%rbp),%rsi
lea    -0x70(%rbp),%rdx
call   1030 <scan_number_of_variables@plt>
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%esi
mov    -0x70(%rbp),%edx
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <adafinal@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
xor    %eax,%eax
call   1090 <adainit@plt>
lea    0xec2(%rip),%rdi
call   1040 <puts@plt>
lea    0xee9(%rip),%rdi
call   1040 <puts@plt>
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   10a0 <read_line@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
lea    0xe3d(%rip),%r14
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe38(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
test   %r15d,%r15d
jle    1223 <main+0xa3>
mov    %r15d,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
movsbl 0x10(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1210 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %r15d,%edi
call   1050 <scan_number_of_variables@plt>
mov    0xc(%rsp),%edx
lea    0xdf5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1080 <adafinal@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [52 x i8] c"Give one string with all polyomials in the system,\0A\00"
@.str.1 = [48 x i8] c"each polynomial is terminated by a semi colon;\0A\00"
@.str.2 = [21 x i8] c"Enter your system : \00"
@.str.3 = [27 x i8] c"Number of characters : %d\0A\00"
@.str.4 = [15 x i8] c"Your system : \00"
@.str.5 = [3 x i8] c"%c\00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [27 x i8] c"fail : %d, dimension : %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (...) @adainit()
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%13 = call i32 @read_line(i8* %12)
store i32 %13, i32* %3
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %4
%16 = load i32, i32* %3
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %5
br label %21
21: ; preds = %32, %0
%22 = load i32, i32* %5
%23 = load i32, i32* %3
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %35
25: ; preds = %21
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %25
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %21
35: ; preds = %21
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%37 = load i32, i32* %3
%38 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%39 = call i32 @scan_number_of_variables(i32 %37, i8* %38, i32* %6)
store i32 %39, i32* %7
%40 = load i32, i32* %7
%41 = load i32, i32* %6
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %40, i32 %41)
%43 = call i32 (...) @adafinal()
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [21 x i8] c"Enter your system : \00"
@.str.3 = [27 x i8] c"Number of characters : %d\0A\00"
@.str.4 = [15 x i8] c"Your system : \00"
@.str.7 = [27 x i8] c"fail : %d, dimension : %d\0A\00"
@str = [51 x i8] c"Give one string with all polyomials in the system,\00"
@str.8 = [47 x i8] c"each polynomial is terminated by a semi colon;\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (...) @adainit()
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.8, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @read_line(i8* %3)
%10 = call i32 @strlen(i8* %3)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%14 = icmp sgt i32 %9, 0
br i1 %14, label %15, label %25
15: ; preds = %0
%16 = zext i32 %9 to i64
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 0, %15 ], [ %23, %17 ]
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = call i32 @putchar(i32 %21)
%23 = add nuw nsw i64 %18, 1
%24 = icmp eq i64 %23, %16
br i1 %24, label %25, label %17
25: ; preds = %17, %0
%26 = call i32 @putchar(i32 10)
%27 = call i32 @scan_number_of_variables(i32 %9, i8* %3, i32* %2)
%28 = load i32, i32* %2
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %27, i32 %28)
%30 = call i32 (...) @adafinal()
ret i32 0
}