#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 */
struct point {
  int dummy;
};

/* Variables and functions */
int EXIT_SUCCESS;
struct point *input_point(char);
int /*<<< orphan*/ point_destroy(struct point *);
double point_distance(struct point *, struct point *);
scalar_t__ point_equals(struct point *, struct point *);
int /*<<< orphan*/ point_to_string(struct point *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  struct point *p1, *p2;
  char p1str[20], p2str[20];
  p1 = input_point('A');
  p2 = input_point('B');
  point_to_string(p1, p1str);
  point_to_string(p2, p2str);
  printf("Got these points: %s and %s\n", p1str, p2str);
  if (point_equals(p1, p2)) {
    printf("The points are equal.\n");
  } else {
    printf("The distance between the points is %.2f\n", point_distance(p1, p2));
  }
  point_destroy(p1);
  point_destroy(p2);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x41,%edi
call   1050 <input_point@plt>
mov    %rax,-0x10(%rbp)
mov    $0x42,%edi
call   1050 <input_point@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <point_to_string@plt>
mov    -0x18(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1070 <point_to_string@plt>
lea    -0x30(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <point_equals@plt>
cmp    $0x0,%rax
je     11e5 <main+0x85>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1200 <main+0xa0>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <point_distance@plt>
lea    0xe3b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <point_destroy@plt>
mov    -0x18(%rbp),%rdi
call   1040 <point_destroy@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    $0x41,%edi
call   1060 <input_point@plt>
mov    %rax,%r14
mov    $0x42,%edi
call   1060 <input_point@plt>
mov    %rax,%rbx
lea    0x20(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <point_to_string@plt>
mov    %rsp,%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <point_to_string@plt>
lea    0xe46(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <point_equals@plt>
test   %rax,%rax
je     11e5 <main+0x75>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
jmp    11fe <main+0x8e>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <point_distance@plt>
lea    0xe26(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r14,%rdi
call   1050 <point_destroy@plt>
mov    %rbx,%rdi
call   1050 <point_destroy@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.point = type { i32 }
@.str = [29 x i8] c"Got these points: %s and %s\0A\00"
@.str.1 = [23 x i8] c"The points are equal.\0A\00"
@.str.2 = [41 x i8] c"The distance between the points is %.2f\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.point*
%3 = alloca %struct.point*
%4 = alloca [20 x i8]
%5 = alloca [20 x i8]
store i32 0, i32* %1
%6 = call %struct.point* @input_point(i8 signext 65)
store %struct.point* %6, %struct.point** %2
%7 = call %struct.point* @input_point(i8 signext 66)
store %struct.point* %7, %struct.point** %3
%8 = load %struct.point*, %struct.point** %2
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%10 = call i32 @point_to_string(%struct.point* %8, i8* %9)
%11 = load %struct.point*, %struct.point** %3
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%13 = call i32 @point_to_string(%struct.point* %11, i8* %12)
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %15)
%17 = load %struct.point*, %struct.point** %2
%18 = load %struct.point*, %struct.point** %3
%19 = call i64 @point_equals(%struct.point* %17, %struct.point* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %28
23: ; preds = %0
%24 = load %struct.point*, %struct.point** %2
%25 = load %struct.point*, %struct.point** %3
%26 = call double @point_distance(%struct.point* %24, %struct.point* %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), double %26)
br label %28
28: ; preds = %23, %21
%29 = load %struct.point*, %struct.point** %2
%30 = call i32 @point_destroy(%struct.point* %29)
%31 = load %struct.point*, %struct.point** %3
%32 = call i32 @point_destroy(%struct.point* %31)
%33 = load i32, i32* @EXIT_SUCCESS
ret i32 %33
}

LLVM IR (-O2):
%struct.point = type { i32 }
@.str = [29 x i8] c"Got these points: %s and %s\0A\00"
@.str.2 = [41 x i8] c"The distance between the points is %.2f\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [22 x i8] c"The points are equal.\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = tail call %struct.point* @input_point(i8 signext 65)
%6 = tail call %struct.point* @input_point(i8 signext 66)
%7 = call i32 @point_to_string(%struct.point* %5, i8* %3)
%8 = call i32 @point_to_string(%struct.point* %6, i8* %4)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
%10 = call i64 @point_equals(%struct.point* %5, %struct.point* %6)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %17
14: ; preds = %0
%15 = call double @point_distance(%struct.point* %5, %struct.point* %6)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), double %15)
br label %17
17: ; preds = %14, %12
%18 = call i32 @point_destroy(%struct.point* %5)
%19 = call i32 @point_destroy(%struct.point* %6)
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
}