#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 */
scalar_t__ calloc(int, int);
int celcon_set_type_of_mixture(int, int *);
int celcon_write_mixed_cell_configuration();
int /*<<< orphan*/ printf(char *, ...);
int read_mixed_cell(int, int);
int read_supports(int, int);
int /*<<< orphan*/ scanf(char *, int *);
int show_mixture(int, int *);
int write_lifted_supports(int);
void read_and_construct(void) {
  int r, *mix, i, fail, rr, n;
  double *c;
  printf("\nGive the number of different supports : ");
  scanf("%d", &r);
  mix = (int *)calloc(r, sizeof(int));
  for (i = 0; i < r; i++) {
    printf("  how many times does support %d occur ? ", i + 1);
    scanf("%d", &mix[i]);
  }
  fail = celcon_set_type_of_mixture(r, mix);
  fail = show_mixture(r, &rr);
  printf("\nGive the dimension of the lifted points : ");
  scanf("%d", &n);
  fail = read_supports(r, n);
  fail = write_lifted_supports(n);
  fail = read_mixed_cell(r, n);
  fail = celcon_write_mixed_cell_configuration();
}


x86 assembly (clang, -O0):
<read_and_construct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe7d(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x4(%rbp),%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1217 <read_and_construct+0x87>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe26(%rip),%rdi
call   1090 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ce <read_and_construct+0x3e>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <celcon_set_type_of_mixture@plt>
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x1c(%rbp),%rsi
call   1030 <show_mixture@plt>
mov    %eax,-0x18(%rbp)
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xde0(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1060 <read_supports@plt>
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%edi
call   1080 <write_lifted_supports@plt>
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10b0 <read_mixed_cell@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   10a0 <celcon_write_mixed_cell_configuration@plt>
mov    %eax,-0x18(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_and_construct>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe78(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1090 <scanf@plt>
mov    0x4(%rsp),%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,%r14
mov    0x4(%rsp),%edi
test   %edi,%edi
jle    1219 <read_and_construct+0x89>
lea    0xe51(%rip),%r15
lea    0xe47(%rip),%r12
mov    %r14,%r13
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1090 <scanf@plt>
movslq 0x4(%rsp),%rdi
add    $0x4,%r13
cmp    %rdi,%rbx
jl     11f0 <read_and_construct+0x60>
mov    %r14,%rsi
call   1070 <celcon_set_type_of_mixture@plt>
mov    0x4(%rsp),%edi
lea    0xc(%rsp),%rsi
call   1030 <show_mixture@plt>
lea    0xe21(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xde6(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1090 <scanf@plt>
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%esi
call   1060 <read_supports@plt>
mov    0x8(%rsp),%edi
call   1080 <write_lifted_supports@plt>
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%esi
call   10b0 <read_mixed_cell@plt>
xor    %eax,%eax
call   10a0 <celcon_write_mixed_cell_configuration@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [42 x i8] c"\0AGive the number of different supports : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [42 x i8] c" how many times does support %d occur ? \00"
@.str.3 = [44 x i8] c"\0AGive the dimension of the lifted points : \00"
define void @read_and_construct() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double*
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = call i64 @calloc(i32 %10, i32 4)
%12 = inttoptr i64 %11 to i32*
store i32* %12, i32** %2
store i32 0, i32* %3
br label %13
13: ; preds = %26, %0
%14 = load i32, i32* %3
%15 = load i32, i32* %1
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %29
17: ; preds = %13
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = load i32*, i32** %2
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %24)
br label %26
26: ; preds = %17
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %13
29: ; preds = %13
%30 = load i32, i32* %1
%31 = load i32*, i32** %2
%32 = call i32 @celcon_set_type_of_mixture(i32 %30, i32* %31)
store i32 %32, i32* %4
%33 = load i32, i32* %1
%34 = call i32 @show_mixture(i32 %33, i32* %5)
store i32 %34, i32* %4
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%37 = load i32, i32* %1
%38 = load i32, i32* %6
%39 = call i32 @read_supports(i32 %37, i32 %38)
store i32 %39, i32* %4
%40 = load i32, i32* %6
%41 = call i32 @write_lifted_supports(i32 %40)
store i32 %41, i32* %4
%42 = load i32, i32* %1
%43 = load i32, i32* %6
%44 = call i32 @read_mixed_cell(i32 %42, i32 %43)
store i32 %44, i32* %4
%45 = call i32 (...) @celcon_write_mixed_cell_configuration()
store i32 %45, i32* %4
ret void
}

LLVM IR (-O2):
@.str = [42 x i8] c"\0AGive the number of different supports : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [42 x i8] c" how many times does support %d occur ? \00"
@.str.3 = [44 x i8] c"\0AGive the dimension of the lifted points : \00"
define void @read_and_construct() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = call i64 @calloc(i32 %9, i32 4)
%11 = inttoptr i64 %10 to i32*
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %0, %14
%15 = phi i64 [ %16, %14 ], [ 0, %0 ]
%16 = add nuw nsw i64 %15, 1
%17 = trunc i64 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds i32, i32* %11, i64 %15
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %19)
%21 = load i32, i32* %1
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %16, %22
br i1 %23, label %14, label %24
24: ; preds = %14, %0
%25 = phi i32 [ %12, %0 ], [ %21, %14 ]
%26 = call i32 @celcon_set_type_of_mixture(i32 %25, i32* %11)
%27 = load i32, i32* %1
%28 = call i32 @show_mixture(i32 %27, i32* %2)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%31 = load i32, i32* %1
%32 = load i32, i32* %3
%33 = call i32 @read_supports(i32 %31, i32 %32)
%34 = load i32, i32* %3
%35 = call i32 @write_lifted_supports(i32 %34)
%36 = load i32, i32* %1
%37 = load i32, i32* %3
%38 = call i32 @read_mixed_cell(i32 %36, i32 %37)
%39 = call i32 (...) @celcon_write_mixed_cell_configuration()
ret void
}