#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 */
double atof(char *);
int atoi(char *);
int fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ lonlat_from_eastnorthzone(double *, double, double, int);
int /*<<< orphan*/ printf(char *, double, double, ...);
int /*<<< orphan*/ stderr;
int utm_from_lonlat(double *, double, double);
int main(int c, char *v[]) {
  if (c == 3) {
    double lon = atof(v[1]);
    double lat = atof(v[2]);
    double utm[2];
    int z = utm_from_lonlat(utm, lon, lat);
    printf("%lf %lf %d\n", utm[0], utm[1], z);
    return 0;
  }
  if (c == 4) {
    double e = atof(v[1]);
    double n = atof(v[2]);
    int z = atoi(v[3]);
    double lonlat[2];
    lonlat_from_eastnorthzone(lonlat, e, n, z);
    printf("%lf %lf\n", lonlat[0], lonlat[1]);
    return 0;
  }
  return fprintf(stderr, "usage:\n\t%s {lon lat|east north zone}\n", *v);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    11e1 <main+0x81>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1080 <utm_from_lonlat@plt>
mov    %eax,-0x34(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mov    -0x34(%rbp),%esi
lea    0xe32(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1278 <main+0x118>
cmpl   $0x4,-0x8(%rbp)
jne    1259 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x4c(%rbp)
lea    -0x60(%rbp),%rdi
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
mov    -0x4c(%rbp),%esi
call   1040 <lonlat_from_eastnorthzone@plt>
movsd  -0x60(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
lea    0xdc6(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1278 <main+0x118>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xda5(%rip),%rsi
call   1060 <fprintf@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
je     11bf <main+0x5f>
cmp    $0x3,%edi
jne    1220 <main+0xc0>
mov    0x8(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x10(%rbx),%rdi
call   1030 <atof@plt>
movaps %xmm0,%xmm1
lea    0x10(%rsp),%rdi
movsd  0x8(%rsp),%xmm0
call   1080 <utm_from_lonlat@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
lea    0xe4c(%rip),%rdi
mov    %eax,%esi
mov    $0x2,%al
call   1050 <printf@plt>
jmp    1218 <main+0xb8>
mov    0x8(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x10(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x28(%rsp)
mov    0x18(%rbx),%rdi
call   1070 <atoi@plt>
lea    0x10(%rsp),%rdi
movsd  0x8(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
mov    %eax,%esi
call   1040 <lonlat_from_eastnorthzone@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
lea    0xdfb(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xde2(%rip),%rsi
add    $0x30,%rsp
pop    %rbx
jmp    1060 <fprintf@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"%lf %lf %d\0A\00"
@.str.1 = [9 x i8] c"%lf %lf\0A\00"
@stderr = global i32 0
@.str.2 = [38 x i8] c"usage:\0A\09%s {lon lat|east north zone}\0A\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 [2 x double]
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca [2 x double]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 3
br i1 %15, label %16, label %35
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call double @atof(i8* %19)
store double %20, double* %6
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call double @atof(i8* %23)
store double %24, double* %7
%25 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 0
%26 = load double, double* %6
%27 = load double, double* %7
%28 = call i32 @utm_from_lonlat(double* %25, double %26, double %27)
store i32 %28, i32* %9
%29 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 0
%30 = load double, double* %29
%31 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 1
%32 = load double, double* %31
%33 = load i32, i32* %9
%34 = call i32 (i8*, double, double, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %30, double %32, i32 %33)
store i32 0, i32* %3
br label %66
35: ; preds = %2
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 4
br i1 %37, label %38, label %61
38: ; preds = %35
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call double @atof(i8* %41)
store double %42, double* %10
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = call double @atof(i8* %45)
store double %46, double* %11
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 3
%49 = load i8*, i8** %48
%50 = call i32 @atoi(i8* %49)
store i32 %50, i32* %12
%51 = getelementptr inbounds [2 x double], [2 x double]* %13, i64 0, i64 0
%52 = load double, double* %10
%53 = load double, double* %11
%54 = load i32, i32* %12
%55 = call i32 @lonlat_from_eastnorthzone(double* %51, double %52, double %53, i32 %54)
%56 = getelementptr inbounds [2 x double], [2 x double]* %13, i64 0, i64 0
%57 = load double, double* %56
%58 = getelementptr inbounds [2 x double], [2 x double]* %13, i64 0, i64 1
%59 = load double, double* %58
%60 = call i32 (i8*, double, double, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), double %57, double %59)
store i32 0, i32* %3
br label %66
61: ; preds = %35
%62 = load i32, i32* @stderr
%63 = load i8**, i8*** %5
%64 = load i8*, i8** %63
%65 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %64)
store i32 %65, i32* %3
br label %66
66: ; preds = %61, %38, %16
%67 = load i32, i32* %3
ret i32 %67
}

LLVM IR (-O2):
@.str = [12 x i8] c"%lf %lf %d\0A\00"
@.str.1 = [9 x i8] c"%lf %lf\0A\00"
@stderr = global i32 0
@.str.2 = [38 x i8] c"usage:\0A\09%s {lon lat|east north zone}\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x double]
%4 = alloca [2 x double]
switch i32 %0, label %36 [
i32 3, label %5
i32 4, label %19
]
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call double @atof(i8* %7)
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call double @atof(i8* %10)
%12 = bitcast [2 x double]* %3 to i8*
%13 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 0
%14 = call i32 @utm_from_lonlat(double* %13, double %8, double %11)
%15 = load double, double* %13
%16 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 1
%17 = load double, double* %16
%18 = call i32 (i8*, double, double, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %15, double %17, i32 %14)
br label %40
19: ; preds = %2
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = tail call double @atof(i8* %21)
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = tail call double @atof(i8* %24)
%26 = getelementptr inbounds i8*, i8** %1, i64 3
%27 = load i8*, i8** %26
%28 = tail call i32 @atoi(i8* %27)
%29 = bitcast [2 x double]* %4 to i8*
%30 = getelementptr inbounds [2 x double], [2 x double]* %4, i64 0, i64 0
%31 = call i32 @lonlat_from_eastnorthzone(double* %30, double %22, double %25, i32 %28)
%32 = load double, double* %30
%33 = getelementptr inbounds [2 x double], [2 x double]* %4, i64 0, i64 1
%34 = load double, double* %33
%35 = call i32 (i8*, double, double, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), double %32, double %34)
br label %40
36: ; preds = %2
%37 = load i32, i32* @stderr
%38 = load i8*, i8** %1
%39 = tail call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %36, %19, %5
%41 = phi i32 [ 0, %5 ], [ 0, %19 ], [ %39, %36 ]
ret i32 %41
}