#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 */
char *CsvEscape(char const *);
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ LC_NUMERIC;
char *ReadExifData(char const *, double *, double *, double *, int *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
char *setlocale(int /*<<< orphan*/, char *);
int ShowFileDetails(const char *File, int MachineReadable) {
  double Lat, Long, Elev;
  int IncludesGPS = 0;
  Lat = Long = Elev = 0;
  char *Time = ReadExifData(File, &Lat, &Long, &Elev, &IncludesGPS);
  int rc = 1;
  char *OldLocale = NULL;
  if (MachineReadable) {
    OldLocale = setlocale(LC_NUMERIC, "C");
  }
  if (Time) {
    if (IncludesGPS) {
      if (MachineReadable) {
        char *EscapedFile = CsvEscape(File);
        if (!EscapedFile) {
          printf(("Out of memory\n"));
          exit(EXIT_FAILURE);
        }
        printf("\"%s\",\"%s\",%f,%f,%.3f\n", EscapedFile, Time, Lat, Long,
               Elev);
        free(EscapedFile);
      } else {
        printf(("%s: %s, Lat %f, Long %f, Elevation %.3f.\n"), File, Time, Lat,
               Long, Elev);
      }
    } else {
      if (!MachineReadable) {
        printf(("%s: %s, No GPS Data.\n"), File, Time);
      }
    }
  } else {
    if (!MachineReadable) {
      printf(("%s: No EXIF data.\n"), File);
      rc = 0;
    }
  }
  free(Time);
  if (MachineReadable) {
    setlocale(LC_NUMERIC, OldLocale);
  }
  return rc;
}


x86 assembly (clang, -O0):
<ShowFileDetails>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x2c(%rbp),%r8
call   1040 <ReadExifData@plt>
mov    %rax,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
movq   $0x0,-0x48(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11dd <ShowFileDetails+0x7d>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe2c(%rip),%rsi
call   1070 <setlocale@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     12b7 <ShowFileDetails+0x157>
cmpl   $0x0,-0x2c(%rbp)
je     128d <ShowFileDetails+0x12d>
cmpl   $0x0,-0xc(%rbp)
je     1263 <ShowFileDetails+0x103>
mov    -0x8(%rbp),%rdi
call   1060 <CsvEscape@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1230 <ShowFileDetails+0xd0>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x50(%rbp),%rsi
mov    -0x38(%rbp),%rdx
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
lea    0xdc3(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
jmp    1288 <ShowFileDetails+0x128>
mov    -0x8(%rbp),%rsi
mov    -0x38(%rbp),%rdx
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
lea    0xda6(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
jmp    12b2 <ShowFileDetails+0x152>
cmpl   $0x0,-0xc(%rbp)
jne    12ad <ShowFileDetails+0x14d>
mov    -0x8(%rbp),%rsi
mov    -0x38(%rbp),%rdx
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12b2 <ShowFileDetails+0x152>
jmp    12df <ShowFileDetails+0x17f>
cmpl   $0x0,-0xc(%rbp)
jne    12da <ShowFileDetails+0x17a>
mov    -0x8(%rbp),%rsi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x3c(%rbp)
jmp    12df <ShowFileDetails+0x17f>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0xc(%rbp)
je     1304 <ShowFileDetails+0x1a4>
mov    0x2cef(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%rsi
call   1070 <setlocale@plt>
mov    -0x3c(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ShowFileDetails>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %esi,%ebp
mov    %rdi,%r14
movl   $0x0,0xc(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x18(%rsp)
movq   $0x0,0x20(%rsp)
lea    0x20(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
call   1050 <ReadExifData@plt>
mov    %rax,%rbx
test   %ebp,%ebp
je     123e <ShowFileDetails+0xce>
mov    0x2e1f(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe2d(%rip),%rsi
call   1080 <setlocale@plt>
mov    %rax,%r15
test   %rbx,%rbx
je     1229 <ShowFileDetails+0xb9>
cmpl   $0x0,0xc(%rsp)
je     1229 <ShowFileDetails+0xb9>
mov    %r14,%rdi
call   1070 <CsvEscape@plt>
test   %rax,%rax
je     12bc <ShowFileDetails+0x14c>
mov    %rax,%r14
movsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
lea    0xdee(%rip),%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
mov    $0x3,%al
call   1060 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x0(%rbp),%edi
mov    %r15,%rsi
call   1080 <setlocale@plt>
jmp    12aa <ShowFileDetails+0x13a>
test   %rbx,%rbx
je     1272 <ShowFileDetails+0x102>
cmpl   $0x0,0xc(%rsp)
je     128e <ShowFileDetails+0x11e>
movsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
lea    0xdb5(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    $0x3,%al
call   1060 <printf@plt>
jmp    12a2 <ShowFileDetails+0x132>
lea    0xddf(%rip),%rdi
xor    %ebx,%ebx
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   1030 <free@plt>
jmp    12af <ShowFileDetails+0x13f>
lea    0xdad(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xda8(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d09(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@LC_NUMERIC = global i32 0
@.str = [2 x i8] c"C\00"
@.str.1 = [15 x i8] c"Out of memory\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [22 x i8] c"\22%s\22,\22%s\22,%f,%f,%.3f\0A\00"
@.str.3 = [42 x i8] c"%s: %s, Lat %f, Long %f, Elevation %.3f.\0A\00"
@.str.4 = [22 x i8] c"%s: %s, No GPS Data.\0A\00"
@.str.5 = [19 x i8] c"%s: No EXIF data.\0A\00"
define i32 @ShowFileDetails(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %8
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %5
%13 = load i8*, i8** %3
%14 = call i8* @ReadExifData(i8* %13, double* %5, double* %6, double* %7, i32* %8)
store i8* %14, i8** %9
store i32 1, i32* %10
store i8* null, i8** %11
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i32, i32* @LC_NUMERIC
%19 = call i8* @setlocale(i32 %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %19, i8** %11
br label %20
20: ; preds = %17, %2
%21 = load i8*, i8** %9
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %64
23: ; preds = %20
%24 = load i32, i32* %8
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %55
26: ; preds = %23
%27 = load i32, i32* %4
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %47
29: ; preds = %26
%30 = load i8*, i8** %3
%31 = call i8* @CsvEscape(i8* %30)
store i8* %31, i8** %12
%32 = load i8*, i8** %12
%33 = icmp ne i8* %32, null
br i1 %33, label %38, label %34
34: ; preds = %29
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %29
%39 = load i8*, i8** %12
%40 = load i8*, i8** %9
%41 = load double, double* %5
%42 = load double, double* %6
%43 = load double, double* %7
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %39, i8* %40, double %41, double %42, double %43)
%45 = load i8*, i8** %12
%46 = call i32 @free(i8* %45)
br label %54
47: ; preds = %26
%48 = load i8*, i8** %3
%49 = load i8*, i8** %9
%50 = load double, double* %5
%51 = load double, double* %6
%52 = load double, double* %7
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %48, i8* %49, double %50, double %51, double %52)
br label %54
54: ; preds = %47, %38
br label %63
55: ; preds = %23
%56 = load i32, i32* %4
%57 = icmp ne i32 %56, 0
br i1 %57, label %62, label %58
58: ; preds = %55
%59 = load i8*, i8** %3
%60 = load i8*, i8** %9
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %59, i8* %60)
br label %62
62: ; preds = %58, %55
br label %63
63: ; preds = %62, %54
br label %71
64: ; preds = %20
%65 = load i32, i32* %4
%66 = icmp ne i32 %65, 0
br i1 %66, label %70, label %67
67: ; preds = %64
%68 = load i8*, i8** %3
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %68)
store i32 0, i32* %10
br label %70
70: ; preds = %67, %64
br label %71
71: ; preds = %70, %63
%72 = load i8*, i8** %9
%73 = call i32 @free(i8* %72)
%74 = load i32, i32* %4
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %71
%77 = load i32, i32* @LC_NUMERIC
%78 = load i8*, i8** %11
%79 = call i8* @setlocale(i32 %77, i8* %78)
br label %80
80: ; preds = %76, %71
%81 = load i32, i32* %10
ret i32 %81
}

LLVM IR (-O2):
@LC_NUMERIC = global i32 0
@.str = [2 x i8] c"C\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [22 x i8] c"\22%s\22,\22%s\22,%f,%f,%.3f\0A\00"
@.str.3 = [42 x i8] c"%s: %s, Lat %f, Long %f, Elevation %.3f.\0A\00"
@.str.4 = [22 x i8] c"%s: %s, No GPS Data.\0A\00"
@.str.5 = [19 x i8] c"%s: No EXIF data.\0A\00"
@str = [14 x i8] c"Out of memory\00"
define i32 @ShowFileDetails(i8* %0, i32 %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = bitcast double* %3 to i8*
%8 = bitcast double* %4 to i8*
%9 = bitcast double* %5 to i8*
%10 = bitcast i32* %6 to i8*
store i32 0, i32* %6
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %3
%11 = call i8* @ReadExifData(i8* %0, double* %3, double* %4, double* %5, i32* %6)
%12 = icmp eq i32 %1, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = icmp eq i8* %11, null
br i1 %14, label %47, label %22
15: ; preds = %2
%16 = load i32, i32* @LC_NUMERIC
%17 = call i8* @setlocale(i32 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i8* %11, null
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, 0
%21 = select i1 %18, i1 true, i1 %20
br i1 %21, label %50, label %25
22: ; preds = %13
%23 = load i32, i32* %6
%24 = icmp eq i32 %23, 0
br i1 %24, label %43, label %38
25: ; preds = %15
%26 = call i8* @CsvEscape(i8* %0)
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %25
%33 = load double, double* %3
%34 = load double, double* %4
%35 = load double, double* %5
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %26, i8* %11, double %33, double %34, double %35)
%37 = call i32 @free(i8* %26)
br label %50
38: ; preds = %22
%39 = load double, double* %3
%40 = load double, double* %4
%41 = load double, double* %5
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* %11, double %39, double %40, double %41)
br label %45
43: ; preds = %22
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* %11)
br label %45
45: ; preds = %38, %43
%46 = call i32 @free(i8* %11)
br label %54
47: ; preds = %13
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%49 = call i32 @free(i8* null)
br label %54
50: ; preds = %15, %32
%51 = call i32 @free(i8* %11)
%52 = load i32, i32* @LC_NUMERIC
%53 = call i8* @setlocale(i32 %52, i8* %17)
br label %54
54: ; preds = %47, %45, %50
%55 = phi i32 [ 1, %50 ], [ 0, %47 ], [ 1, %45 ]
ret i32 %55
}