#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*/ printf(char *, ...);
int read_witness_set_from_file(int, char *, int *, int *, int *);
int /*<<< orphan*/ scanf(char *, ...);
int standard_collapse_diagonal(int, int);
scalar_t__ strlen(char *);
int write_witness_set_to_file(int, char *);
int collapse_extrinsic_diagonal(void) {
  int m1, m2, n, dim, deg, add, fail;
  char ch, infile[80], outfile[80];
  scanf("%c", &ch);
  printf("\nReading the name of the file for a witness set...");
  printf("\nGive a string of characters : ");
  scanf("%s", infile);
  m1 = (int)strlen(infile);
  printf("\nReading the name of the output file...");
  printf("\nGive a string of characters : ");
  scanf("%s", outfile);
  m2 = (int)strlen(outfile);
  fail = read_witness_set_from_file(m1, infile, &n, &dim, &deg);
  printf("\nThe current number of slack variables : %d\n", dim);
  printf("Give number of slack variables to add : ");
  scanf("%d", &add);
  fail = standard_collapse_diagonal(dim, add);
  fail = write_witness_set_to_file(m2, outfile);
  return fail;
}


x86 assembly (clang, -O0):
<collapse_extrinsic_diagonal>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
lea    0xe8e(%rip),%rdi
lea    -0x1d(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x4(%rbp)
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xc0(%rbp),%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    -0xc0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x70(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1060 <read_witness_set_from_file@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe9f(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1070 <standard_collapse_diagonal@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
lea    -0xc0(%rbp),%rsi
call   1030 <write_witness_set_to_file@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<collapse_extrinsic_diagonal>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xc8,%rsp
lea    0xe8b(%rip),%rdi
lea    0xf(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea0(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeaf(%rip),%r15
lea    0x70(%rsp),%r12
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x20(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rax,%r15
lea    0x1c(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x18(%rsp),%r8
mov    %ebx,%edi
mov    %r12,%rsi
call   1060 <read_witness_set_from_file@plt>
mov    0x10(%rsp),%esi
lea    0xe64(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0x10(%rsp),%edi
mov    0x14(%rsp),%esi
call   1070 <standard_collapse_diagonal@plt>
mov    %r15d,%edi
mov    %r14,%rsi
call   1030 <write_witness_set_to_file@plt>
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [51 x i8] c"\0AReading the name of the file for a witness set...\00"
@.str.2 = [32 x i8] c"\0AGive a string of characters : \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [40 x i8] c"\0AReading the name of the output file...\00"
@.str.5 = [45 x i8] c"\0AThe current number of slack variables : %d\0A\00"
@.str.6 = [41 x i8] c"Give number of slack variables to add : \00"
@.str.7 = [3 x i8] c"%d\00"
define i32 @collapse_extrinsic_diagonal() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca [80 x i8]
%10 = alloca [80 x i8]
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%17 = call i64 @strlen(i8* %16)
%18 = trunc i64 %17 to i32
store i32 %18, i32* %1
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%24 = call i64 @strlen(i8* %23)
%25 = trunc i64 %24 to i32
store i32 %25, i32* %2
%26 = load i32, i32* %1
%27 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%28 = call i32 @read_witness_set_from_file(i32 %26, i8* %27, i32* %3, i32* %4, i32* %5)
store i32 %28, i32* %7
%29 = load i32, i32* %4
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %6)
%33 = load i32, i32* %4
%34 = load i32, i32* %6
%35 = call i32 @standard_collapse_diagonal(i32 %33, i32 %34)
store i32 %35, i32* %7
%36 = load i32, i32* %2
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%38 = call i32 @write_witness_set_to_file(i32 %36, i8* %37)
store i32 %38, i32* %7
%39 = load i32, i32* %7
ret i32 %39
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [51 x i8] c"\0AReading the name of the file for a witness set...\00"
@.str.2 = [32 x i8] c"\0AGive a string of characters : \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [40 x i8] c"\0AReading the name of the output file...\00"
@.str.5 = [45 x i8] c"\0AThe current number of slack variables : %d\0A\00"
@.str.6 = [41 x i8] c"Give number of slack variables to add : \00"
@.str.7 = [3 x i8] c"%d\00"
define i32 @collapse_extrinsic_diagonal() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca [80 x i8]
%7 = alloca [80 x i8]
%8 = bitcast i32* %1 to i8*
%9 = bitcast i32* %2 to i8*
%10 = bitcast i32* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%18 = call i64 @strlen(i8* %12)
%19 = trunc i64 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%23 = call i64 @strlen(i8* %13)
%24 = trunc i64 %23 to i32
%25 = call i32 @read_witness_set_from_file(i32 %19, i8* %12, i32* %1, i32* %2, i32* %3)
%26 = load i32, i32* %2
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %4)
%30 = load i32, i32* %2
%31 = load i32, i32* %4
%32 = call i32 @standard_collapse_diagonal(i32 %30, i32 %31)
%33 = call i32 @write_witness_set_to_file(i32 %24, i8* %13)
ret i32 %33
}