#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 remove_last_slack(int);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strlen(char *);
int write_witness_set_to_file(int, char *);
int remove_last_slack_variable(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);
  fail = remove_last_slack(dim);
  fail = write_witness_set_to_file(m2, outfile);
}


x86 assembly (clang, -O0):
<remove_last_slack_variable>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
lea    0xe8e(%rip),%rdi
lea    -0x21(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xeb4(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x80(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x8(%rbp)
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xd0(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1070 <scanf@plt>
lea    -0xd0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x80(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
call   1060 <read_witness_set_from_file@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
call   1080 <remove_last_slack@plt>
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
lea    -0xd0(%rbp),%rsi
call   1030 <write_witness_set_to_file@plt>
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_last_slack_variable>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb0,%rsp
lea    0xe89(%rip),%rdi
lea    0x3(%rsp),%rsi
call   1070 <scanf@plt>
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea0(%rip),%r12
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeaf(%rip),%r15
lea    0x60(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <scanf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rax,%r13
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x10(%rsp),%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%rdx
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %r13d,%edi
mov    %r14,%rsi
call   1060 <read_witness_set_from_file@plt>
mov    0x4(%rsp),%esi
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%edi
call   1080 <remove_last_slack@plt>
mov    %ebx,%edi
mov    %r12,%rsi
call   1030 <write_witness_set_to_file@plt>
add    $0xb0,%rsp
pop    %rbx
pop    %r12
pop    %r13
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"
define i32 @remove_last_slack_variable() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca [80 x i8]
%11 = alloca [80 x i8]
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%18 = call i64 @strlen(i8* %17)
%19 = trunc i64 %18 to i32
store i32 %19, i32* %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%25 = call i64 @strlen(i8* %24)
%26 = trunc i64 %25 to i32
store i32 %26, i32* %3
%27 = load i32, i32* %2
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%29 = call i32 @read_witness_set_from_file(i32 %27, i8* %28, i32* %4, i32* %5, i32* %6)
store i32 %29, i32* %8
%30 = load i32, i32* %5
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %5
%33 = call i32 @remove_last_slack(i32 %32)
store i32 %33, i32* %8
%34 = load i32, i32* %3
%35 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%36 = call i32 @write_witness_set_to_file(i32 %34, i8* %35)
store i32 %36, i32* %8
%37 = load i32, i32* %1
ret i32 %37
}

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"
define i32 @remove_last_slack_variable() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca [80 x i8]
%6 = alloca [80 x i8]
%7 = bitcast i32* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32* %3 to i8*
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%16 = call i64 @strlen(i8* %10)
%17 = trunc i64 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%21 = call i64 @strlen(i8* %11)
%22 = trunc i64 %21 to i32
%23 = call i32 @read_witness_set_from_file(i32 %17, i8* %10, i32* %1, i32* %2, i32* %3)
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %2
%27 = call i32 @remove_last_slack(i32 %26)
%28 = call i32 @write_witness_set_to_file(i32 %22, i8* %11)
ret i32 undef
}