#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 fabs(double);
int /*<<< orphan*/ printf(char const *, ...);
void EmitCoordinate(double *padfCoord, int nDimension) {
  const char *pszFormat;
  if (fabs(padfCoord[0]) < 180 && fabs(padfCoord[1]) < 180)
    pszFormat = "%.9f";
  else
    pszFormat = "%.2f";
  printf(pszFormat, padfCoord[0]);
  printf(",");
  printf(pszFormat, padfCoord[1]);
  if (nDimension > 2) {
    printf(",");
    printf(pszFormat, padfCoord[2]);
  }
  if (nDimension > 3) {
    printf(",");
    printf(pszFormat, padfCoord[3]);
  }
}


x86 assembly (clang, -O0):
<EmitCoordinate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <fabs@plt>
cmp    $0xb4,%eax
jge    1170 <EmitCoordinate+0x50>
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <fabs@plt>
cmp    $0xb4,%eax
jge    1170 <EmitCoordinate+0x50>
lea    0xe99(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    117b <EmitCoordinate+0x5b>
lea    0xe8e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
cmpl   $0x2,-0xc(%rbp)
jle    11dc <EmitCoordinate+0xbc>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
cmpl   $0x3,-0xc(%rbp)
jle    1208 <EmitCoordinate+0xe8>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EmitCoordinate>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
call   1050 <fabs@plt>
cmp    $0xb3,%eax
jg     1164 <EmitCoordinate+0x34>
movsd  0x8(%rbx),%xmm0
call   1050 <fabs@plt>
cmp    $0xb4,%eax
jge    1164 <EmitCoordinate+0x34>
lea    0xe9e(%rip),%rbp
jmp    116b <EmitCoordinate+0x3b>
lea    0xe9a(%rip),%rbp
movsd  (%rbx),%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x2c,%edi
call   1030 <putchar@plt>
movsd  0x8(%rbx),%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cmp    $0x3,%r14d
jl     11b7 <EmitCoordinate+0x87>
mov    $0x2c,%edi
call   1030 <putchar@plt>
movsd  0x10(%rbx),%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cmp    $0x3,%r14d
jne    11bc <EmitCoordinate+0x8c>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x2c,%edi
call   1030 <putchar@plt>
movsd  0x18(%rbx),%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%.9f\00"
@.str.1 = [5 x i8] c"%.2f\00"
@.str.2 = [2 x i8] c",\00"
define void @EmitCoordinate(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i8*
store double* %0, double** %3
store i32 %1, i32* %4
%6 = load double*, double** %3
%7 = getelementptr inbounds double, double* %6, i64 0
%8 = load double, double* %7
%9 = call i32 @fabs(double %8)
%10 = icmp slt i32 %9, 180
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load double*, double** %3
%13 = getelementptr inbounds double, double* %12, i64 1
%14 = load double, double* %13
%15 = call i32 @fabs(double %14)
%16 = icmp slt i32 %15, 180
br i1 %16, label %17, label %18
17: ; preds = %11
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %5
br label %19
18: ; preds = %11, %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %5
br label %19
19: ; preds = %18, %17
%20 = load i8*, i8** %5
%21 = load double*, double** %3
%22 = getelementptr inbounds double, double* %21, i64 0
%23 = load double, double* %22
%24 = call i32 (i8*, ...) @printf(i8* %20, double %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = load i8*, i8** %5
%27 = load double*, double** %3
%28 = getelementptr inbounds double, double* %27, i64 1
%29 = load double, double* %28
%30 = call i32 (i8*, ...) @printf(i8* %26, double %29)
%31 = load i32, i32* %4
%32 = icmp sgt i32 %31, 2
br i1 %32, label %33, label %40
33: ; preds = %19
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%35 = load i8*, i8** %5
%36 = load double*, double** %3
%37 = getelementptr inbounds double, double* %36, i64 2
%38 = load double, double* %37
%39 = call i32 (i8*, ...) @printf(i8* %35, double %38)
br label %40
40: ; preds = %33, %19
%41 = load i32, i32* %4
%42 = icmp sgt i32 %41, 3
br i1 %42, label %43, label %50
43: ; preds = %40
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%45 = load i8*, i8** %5
%46 = load double*, double** %3
%47 = getelementptr inbounds double, double* %46, i64 3
%48 = load double, double* %47
%49 = call i32 (i8*, ...) @printf(i8* %45, double %48)
br label %50
50: ; preds = %43, %40
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%.9f\00"
@.str.1 = [5 x i8] c"%.2f\00"
define void @EmitCoordinate(double* nocapture %0, i32 %1) {
%3 = load double, double* %0
%4 = tail call i32 @fabs(double %3)
%5 = icmp slt i32 %4, 180
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = getelementptr inbounds double, double* %0, i64 1
%8 = load double, double* %7
%9 = tail call i32 @fabs(double %8)
%10 = icmp slt i32 %9, 180
br i1 %10, label %12, label %11
11: ; preds = %6, %2
br label %12
12: ; preds = %6, %11
%13 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %11 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %6 ]
%14 = load double, double* %0
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %13, double %14)
%16 = tail call i32 @putchar(i32 44)
%17 = getelementptr inbounds double, double* %0, i64 1
%18 = load double, double* %17
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %13, double %18)
%20 = icmp sgt i32 %1, 2
br i1 %20, label %21, label %32
21: ; preds = %12
%22 = tail call i32 @putchar(i32 44)
%23 = getelementptr inbounds double, double* %0, i64 2
%24 = load double, double* %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %13, double %24)
%26 = icmp eq i32 %1, 3
br i1 %26, label %32, label %27
27: ; preds = %21
%28 = tail call i32 @putchar(i32 44)
%29 = getelementptr inbounds double, double* %0, i64 3
%30 = load double, double* %29
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %13, double %30)
br label %32
32: ; preds = %12, %27, %21
ret void
}