#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
double INFINITY;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ help(char *);
scalar_t__ parse_ply_points_for_extrema(double *, double *, double *, double *,
                                        char *, char *);
int /*<<< orphan*/ stderr;
int main(int c, char *v[]) {
  if (c != 3) {
    help(*v);
    return 1;
  }
  double xmin = INFINITY;
  double xmax = -INFINITY;
  double ymin = INFINITY;
  double ymax = -INFINITY;
  char utm[3];
  char *ply_file = v[1];
  char *plyextrema_file = v[2];
  if (parse_ply_points_for_extrema(&xmin, &xmax, &ymin, &ymax, utm, ply_file))
    fprintf(stderr, "xmin: %lf, xmax: %lf, ymin: %lf, ymax: %lf\n", xmin, xmax,
            ymin, ymax);
  else {
    fprintf(stderr, "plyextrema: empty input ply file\n");
    return EXIT_FAILURE;
  }
  FILE *out_extrema = NULL;
  out_extrema = fopen(plyextrema_file, "w");
  if (out_extrema != NULL) {
    fprintf(out_extrema, "%lf %lf %lf %lf", xmin, xmax, ymin, ymax);
    fclose(out_extrema);
  } else {
    fprintf(stderr, "ERROR : can't create %s", v[2]);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1188 <main+0x38>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <help@plt>
movl   $0x1,-0x4(%rbp)
jmp    131c <main+0x1cc>
mov    0x2e59(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    0x2e49(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0x2e22(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    0x2e12(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x48(%rbp)
lea    -0x33(%rbp),%r8
mov    -0x40(%rbp),%r9
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   1070 <parse_ply_points_for_extrema@plt>
cmp    $0x0,%rax
je     1265 <main+0x115>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
lea    0xda7(%rip),%rsi
mov    $0x4,%al
call   1040 <fprintf@plt>
jmp    128d <main+0x13d>
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
lea    0xdb7(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    131c <main+0x1cc>
movq   $0x0,-0x50(%rbp)
mov    -0x48(%rbp),%rdi
lea    0xdae(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     12ea <main+0x19a>
mov    -0x50(%rbp),%rax
mov    %eax,%edi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
lea    0xd7b(%rip),%rsi
mov    $0x4,%al
call   1040 <fprintf@plt>
mov    -0x50(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1315 <main+0x1c5>
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xd5e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    131c <main+0x1cc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    1237 <main+0xe7>
mov    0x2e7c(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x20(%rsp)
movaps 0xe83(%rip),%xmm1
xorps  %xmm0,%xmm1
movlps %xmm1,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
movlps %xmm1,0x8(%rsp)
mov    0x8(%rbx),%r9
mov    0x10(%rbx),%r14
lea    0x20(%rsp),%rdi
lea    0x18(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x2d(%rsp),%r8
call   1070 <parse_ply_points_for_extrema@plt>
mov    0x2e1b(%rip),%r15
mov    (%r15),%edi
test   %rax,%rax
je     1241 <main+0xf1>
movsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
lea    0xe2c(%rip),%rsi
mov    $0x4,%al
call   1040 <fprintf@plt>
lea    0xe6c(%rip),%rsi
mov    %r14,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     125a <main+0x10a>
mov    %rax,%r14
movsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
lea    0xe3f(%rip),%rsi
mov    %r14d,%edi
mov    $0x4,%al
call   1040 <fprintf@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    1274 <main+0x124>
mov    (%rbx),%rdi
call   1060 <help@plt>
jmp    126f <main+0x11f>
lea    0xdf4(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2d7a(%rip),%rax
mov    (%rax),%eax
jmp    1274 <main+0x124>
mov    (%r15),%edi
mov    0x10(%rbx),%rdx
lea    0xe08(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@INFINITY = global double 0.000000e+00
@stderr = global i32 0
@.str = [44 x i8] c"xmin: %lf, xmax: %lf, ymin: %lf, ymax: %lf\0A\00"
@.str.1 = [34 x i8] c"plyextrema: empty input ply file\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [16 x i8] c"%lf %lf %lf %lf\00"
@.str.4 = [24 x i8] c"ERROR : can't create %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca [3 x i8]
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 3
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = load i8*, i8** %17
%19 = call i32 @help(i8* %18)
store i32 1, i32* %3
br label %70
20: ; preds = %2
%21 = load double, double* @INFINITY
store double %21, double* %6
%22 = load double, double* @INFINITY
%23 = fneg double %22
store double %23, double* %7
%24 = load double, double* @INFINITY
store double %24, double* %8
%25 = load double, double* @INFINITY
%26 = fneg double %25
store double %26, double* %9
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
store i8* %29, i8** %11
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
store i8* %32, i8** %12
%33 = getelementptr inbounds [3 x i8], [3 x i8]* %10, i64 0, i64 0
%34 = load i8*, i8** %11
%35 = call i64 @parse_ply_points_for_extrema(double* %6, double* %7, double* %8, double* %9, i8* %33, i8* %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %44
37: ; preds = %20
%38 = load i32, i32* @stderr
%39 = load double, double* %6
%40 = load double, double* %7
%41 = load double, double* %8
%42 = load double, double* %9
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), double %39, double %40, double %41, double %42)
br label %48
44: ; preds = %20
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%47 = load i32, i32* @EXIT_FAILURE
store i32 %47, i32* %3
br label %70
48: ; preds = %37
store i32* null, i32** %13
%49 = load i8*, i8** %12
%50 = call i32* @fopen(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %50, i32** %13
%51 = load i32*, i32** %13
%52 = icmp ne i32* %51, null
br i1 %52, label %53, label %63
53: ; preds = %48
%54 = load i32*, i32** %13
%55 = ptrtoint i32* %54 to i32
%56 = load double, double* %6
%57 = load double, double* %7
%58 = load double, double* %8
%59 = load double, double* %9
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %56, double %57, double %58, double %59)
%61 = load i32*, i32** %13
%62 = call i32 @fclose(i32* %61)
br label %69
63: ; preds = %48
%64 = load i32, i32* @stderr
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 2
%67 = load i8*, i8** %66
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %67)
store i32 1, i32* %3
br label %70
69: ; preds = %53
store i32 0, i32* %3
br label %70
70: ; preds = %69, %63, %44, %16
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
@INFINITY = global double 0.000000e+00
@stderr = global i32 0
@.str = [44 x i8] c"xmin: %lf, xmax: %lf, ymin: %lf, ymax: %lf\0A\00"
@.str.1 = [34 x i8] c"plyextrema: empty input ply file\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [16 x i8] c"%lf %lf %lf %lf\00"
@.str.4 = [24 x i8] c"ERROR : can't create %s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca [3 x i8]
%8 = icmp eq i32 %0, 3
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = tail call i32 @help(i8* %10)
br label %53
12: ; preds = %2
%13 = bitcast double* %3 to i8*
%14 = load double, double* @INFINITY
store double %14, double* %3
%15 = bitcast double* %4 to i8*
%16 = fneg double %14
store double %16, double* %4
%17 = bitcast double* %5 to i8*
store double %14, double* %5
%18 = bitcast double* %6 to i8*
store double %16, double* %6
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = call i64 @parse_ply_points_for_extrema(double* %3, double* %4, double* %5, double* %6, i8* %19, i8* %21)
%25 = icmp eq i64 %24, 0
%26 = load i32, i32* @stderr
br i1 %25, label %35, label %27
27: ; preds = %12
%28 = load double, double* %3
%29 = load double, double* %4
%30 = load double, double* %5
%31 = load double, double* %6
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), double %28, double %29, double %30, double %31)
%33 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %47, label %38
35: ; preds = %12
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
br label %51
38: ; preds = %27
%39 = ptrtoint i32* %33 to i64
%40 = trunc i64 %39 to i32
%41 = load double, double* %3
%42 = load double, double* %4
%43 = load double, double* %5
%44 = load double, double* %6
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %41, double %42, double %43, double %44)
%46 = call i32 @fclose(i32* %33)
br label %51
47: ; preds = %27
%48 = load i32, i32* @stderr
%49 = load i8*, i8** %22
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %47, %38, %35
%52 = phi i32 [ %37, %35 ], [ 0, %38 ], [ 1, %47 ]
br label %53
53: ; preds = %51, %9
%54 = phi i32 [ 1, %9 ], [ %52, %51 ]
ret i32 %54
}