#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 */
char *alloca(size_t);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, float *, float *);
int /*<<< orphan*/ report(float, float, char *, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, size_t, char *, char *);
scalar_t__ strlen(char *);
int guess_by_file(int argc, char **args) {
  size_t len = (size_t)argc;
  size_t off = 0;
  size_t i;
  char *pathname;
  FILE *f;
  float latitude;
  float longitude;
  for (i = 0; i < (size_t)argc; i++)
    len += strlen(*(args + i));
  pathname = alloca(len * sizeof(char));
  for (i = 0; i < (size_t)argc; i++) {
    snprintf(pathname + off, len, "%s", *(args + i));
    off += strlen(*(args + i));
    *(pathname + off++) = ' ';
  }
  *(pathname + len - 1) = '\0';
  f = fopen(pathname, "r");
  if (f == NULL)
    return 1;
  if (fscanf(f, "%f %f", &latitude, &longitude) < 2) {
    fclose(f);
    return 1;
  }
  report(latitude, longitude, "file", 0, 0);
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<guess_by_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movslq -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    11d2 <guess_by_file+0x62>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1197 <guess_by_file+0x27>
mov    -0x18(%rbp),%rdi
shl    $0x0,%rdi
call   1070 <alloca@plt>
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    1261 <guess_by_file+0xf1>
mov    -0x30(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xde5(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
movb   $0x20,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11eb <guess_by_file+0x7b>
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,-0x1(%rax,%rcx,1)
mov    -0x30(%rbp),%rdi
lea    0xd8a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1299 <guess_by_file+0x129>
movl   $0x1,-0x4(%rbp)
jmp    12f9 <guess_by_file+0x189>
mov    -0x38(%rbp),%rdi
lea    0xd61(%rip),%rsi
lea    -0x3c(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   1060 <fscanf@plt>
cmp    $0x2,%eax
jge    12cf <guess_by_file+0x15f>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f9 <guess_by_file+0x189>
movss  -0x3c(%rbp),%xmm0
movss  -0x40(%rbp),%xmm1
lea    0xd2b(%rip),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1090 <report@plt>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<guess_by_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movslq %edi,%r12
test   %r12d,%r12d
je     121b <guess_by_file+0xab>
mov    %rsi,%r14
mov    %edi,%r13d
cmp    $0x2,%r12
mov    $0x1,%r15d
cmovae %r12,%r15
xor    %ebp,%ebp
mov    %r12,%rbx
mov    (%r14,%rbp,8),%rdi
call   1040 <strlen@plt>
add    %rax,%rbx
add    $0x1,%rbp
cmp    %rbp,%r15
jne    11a0 <guess_by_file+0x30>
mov    %rbx,%rdi
call   1070 <alloca@plt>
mov    %rax,%r15
test   %r13d,%r13d
je     1228 <guess_by_file+0xb8>
cmp    $0x2,%r12
mov    $0x1,%r13d
cmovae %r12,%r13
xor    %ebp,%ebp
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
lea    (%r15,%r12,1),%rdi
mov    (%r14,%rbp,8),%rcx
mov    %rbx,%rsi
lea    0xe0e(%rip),%rdx
call   1050 <snprintf@plt>
mov    (%r14,%rbp,8),%rdi
call   1040 <strlen@plt>
lea    (%rax,%r12,1),%rcx
add    %rax,%r12
add    $0x1,%r12
movb   $0x20,(%r15,%rcx,1)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    11e0 <guess_by_file+0x70>
jmp    1228 <guess_by_file+0xb8>
mov    %r12,%rdi
call   1070 <alloca@plt>
mov    %rax,%r15
xor    %ebx,%ebx
movb   $0x0,-0x1(%r15,%rbx,1)
lea    0xdce(%rip),%rsi
mov    %r15,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     128d <guess_by_file+0x11d>
mov    %rax,%rbx
lea    0xdb9(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    %rax,%rdi
call   1060 <fscanf@plt>
mov    $0x1,%ebp
cmp    $0x2,%eax
jl     1283 <guess_by_file+0x113>
movss  0x4(%rsp),%xmm0
movss  (%rsp),%xmm1
lea    0xd93(%rip),%rdi
xor    %ebp,%ebp
xor    %esi,%esi
xor    %edx,%edx
call   1090 <report@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    1292 <guess_by_file+0x122>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%f %f\00"
@.str.3 = [5 x i8] c"file\00"
define i32 @guess_by_file(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca float
%12 = alloca float
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
store i64 %14, i64* %6
store i64 0, i64* %7
store i64 0, i64* %8
br label %15
15: ; preds = %28, %2
%16 = load i64, i64* %8
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = icmp ult i64 %16, %18
br i1 %19, label %20, label %31
20: ; preds = %15
%21 = load i8**, i8*** %5
%22 = load i64, i64* %8
%23 = getelementptr inbounds i8*, i8** %21, i64 %22
%24 = load i8*, i8** %23
%25 = call i64 @strlen(i8* %24)
%26 = load i64, i64* %6
%27 = add i64 %26, %25
store i64 %27, i64* %6
br label %28
28: ; preds = %20
%29 = load i64, i64* %8
%30 = add i64 %29, 1
store i64 %30, i64* %8
br label %15
31: ; preds = %15
%32 = load i64, i64* %6
%33 = mul i64 %32, 1
%34 = call i8* @alloca(i64 %33)
store i8* %34, i8** %9
store i64 0, i64* %8
br label %35
35: ; preds = %61, %31
%36 = load i64, i64* %8
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = icmp ult i64 %36, %38
br i1 %39, label %40, label %64
40: ; preds = %35
%41 = load i8*, i8** %9
%42 = load i64, i64* %7
%43 = getelementptr inbounds i8, i8* %41, i64 %42
%44 = load i64, i64* %6
%45 = load i8**, i8*** %5
%46 = load i64, i64* %8
%47 = getelementptr inbounds i8*, i8** %45, i64 %46
%48 = load i8*, i8** %47
%49 = call i32 @snprintf(i8* %43, i64 %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %48)
%50 = load i8**, i8*** %5
%51 = load i64, i64* %8
%52 = getelementptr inbounds i8*, i8** %50, i64 %51
%53 = load i8*, i8** %52
%54 = call i64 @strlen(i8* %53)
%55 = load i64, i64* %7
%56 = add i64 %55, %54
store i64 %56, i64* %7
%57 = load i8*, i8** %9
%58 = load i64, i64* %7
%59 = add i64 %58, 1
store i64 %59, i64* %7
%60 = getelementptr inbounds i8, i8* %57, i64 %58
store i8 32, i8* %60
br label %61
61: ; preds = %40
%62 = load i64, i64* %8
%63 = add i64 %62, 1
store i64 %63, i64* %8
br label %35
64: ; preds = %35
%65 = load i8*, i8** %9
%66 = load i64, i64* %6
%67 = getelementptr inbounds i8, i8* %65, i64 %66
%68 = getelementptr inbounds i8, i8* %67, i64 -1
store i8 0, i8* %68
%69 = load i8*, i8** %9
%70 = call i32* @fopen(i8* %69, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %70, i32** %10
%71 = load i32*, i32** %10
%72 = icmp eq i32* %71, null
br i1 %72, label %73, label %74
73: ; preds = %64
store i32 1, i32* %3
br label %87
74: ; preds = %64
%75 = load i32*, i32** %10
%76 = call i32 @fscanf(i32* %75, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), float* %11, float* %12)
%77 = icmp slt i32 %76, 2
br i1 %77, label %78, label %81
78: ; preds = %74
%79 = load i32*, i32** %10
%80 = call i32 @fclose(i32* %79)
store i32 1, i32* %3
br label %87
81: ; preds = %74
%82 = load float, float* %11
%83 = load float, float* %12
%84 = call i32 @report(float %82, float %83, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0)
%85 = load i32*, i32** %10
%86 = call i32 @fclose(i32* %85)
store i32 0, i32* %3
br label %87
87: ; preds = %81, %78, %73
%88 = load i32, i32* %3
ret i32 %88
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%f %f\00"
@.str.3 = [5 x i8] c"file\00"
define i32 @guess_by_file(i32 %0, i8** nocapture %1) {
%3 = alloca float
%4 = alloca float
%5 = sext i32 %0 to i64
%6 = bitcast float* %3 to i8*
%7 = bitcast float* %4 to i8*
%8 = icmp eq i32 %0, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i8* @alloca(i64 %5)
br label %40
11: ; preds = %2
%12 = call i64 @llvm.umax.i64(i64 %5, i64 1)
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ %19, %13 ], [ %5, %11 ]
%15 = phi i64 [ %20, %13 ], [ 0, %11 ]
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = load i8*, i8** %16
%18 = tail call i64 @strlen(i8* dereferenceable(1) %17)
%19 = add i64 %18, %14
%20 = add nuw i64 %15, 1
%21 = icmp eq i64 %20, %12
br i1 %21, label %22, label %13
22: ; preds = %13
%23 = tail call i8* @alloca(i64 %19)
br i1 %8, label %40, label %24
24: ; preds = %22
%25 = call i64 @llvm.umax.i64(i64 %5, i64 1)
br label %26
26: ; preds = %24, %26
%27 = phi i64 [ %38, %26 ], [ 0, %24 ]
%28 = phi i64 [ %36, %26 ], [ 0, %24 ]
%29 = getelementptr inbounds i8, i8* %23, i64 %28
%30 = getelementptr inbounds i8*, i8** %1, i64 %27
%31 = load i8*, i8** %30
%32 = tail call i32 @snprintf(i8* %29, i64 %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %31)
%33 = load i8*, i8** %30
%34 = tail call i64 @strlen(i8* dereferenceable(1) %33)
%35 = add i64 %34, %28
%36 = add i64 %35, 1
%37 = getelementptr inbounds i8, i8* %23, i64 %35
store i8 32, i8* %37
%38 = add nuw i64 %27, 1
%39 = icmp eq i64 %38, %25
br i1 %39, label %40, label %26
40: ; preds = %26, %9, %22
%41 = phi i8* [ %10, %9 ], [ %23, %22 ], [ %23, %26 ]
%42 = phi i64 [ 0, %9 ], [ %19, %22 ], [ %19, %26 ]
%43 = getelementptr inbounds i8, i8* %41, i64 %42
%44 = getelementptr inbounds i8, i8* %43, i64 -1
store i8 0, i8* %44
%45 = tail call i32* @fopen(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%46 = icmp eq i32* %45, null
br i1 %46, label %57, label %47
47: ; preds = %40
%48 = call i32 @fscanf(i32* %45, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), float* %3, float* %4)
%49 = icmp slt i32 %48, 2
br i1 %49, label %54, label %50
50: ; preds = %47
%51 = load float, float* %3
%52 = load float, float* %4
%53 = call i32 @report(float %51, float %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0)
br label %54
54: ; preds = %47, %50
%55 = phi i32 [ 0, %50 ], [ 1, %47 ]
%56 = call i32 @fclose(i32* %45)
br label %57
57: ; preds = %54, %40
%58 = phi i32 [ 1, %40 ], [ %55, %54 ]
ret i32 %58
}