#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 convex_hull(int, char *);
int number_of_facets(int, int *);
int /*<<< orphan*/ printf(char *, ...);
int retrieve_facet(int, int, int *, char *);
int /*<<< orphan*/ scanf(char *, int *);
int hull_in_3d(int nbc_pts, char *pts) {
  int fail, nbr, fcn, ncp;
  char rep[256];
  fail = convex_hull(nbc_pts, pts);
  fail = number_of_facets(3, &nbr);
  printf("Number of facets : %d\n", nbr);
  do {
    printf("Give a facet number (-1 to exit) : ");
    scanf("%d", &fcn);
    if (fcn < 0)
      break;
    fail = retrieve_facet(3, fcn, &ncp, rep);
    printf("The representation of facet %d :\n %s\n", fcn, rep);
  } while (fcn >= 0);
  return fail;
}


x86 assembly (clang, -O0):
<hull_in_3d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <convex_hull@plt>
mov    %eax,-0x14(%rbp)
mov    $0x3,%edi
lea    -0x18(%rbp),%rsi
call   1030 <number_of_facets@plt>
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe93(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0x1c(%rbp)
jge    11c0 <hull_in_3d+0x70>
jmp    11fd <hull_in_3d+0xad>
mov    -0x1c(%rbp),%esi
lea    -0x120(%rbp),%rcx
mov    $0x3,%edi
lea    -0x20(%rbp),%rdx
call   1070 <retrieve_facet@plt>
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%esi
lea    -0x120(%rbp),%rdx
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
jge    1193 <hull_in_3d+0x43>
mov    -0x14(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hull_in_3d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
call   1050 <convex_hull@plt>
lea    0x8(%rsp),%rsi
mov    $0x3,%edi
call   1030 <number_of_facets@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%esi
lea    0xe7e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9d(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
js     1219 <hull_in_3d+0xc9>
lea    0x10(%rsp),%r15
lea    0xe82(%rip),%r12
lea    0xe54(%rip),%r13
lea    0xe71(%rip),%rbp
lea    0x4(%rsp),%r14
nop
mov    $0x3,%edi
lea    0xc(%rsp),%rdx
mov    %r15,%rcx
call   1070 <retrieve_facet@plt>
mov    %eax,%ebx
mov    0x4(%rsp),%esi
mov    %r12,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x4(%rsp)
js     1219 <hull_in_3d+0xc9>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jns    11d0 <hull_in_3d+0x80>
mov    %ebx,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Number of facets : %d\0A\00"
@.str.1 = [36 x i8] c"Give a facet number (-1 to exit) : \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [38 x i8] c"The representation of facet %d :\0A %s\0A\00"
define i32 @hull_in_3d(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [256 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%10 = load i32, i32* %3
%11 = load i8*, i8** %4
%12 = call i32 @convex_hull(i32 %10, i8* %11)
store i32 %12, i32* %5
%13 = call i32 @number_of_facets(i32 3, i32* %6)
store i32 %13, i32* %5
%14 = load i32, i32* %6
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %29, %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
br label %32
22: ; preds = %16
%23 = load i32, i32* %7
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%25 = call i32 @retrieve_facet(i32 3, i32 %23, i32* %8, i8* %24)
store i32 %25, i32* %5
%26 = load i32, i32* %7
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %26, i8* %27)
br label %29
29: ; preds = %22
%30 = load i32, i32* %7
%31 = icmp sge i32 %30, 0
br i1 %31, label %16, label %32
32: ; preds = %29, %21
%33 = load i32, i32* %5
ret i32 %33
}

LLVM IR (-O2):
@.str = [23 x i8] c"Number of facets : %d\0A\00"
@.str.1 = [36 x i8] c"Give a facet number (-1 to exit) : \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [38 x i8] c"The representation of facet %d :\0A %s\0A\00"
define i32 @hull_in_3d(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [256 x i8]
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%11 = tail call i32 @convex_hull(i32 %0, i8* %1)
%12 = call i32 @number_of_facets(i32 3, i32* %3)
%13 = load i32, i32* %3
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 0
br i1 %18, label %31, label %24
19: ; preds = %24
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %2, %19
%25 = phi i32 [ %22, %19 ], [ %17, %2 ]
%26 = call i32 @retrieve_facet(i32 3, i32 %25, i32* %5, i8* %10)
%27 = load i32, i32* %4
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %27, i8* %10)
%29 = load i32, i32* %4
%30 = icmp sgt i32 %29, -1
br i1 %30, label %19, label %31
31: ; preds = %24, %19, %2
%32 = phi i32 [ %12, %2 ], [ %26, %19 ], [ %26, %24 ]
ret i32 %32
}