#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*/ tdprintf(char *, double, double, int, int, double);
int /*<<< orphan*/ tprintf(char *, double, double, char *, int, int, double);
void putSegmentPicture(char *segment, double px, double py, int dx, int dy,
                       double len) {
  tdprintf("[Segment] (%f,%f)[%d,%d]{%lf}\n", px, py, dx, dy, len);
  if (len < 0) {
    len = -len;
    if (dx == 0) {
      dy = -dy;
    }
  }
  tprintf("\\put(%3.4f,%3.4f){\\%s(%d,%d){%3.4f}}\n", px, py, segment, dx, dy,
          len);
}


x86 assembly (clang, -O0):
<putSegmentPicture>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
mov    %edx,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
movsd  -0x28(%rbp),%xmm2
lea    0xea3(%rip),%rdi
call   1040 <tdprintf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11a8 <putSegmentPicture+0x88>
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11a3 <putSegmentPicture+0x83>
xor    %eax,%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11a8 <putSegmentPicture+0x88>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
movsd  -0x28(%rbp),%xmm2
lea    0xe57(%rip),%rdi
call   1030 <tprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putSegmentPicture>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movaps %xmm2,0x10(%rsp)
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,%r14
lea    0xed5(%rip),%rdi
movsd  %xmm0,(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1040 <tdprintf@plt>
movapd 0x10(%rsp),%xmm2
mov    %ebx,%eax
neg    %eax
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
cmovbe %ebx,%eax
jbe    116a <putSegmentPicture+0x4a>
xorpd  0xe96(%rip),%xmm2
test   %ebp,%ebp
cmove  %eax,%ebx
lea    0xeb9(%rip),%rdi
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %r14,%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <tprintf@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"[Segment] (%f,%f)[%d,%d]{%lf}\0A\00"
@.str.1 = [38 x i8] c"\\put(%3.4f,%3.4f){\\%s(%d,%d){%3.4f}}\0A\00"
define void @putSegmentPicture(i8* %0, double %1, double %2, i32 %3, i32 %4, double %5) {
%7 = alloca i8*
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
store i8* %0, i8** %7
store double %1, double* %8
store double %2, double* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store double %5, double* %12
%13 = load double, double* %8
%14 = load double, double* %9
%15 = load i32, i32* %10
%16 = load i32, i32* %11
%17 = load double, double* %12
%18 = call i32 @tdprintf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), double %13, double %14, i32 %15, i32 %16, double %17)
%19 = load double, double* %12
%20 = fcmp olt double %19, 0.000000e+00
br i1 %20, label %21, label %30
21: ; preds = %6
%22 = load double, double* %12
%23 = fneg double %22
store double %23, double* %12
%24 = load i32, i32* %10
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load i32, i32* %11
%28 = sub nsw i32 0, %27
store i32 %28, i32* %11
br label %29
29: ; preds = %26, %21
br label %30
30: ; preds = %29, %6
%31 = load double, double* %8
%32 = load double, double* %9
%33 = load i8*, i8** %7
%34 = load i32, i32* %10
%35 = load i32, i32* %11
%36 = load double, double* %12
%37 = call i32 @tprintf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), double %31, double %32, i8* %33, i32 %34, i32 %35, double %36)
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"[Segment] (%f,%f)[%d,%d]{%lf}\0A\00"
@.str.1 = [38 x i8] c"\\put(%3.4f,%3.4f){\\%s(%d,%d){%3.4f}}\0A\00"
define void @putSegmentPicture(i8* %0, double %1, double %2, i32 %3, i32 %4, double %5) {
%7 = tail call i32 @tdprintf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), double %1, double %2, i32 %3, i32 %4, double %5)
%8 = fcmp olt double %5, 0.000000e+00
%9 = fneg double %5
%10 = icmp eq i32 %3, 0
%11 = sub nsw i32 0, %4
%12 = and i1 %10, %8
%13 = select i1 %12, i32 %11, i32 %4
%14 = select i1 %8, double %9, double %5
%15 = tail call i32 @tprintf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), double %1, double %2, i8* %0, i32 %3, i32 %13, double %14)
ret void
}