#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 */
struct raster {
  int dummy;
};
struct hgt {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
double atof(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ marklocation(struct raster *, struct hgt *, double, double,
                                char *, int);
int /*<<< orphan*/ perror(char *);
char *strchr(char *, char);
int strlen(char *);
void markcities(struct raster *ra, struct hgt *hgt, char *pattern,
                int fontsize) {
  FILE *fp;
  char buf[1024];
  pattern = pattern;
  fp = fopen("cities_it.txt", "r");
  if (!fp)
    perror("Can't open cities_it.txt");
  while (fgets(buf, 1024, fp) != NULL) {
    char *name, *slat, *slon, *p;
    double lat, lon;
    buf[1023] = '\0';
    if (buf[strlen(buf) - 1] == '\r')
      buf[strlen(buf) - 1] = '\0';
    if (buf[strlen(buf) - 1] == '\n')
      buf[strlen(buf) - 1] = '\0';
    p = strchr(buf, ',');
    if (!p)
      continue;
    name = p + 1;
    p = strchr(name, ',');
    if (!p)
      continue;
    *p = '\0';
    p = strchr(p + 1, ',');
    if (!p)
      continue;
    p = strchr(p + 1, ',');
    if (!p)
      continue;
    slat = p + 1;
    p = strchr(p + 1, ',');
    if (!p)
      continue;
    *p = '\0';
    slon = p + 1;
    lat = atof(slat);
    lon = atof(slon);
    marklocation(ra, hgt, lat, lon, name, fontsize);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<markcities>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xe64(%rip),%rdi
lea    0xe50(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11d0 <markcities+0x50>
lea    0xe37(%rip),%rdi
call   10a0 <perror@plt>
jmp    11d5 <markcities+0x55>
lea    -0x430(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x400,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     13ef <markcities+0x26f>
movb   $0x0,-0x31(%rbp)
lea    -0x430(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x430(%rbp,%rax,1),%eax
ff
cmp    $0xd,%eax
jne    1233 <markcities+0xb3>
lea    -0x430(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x430(%rbp,%rax,1)
lea    -0x430(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x430(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    126e <markcities+0xee>
lea    -0x430(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x430(%rbp,%rax,1)
lea    -0x430(%rbp),%rdi
mov    $0x2c,%esi
call   1070 <strchr@plt>
mov    %rax,-0x450(%rbp)
cmpq   $0x0,-0x450(%rbp)
jne    1299 <markcities+0x119>
jmp    11d5 <markcities+0x55>
mov    -0x450(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x438(%rbp)
mov    -0x438(%rbp),%rdi
mov    $0x2c,%esi
call   1070 <strchr@plt>
mov    %rax,-0x450(%rbp)
cmpq   $0x0,-0x450(%rbp)
jne    12d6 <markcities+0x156>
jmp    11d5 <markcities+0x55>
mov    -0x450(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x450(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2c,%esi
call   1070 <strchr@plt>
mov    %rax,-0x450(%rbp)
cmpq   $0x0,-0x450(%rbp)
jne    130f <markcities+0x18f>
jmp    11d5 <markcities+0x55>
mov    -0x450(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2c,%esi
call   1070 <strchr@plt>
mov    %rax,-0x450(%rbp)
cmpq   $0x0,-0x450(%rbp)
jne    133e <markcities+0x1be>
jmp    11d5 <markcities+0x55>
mov    -0x450(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x440(%rbp)
mov    -0x450(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2c,%esi
call   1070 <strchr@plt>
mov    %rax,-0x450(%rbp)
cmpq   $0x0,-0x450(%rbp)
jne    137f <markcities+0x1ff>
jmp    11d5 <markcities+0x55>
mov    -0x450(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x450(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x448(%rbp)
mov    -0x440(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x458(%rbp)
ff
mov    -0x448(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x460(%rbp)
ff
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movsd  -0x458(%rbp),%xmm0
ff
movsd  -0x460(%rbp),%xmm1
ff
mov    -0x438(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1060 <marklocation@plt>
jmp    11d5 <markcities+0x55>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<markcities>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %ecx,0xc(%rsp)
mov    %rsi,0x10(%rsp)
mov    %rdi,%r12
lea    0xe69(%rip),%rdi
lea    0xe55(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r13
test   %rax,%rax
je     1310 <markcities+0x190>
lea    0x20(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %r13,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12f6 <markcities+0x176>
movb   $0x0,0x41f(%rsp)
mov    %rbp,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0xd,-0x1(%rax,%rbp,1)
jne    1211 <markcities+0x91>
mov    %rbp,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
mov    %rbp,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbp,1)
jne    1231 <markcities+0xb1>
mov    %rbp,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
mov    %rbp,%rdi
mov    $0x2c,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     11d0 <markcities+0x50>
mov    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     11d0 <markcities+0x50>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rax,%rdi
mov    $0x2c,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     11d0 <markcities+0x50>
add    $0x1,%rax
mov    %rax,%rdi
mov    $0x2c,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     11d0 <markcities+0x50>
mov    %rax,%r14
add    $0x1,%r14
mov    %r14,%rdi
mov    $0x2c,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     11d0 <markcities+0x50>
mov    %rax,%r15
movb   $0x0,(%rax)
add    $0x1,%r15
mov    %r14,%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x18(%rsp)
mov    %r15,%rdi
call   1030 <atof@plt>
movaps %xmm0,%xmm1
mov    %r12,%rdi
mov    0x10(%rsp),%rsi
movsd  0x18(%rsp),%xmm0
mov    %rbx,%rdx
mov    0xc(%rsp),%ecx
call   1060 <marklocation@plt>
jmp    11d0 <markcities+0x50>
mov    %r13,%rdi
call   1040 <fclose@plt>
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xceb(%rip),%rdi
call   10a0 <perror@plt>
jmp    11bc <markcities+0x3c>

LLVM IR (-O0):
%struct.raster = type { i32 }
%struct.hgt = type { i32 }
@.str = [14 x i8] c"cities_it.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [25 x i8] c"Can't open cities_it.txt\00"
define void @markcities(%struct.raster* %0, %struct.hgt* %1, i8* %2, i32 %3) {
%5 = alloca %struct.raster*
%6 = alloca %struct.hgt*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca [1024 x i8]
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca double
%16 = alloca double
store %struct.raster* %0, %struct.raster** %5
store %struct.hgt* %1, %struct.hgt** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%17 = load i8*, i8** %7
store i8* %17, i8** %7
%18 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %9
%19 = load i32*, i32** %9
%20 = icmp ne i32* %19, null
br i1 %20, label %23, label %21
21: ; preds = %4
%22 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %4
br label %24
24: ; preds = %98, %97, %88, %81, %73, %65, %23
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%26 = load i32*, i32** %9
%27 = call i32* @fgets(i8* %25, i32 1024, i32* %26)
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %113
29: ; preds = %24
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 1023
store i8 0, i8* %30
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%32 = call i32 @strlen(i8* %31)
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 13
br i1 %38, label %39, label %45
39: ; preds = %29
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%41 = call i32 @strlen(i8* %40)
%42 = sub nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 %43
store i8 0, i8* %44
br label %45
45: ; preds = %39, %29
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%47 = call i32 @strlen(i8* %46)
%48 = sub nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 10
br i1 %53, label %54, label %60
54: ; preds = %45
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%56 = call i32 @strlen(i8* %55)
%57 = sub nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 %58
store i8 0, i8* %59
br label %60
60: ; preds = %54, %45
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%62 = call i8* @strchr(i8* %61, i8 signext 44)
store i8* %62, i8** %14
%63 = load i8*, i8** %14
%64 = icmp ne i8* %63, null
br i1 %64, label %66, label %65
65: ; preds = %60
br label %24
66: ; preds = %60
%67 = load i8*, i8** %14
%68 = getelementptr inbounds i8, i8* %67, i64 1
store i8* %68, i8** %11
%69 = load i8*, i8** %11
%70 = call i8* @strchr(i8* %69, i8 signext 44)
store i8* %70, i8** %14
%71 = load i8*, i8** %14
%72 = icmp ne i8* %71, null
br i1 %72, label %74, label %73
73: ; preds = %66
br label %24
74: ; preds = %66
%75 = load i8*, i8** %14
store i8 0, i8* %75
%76 = load i8*, i8** %14
%77 = getelementptr inbounds i8, i8* %76, i64 1
%78 = call i8* @strchr(i8* %77, i8 signext 44)
store i8* %78, i8** %14
%79 = load i8*, i8** %14
%80 = icmp ne i8* %79, null
br i1 %80, label %82, label %81
81: ; preds = %74
br label %24
82: ; preds = %74
%83 = load i8*, i8** %14
%84 = getelementptr inbounds i8, i8* %83, i64 1
%85 = call i8* @strchr(i8* %84, i8 signext 44)
store i8* %85, i8** %14
%86 = load i8*, i8** %14
%87 = icmp ne i8* %86, null
br i1 %87, label %89, label %88
88: ; preds = %82
br label %24
89: ; preds = %82
%90 = load i8*, i8** %14
%91 = getelementptr inbounds i8, i8* %90, i64 1
store i8* %91, i8** %12
%92 = load i8*, i8** %14
%93 = getelementptr inbounds i8, i8* %92, i64 1
%94 = call i8* @strchr(i8* %93, i8 signext 44)
store i8* %94, i8** %14
%95 = load i8*, i8** %14
%96 = icmp ne i8* %95, null
br i1 %96, label %98, label %97
97: ; preds = %89
br label %24
98: ; preds = %89
%99 = load i8*, i8** %14
store i8 0, i8* %99
%100 = load i8*, i8** %14
%101 = getelementptr inbounds i8, i8* %100, i64 1
store i8* %101, i8** %13
%102 = load i8*, i8** %12
%103 = call double @atof(i8* %102)
store double %103, double* %15
%104 = load i8*, i8** %13
%105 = call double @atof(i8* %104)
store double %105, double* %16
%106 = load %struct.raster*, %struct.raster** %5
%107 = load %struct.hgt*, %struct.hgt** %6
%108 = load double, double* %15
%109 = load double, double* %16
%110 = load i8*, i8** %11
%111 = load i32, i32* %8
%112 = call i32 @marklocation(%struct.raster* %106, %struct.hgt* %107, double %108, double %109, i8* %110, i32 %111)
br label %24
113: ; preds = %24
%114 = load i32*, i32** %9
%115 = call i32 @fclose(i32* %114)
ret void
}

LLVM IR (-O2):
%struct.raster = type { i32 }
%struct.hgt = type { i32 }
@.str = [14 x i8] c"cities_it.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [25 x i8] c"Can't open cities_it.txt\00"
define void @markcities(%struct.raster* %0, %struct.hgt* %1, i8* nocapture readnone %2, i32 %3) {
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %9, %4
%12 = call i32* @fgets(i8* %6, i32 1024, i32* %7)
%13 = icmp eq i32* %12, null
br i1 %13, label %67, label %14
14: ; preds = %11
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 1023
br label %16
16: ; preds = %14, %64
store i8 0, i8* %15
%17 = call i32 @strlen(i8* %6)
%18 = add nsw i32 %17, -1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 13
br i1 %22, label %23, label %28
23: ; preds = %16
%24 = call i32 @strlen(i8* %6)
%25 = add nsw i32 %24, -1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %26
store i8 0, i8* %27
br label %28
28: ; preds = %23, %16
%29 = call i32 @strlen(i8* %6)
%30 = add nsw i32 %29, -1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 10
br i1 %34, label %35, label %40
35: ; preds = %28
%36 = call i32 @strlen(i8* %6)
%37 = add nsw i32 %36, -1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %38
store i8 0, i8* %39
br label %40
40: ; preds = %35, %28
%41 = call i8* @strchr(i8* %6, i8 signext 44)
%42 = icmp eq i8* %41, null
br i1 %42, label %64, label %43
43: ; preds = %40
%44 = getelementptr inbounds i8, i8* %41, i64 1
%45 = call i8* @strchr(i8* %44, i8 signext 44)
%46 = icmp eq i8* %45, null
br i1 %46, label %64, label %47
47: ; preds = %43
store i8 0, i8* %45
%48 = getelementptr inbounds i8, i8* %45, i64 1
%49 = call i8* @strchr(i8* %48, i8 signext 44)
%50 = icmp eq i8* %49, null
br i1 %50, label %64, label %51
51: ; preds = %47
%52 = getelementptr inbounds i8, i8* %49, i64 1
%53 = call i8* @strchr(i8* %52, i8 signext 44)
%54 = icmp eq i8* %53, null
br i1 %54, label %64, label %55
55: ; preds = %51
%56 = getelementptr inbounds i8, i8* %53, i64 1
%57 = call i8* @strchr(i8* %56, i8 signext 44)
%58 = icmp eq i8* %57, null
br i1 %58, label %64, label %59
59: ; preds = %55
store i8 0, i8* %57
%60 = getelementptr inbounds i8, i8* %57, i64 1
%61 = call double @atof(i8* %56)
%62 = call double @atof(i8* %60)
%63 = call i32 @marklocation(%struct.raster* %0, %struct.hgt* %1, double %61, double %62, i8* %44, i32 %3)
br label %64
64: ; preds = %55, %51, %47, %43, %40, %59
%65 = call i32* @fgets(i8* %6, i32 1024, i32* %7)
%66 = icmp eq i32* %65, null
br i1 %66, label %67, label %16
67: ; preds = %64, %11
%68 = call i32 @fclose(i32* %7)
ret void
}