#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int range(float, float, float, int /*<<< orphan*/ *);
int /*<<< orphan*/ sscanf(char *, char *, float *);
int /*<<< orphan*/ stderr;
main(int argc, char **argv) {
  float d, lat, lon;
  FILE *fronts, *out;
  if (argc < 6) {
    (void)fprintf(stderr, "%s synopsis:  %s name lat lon d fronts", argv[0],
                  argv[0]);
    return 1;
  }
  fronts = fopen(argv[5], "r");
  if (fronts == (FILE *)NULL) {
    (void)fprintf(stderr, "%s:  unable to read fronts file %s.\n", argv[0],
                  argv[5]);
    return 2;
  }
  (void)sscanf(argv[2], "%f", &lat);
  (void)sscanf(argv[3], "%f", &lon);
  (void)sscanf(argv[4], "%f", &d);
  switch (range(lat, lon, d, fronts)) {
  case 0:
    out = fopen("close.txt", "a");
    (void)fprintf(out, "%s\tclose\n", argv[1]);
    (void)fclose(out);
    break;
  case 1:
    out = fopen("far.txt", "a");
    (void)fprintf(out, "%s\tfar\n", argv[1]);
    (void)fclose(out);
    break;
  case 2:
    out = fopen("err.txt", "a");
    (void)fprintf(out, "%s\n", argv[1]);
    (void)fclose(out);
    (void)fprintf(stderr, "%s:  unable to parse fronts file %s.\n", argv[0],
                  argv[5]);
    return 2;
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    11a1 <main+0x51>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    137f <main+0x22f>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
lea    0xe77(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11f6 <main+0xa6>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rcx
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    137f <main+0x22f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe49(%rip),%rsi
mov    %rsi,-0x40(%rbp)
lea    -0x18(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x40(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    -0x1c(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x40(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    -0x14(%rbp),%rdx
call   1050 <sscanf@plt>
movss  -0x18(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
mov    -0x28(%rbp),%rdi
call   1060 <range@plt>
mov    %eax,%ecx
mov    %ecx,-0x34(%rbp)
test   %eax,%eax
je     1288 <main+0x138>
jmp    1266 <main+0x116>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
je     12c9 <main+0x179>
jmp    1277 <main+0x127>
mov    -0x34(%rbp),%eax
sub    $0x2,%eax
je     130a <main+0x1ba>
jmp    1378 <main+0x228>
lea    0xdc2(%rip),%rdi
lea    0xdc5(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %eax,%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xda9(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1378 <main+0x228>
lea    0xd97(%rip),%rdi
lea    0xd84(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %eax,%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd7a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1378 <main+0x228>
lea    0xd66(%rip),%rdi
lea    0xd43(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %eax,%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd49(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2c93(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rcx
lea    0xd1e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    137f <main+0x22f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x5,%edi
jg     1187 <main+0x37>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rcx
lea    0xe8d(%rip),%rsi
mov    %rcx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%ebp
jmp    12da <main+0x18a>
mov    0x28(%rbx),%rdi
lea    0xe95(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1235 <main+0xe5>
mov    %rax,%rbp
mov    0x10(%rbx),%rdi
lea    0xea0(%rip),%r14
lea    0x8(%rsp),%rdx
mov    %r14,%rsi
call   1050 <sscanf@plt>
mov    0x18(%rbx),%rdi
lea    0x4(%rsp),%rdx
mov    %r14,%rsi
call   1050 <sscanf@plt>
mov    0x20(%rbx),%rdi
lea    0xc(%rsp),%rdx
mov    %r14,%rsi
call   1050 <sscanf@plt>
movss  0x8(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
movss  0xc(%rsp),%xmm2
mov    %rbp,%rdi
call   1060 <range@plt>
cmp    $0x2,%eax
je     124e <main+0xfe>
cmp    $0x1,%eax
je     12a5 <main+0x155>
xor    %ebp,%ebp
test   %eax,%eax
jne    12da <main+0x18a>
lea    0xe3b(%rip),%rdi
lea    0xe3e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
mov    0x8(%rbx),%rdx
lea    0xe2d(%rip),%rsi
jmp    12c6 <main+0x176>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
mov    0x28(%rbx),%rcx
lea    0xddd(%rip),%rsi
jmp    1297 <main+0x147>
lea    0xe22(%rip),%rdi
lea    0xdff(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbp
mov    0x8(%rbx),%rdx
lea    0xe10(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %rbp,%rdi
call   1030 <fclose@plt>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
mov    0x28(%rbx),%rcx
lea    0xdec(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x2,%ebp
jmp    12da <main+0x18a>
lea    0xdbb(%rip),%rdi
lea    0xda8(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
mov    0x8(%rbx),%rdx
lea    0xda9(%rip),%rsi
xor    %ebp,%ebp
mov    %r14d,%edi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"%s synopsis: %s name lat lon d fronts\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [37 x i8] c"%s: unable to read fronts file %s.\0A\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [10 x i8] c"close.txt\00"
@.str.5 = [2 x i8] c"a\00"
@.str.6 = [10 x i8] c"%s\09close\0A\00"
@.str.7 = [8 x i8] c"far.txt\00"
@.str.8 = [8 x i8] c"%s\09far\0A\00"
@.str.9 = [8 x i8] c"err.txt\00"
@.str.10 = [4 x i8] c"%s\0A\00"
@.str.11 = [38 x i8] c"%s: unable to parse fronts file %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca i32*
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 6
br i1 %12, label %13, label %22
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %20)
store i32 1, i32* %3
br label %95
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 5
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %9
%27 = load i32*, i32** %9
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %38
29: ; preds = %22
%30 = load i32, i32* @stderr
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 5
%36 = load i8*, i8** %35
%37 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %33, i8* %36)
store i32 2, i32* %3
br label %95
38: ; preds = %22
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 2
%41 = load i8*, i8** %40
%42 = call i32 @sscanf(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %7)
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 3
%45 = load i8*, i8** %44
%46 = call i32 @sscanf(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %8)
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 4
%49 = load i8*, i8** %48
%50 = call i32 @sscanf(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %6)
%51 = load float, float* %7
%52 = load float, float* %8
%53 = load float, float* %6
%54 = load i32*, i32** %9
%55 = call i32 @range(float %51, float %52, float %53, i32* %54)
switch i32 %55, label %94 [
i32 0, label %56
i32 1, label %66
i32 2, label %76
]
56: ; preds = %38
%57 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %57, i32** %10
%58 = load i32*, i32** %10
%59 = ptrtoint i32* %58 to i32
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 1
%62 = load i8*, i8** %61
%63 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %62)
%64 = load i32*, i32** %10
%65 = call i32 @fclose(i32* %64)
br label %94
66: ; preds = %38
%67 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %67, i32** %10
%68 = load i32*, i32** %10
%69 = ptrtoint i32* %68 to i32
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 1
%72 = load i8*, i8** %71
%73 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %72)
%74 = load i32*, i32** %10
%75 = call i32 @fclose(i32* %74)
br label %94
76: ; preds = %38
%77 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %77, i32** %10
%78 = load i32*, i32** %10
%79 = ptrtoint i32* %78 to i32
%80 = load i8**, i8*** %5
%81 = getelementptr inbounds i8*, i8** %80, i64 1
%82 = load i8*, i8** %81
%83 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %82)
%84 = load i32*, i32** %10
%85 = call i32 @fclose(i32* %84)
%86 = load i32, i32* @stderr
%87 = load i8**, i8*** %5
%88 = getelementptr inbounds i8*, i8** %87, i64 0
%89 = load i8*, i8** %88
%90 = load i8**, i8*** %5
%91 = getelementptr inbounds i8*, i8** %90, i64 5
%92 = load i8*, i8** %91
%93 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i8* %89, i8* %92)
store i32 2, i32* %3
br label %95
94: ; preds = %38, %66, %56
store i32 0, i32* %3
br label %95
95: ; preds = %94, %76, %29, %13
%96 = load i32, i32* %3
ret i32 %96
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"%s synopsis: %s name lat lon d fronts\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [37 x i8] c"%s: unable to read fronts file %s.\0A\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [10 x i8] c"close.txt\00"
@.str.5 = [2 x i8] c"a\00"
@.str.6 = [10 x i8] c"%s\09close\0A\00"
@.str.7 = [8 x i8] c"far.txt\00"
@.str.8 = [8 x i8] c"%s\09far\0A\00"
@.str.9 = [8 x i8] c"err.txt\00"
@.str.10 = [4 x i8] c"%s\0A\00"
@.str.11 = [38 x i8] c"%s: unable to parse fronts file %s.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = bitcast float* %3 to i8*
%7 = bitcast float* %4 to i8*
%8 = bitcast float* %5 to i8*
%9 = icmp slt i32 %0, 6
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %12)
br label %66
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 5
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %1
%22 = load i8*, i8** %15
%23 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %21, i8* %22)
br label %66
24: ; preds = %14
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%28 = getelementptr inbounds i8*, i8** %1, i64 3
%29 = load i8*, i8** %28
%30 = call i32 @sscanf(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %5)
%31 = getelementptr inbounds i8*, i8** %1, i64 4
%32 = load i8*, i8** %31
%33 = call i32 @sscanf(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%34 = load float, float* %4
%35 = load float, float* %5
%36 = load float, float* %3
%37 = call i32 @range(float %34, float %35, float %36, i32* %17)
switch i32 %37, label %66 [
i32 0, label %38
i32 1, label %46
i32 2, label %54
]
38: ; preds = %24
%39 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%40 = ptrtoint i32* %39 to i64
%41 = trunc i64 %40 to i32
%42 = getelementptr inbounds i8*, i8** %1, i64 1
%43 = load i8*, i8** %42
%44 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %43)
%45 = call i32 @fclose(i32* %39)
br label %66
46: ; preds = %24
%47 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%48 = ptrtoint i32* %47 to i64
%49 = trunc i64 %48 to i32
%50 = getelementptr inbounds i8*, i8** %1, i64 1
%51 = load i8*, i8** %50
%52 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %51)
%53 = call i32 @fclose(i32* %47)
br label %66
54: ; preds = %24
%55 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%56 = ptrtoint i32* %55 to i64
%57 = trunc i64 %56 to i32
%58 = getelementptr inbounds i8*, i8** %1, i64 1
%59 = load i8*, i8** %58
%60 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %59)
%61 = call i32 @fclose(i32* %55)
%62 = load i32, i32* @stderr
%63 = load i8*, i8** %1
%64 = load i8*, i8** %15
%65 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i8* %63, i8* %64)
br label %66
66: ; preds = %38, %46, %24, %54, %19, %10
%67 = phi i32 [ 1, %10 ], [ 2, %19 ], [ 2, %54 ], [ 0, %24 ], [ 0, %46 ], [ 0, %38 ]
ret i32 %67
}