#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, long);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *, char *, long *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char city[15], country[15];
  char cityT[15];
  long pop, tot = 0, topP = 0;
  FILE *fp, *fIre, *fMil;
  fMil = fopen("fMil.txt", "wt");
  fIre = fopen("fIre.txt", "wt");
  fp = fopen("population.txt", "rt");
  while (fscanf(fp, "%s %s %ld", country, city, &pop) != EOF) {
    if (strcmp(country, "ireland") == 0) {
      fputs(city, fIre);
      fputc('\n', fIre);
    }
    if (pop >= 1000000) {
      fputs(city, fMil);
      fputc(' ', fMil);
      fprintf(fMil, "%ld", pop);
      fputc('\n', fMil);
    }
    if (pop > topP) {
      topP = pop;
      strcpy(cityT, city);
    }
    tot += pop;
  }
  printf("Total Population: %ld\n", tot);
  printf("Highest population: %s %ld\n", cityT, topP);
  printf("\n[Press any key to clsose]");
  getchar();
  fclose(fMil);
  fclose(fIre);
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
lea    0xe3a(%rip),%rdi
lea    0xe3c(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x68(%rbp)
lea    0xe2f(%rip),%rdi
lea    0xe25(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x60(%rbp)
lea    0xe21(%rip),%rdi
lea    0xe29(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
lea    -0x22(%rbp),%rdx
lea    -0x13(%rbp),%rcx
lea    0xe10(%rip),%rsi
lea    -0x40(%rbp),%r8
call   1070 <fscanf@plt>
mov    0x2dc1(%rip),%rcx
cmp    (%rcx),%rax
je     12e4 <main+0x144>
lea    -0x22(%rbp),%rdi
lea    0xdf6(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1265 <main+0xc5>
lea    -0x13(%rbp),%rdi
mov    -0x60(%rbp),%rsi
call   1060 <fputs@plt>
mov    -0x60(%rbp),%rsi
mov    $0xa,%edi
call   1080 <fputc@plt>
cmpq   $0xf4240,-0x40(%rbp)
jl     12b0 <main+0x110>
lea    -0x13(%rbp),%rdi
mov    -0x68(%rbp),%rsi
call   1060 <fputs@plt>
mov    -0x68(%rbp),%rsi
mov    $0x20,%edi
call   1080 <fputc@plt>
mov    -0x68(%rbp),%rdi
mov    -0x40(%rbp),%rdx
lea    0xd90(%rip),%rsi
call   10b0 <fprintf@plt>
mov    -0x68(%rbp),%rsi
mov    $0xa,%edi
call   1080 <fputc@plt>
mov    -0x40(%rbp),%rax
cmp    -0x50(%rbp),%rax
jle    12d3 <main+0x133>
mov    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x31(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x40(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    1204 <main+0x64>
mov    -0x48(%rbp),%rsi
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x31(%rbp),%rsi
mov    -0x50(%rbp),%rdx
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   10a0 <getchar@plt>
mov    -0x68(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x60(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x58(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xe4b(%rip),%rdi
lea    0xe4d(%rip),%rbx
mov    %rbx,%rsi
call   10c0 <fopen@plt>
mov    %rax,%r12
lea    0xe3e(%rip),%rdi
mov    %rbx,%rsi
call   10c0 <fopen@plt>
mov    %rax,0x10(%rsp)
lea    0xe33(%rip),%rdi
lea    0xe3b(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%rbp
lea    0xe2f(%rip),%rsi
lea    0x39(%rsp),%rdx
lea    0x1b(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %rax,%rdi
call   1070 <fscanf@plt>
mov    0x2dd2(%rip),%rcx
cmp    (%rcx),%rax
jne    1287 <main+0xe7>
xor    %r14d,%r14d
xor    %ebx,%ebx
lea    0xe12(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe18(%rip),%rdi
lea    0x2a(%rsp),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe1e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   10a0 <getchar@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    0x10(%rsp),%rdi
call   1040 <fclose@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
lea    0x39(%rsp),%rdi
xor    %r15d,%r15d
jmp    12e7 <main+0x147>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x2a(%rsp),%rdi
mov    %rcx,%rsi
call   1030 <strcpy@plt>
lea    0x1b(%rsp),%rcx
mov    0x8(%rsp),%rax
mov    %r14,%r15
add    %rax,%rbx
mov    %rbp,%rdi
lea    0xd60(%rip),%rsi
mov    %r13,%rdx
lea    0x8(%rsp),%r8
call   1070 <fscanf@plt>
mov    %r13,%rdi
mov    0x2d0a(%rip),%rcx
cmp    (%rcx),%rax
je     1220 <main+0x80>
mov    %rdi,%r13
lea    0xd40(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
jne    1320 <main+0x180>
lea    0x1b(%rsp),%rdi
mov    %rbp,%r14
mov    0x10(%rsp),%rbp
mov    %rbp,%rsi
call   1060 <fputs@plt>
mov    $0xa,%edi
mov    %rbp,%rsi
mov    %r14,%rbp
call   1080 <fputc@plt>
mov    0x8(%rsp),%r14
cmp    $0xf4240,%r14
lea    0x1b(%rsp),%rcx
jl     1376 <main+0x1d6>
mov    %rcx,%rdi
mov    %r12,%rsi
call   1060 <fputs@plt>
mov    $0x20,%edi
mov    %r12,%rsi
call   1080 <fputc@plt>
mov    0x8(%rsp),%rdx
mov    %r12,%rdi
lea    0xcd3(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0xa,%edi
mov    %r12,%rsi
call   1080 <fputc@plt>
lea    0x1b(%rsp),%rcx
mov    0x8(%rsp),%r14
cmp    %r15,%r14
jg     12a0 <main+0x100>
mov    %r14,%rax
mov    %r15,%r14
jmp    12ba <main+0x11a>

LLVM IR (-O0):
@.str = [9 x i8] c"fMil.txt\00"
@.str.1 = [3 x i8] c"wt\00"
@.str.2 = [9 x i8] c"fIre.txt\00"
@.str.3 = [15 x i8] c"population.txt\00"
@.str.4 = [3 x i8] c"rt\00"
@.str.5 = [10 x i8] c"%s %s %ld\00"
@EOF = global i64 0
@.str.6 = [8 x i8] c"ireland\00"
@.str.7 = [4 x i8] c"%ld\00"
@.str.8 = [23 x i8] c"Total Population: %ld\0A\00"
@.str.9 = [28 x i8] c"Highest population: %s %ld\0A\00"
@.str.10 = [27 x i8] c"\0A[Press any key to clsose]\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x i8]
%3 = alloca [15 x i8]
%4 = alloca [15 x i8]
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
store i32 0, i32* %1
store i64 0, i64* %6
store i64 0, i64* %7
%11 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %10
%12 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %9
%13 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %13, i32** %8
br label %14
14: ; preds = %54, %0
%15 = load i32*, i32** %8
%16 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%17 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%18 = call i64 @fscanf(i32* %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %16, i8* %17, i64* %5)
%19 = load i64, i64* @EOF
%20 = icmp ne i64 %18, %19
br i1 %20, label %21, label %58
21: ; preds = %14
%22 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %21
%26 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%27 = load i32*, i32** %9
%28 = call i32 @fputs(i8* %26, i32* %27)
%29 = load i32*, i32** %9
%30 = call i32 @fputc(i8 signext 10, i32* %29)
br label %31
31: ; preds = %25, %21
%32 = load i64, i64* %5
%33 = icmp sge i64 %32, 1000000
br i1 %33, label %34, label %45
34: ; preds = %31
%35 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%36 = load i32*, i32** %10
%37 = call i32 @fputs(i8* %35, i32* %36)
%38 = load i32*, i32** %10
%39 = call i32 @fputc(i8 signext 32, i32* %38)
%40 = load i32*, i32** %10
%41 = load i64, i64* %5
%42 = call i32 @fprintf(i32* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i64 %41)
%43 = load i32*, i32** %10
%44 = call i32 @fputc(i8 signext 10, i32* %43)
br label %45
45: ; preds = %34, %31
%46 = load i64, i64* %5
%47 = load i64, i64* %7
%48 = icmp sgt i64 %46, %47
br i1 %48, label %49, label %54
49: ; preds = %45
%50 = load i64, i64* %5
store i64 %50, i64* %7
%51 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%52 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%53 = call i32 @strcpy(i8* %51, i8* %52)
br label %54
54: ; preds = %49, %45
%55 = load i64, i64* %5
%56 = load i64, i64* %6
%57 = add nsw i64 %56, %55
store i64 %57, i64* %6
br label %14
58: ; preds = %14
%59 = load i64, i64* %6
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i64 %59)
%61 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%62 = load i64, i64* %7
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i8* %61, i64 %62)
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%65 = call i32 (...) @getchar()
%66 = load i32*, i32** %10
%67 = call i32 @fclose(i32* %66)
%68 = load i32*, i32** %9
%69 = call i32 @fclose(i32* %68)
%70 = load i32*, i32** %8
%71 = call i32 @fclose(i32* %70)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"fMil.txt\00"
@.str.1 = [3 x i8] c"wt\00"
@.str.2 = [9 x i8] c"fIre.txt\00"
@.str.3 = [15 x i8] c"population.txt\00"
@.str.4 = [3 x i8] c"rt\00"
@.str.5 = [10 x i8] c"%s %s %ld\00"
@EOF = global i64 0
@.str.6 = [8 x i8] c"ireland\00"
@.str.7 = [4 x i8] c"%ld\00"
@.str.8 = [23 x i8] c"Total Population: %ld\0A\00"
@.str.9 = [28 x i8] c"Highest population: %s %ld\0A\00"
@.str.10 = [27 x i8] c"\0A[Press any key to clsose]\00"
define i32 @main() {
%1 = alloca [15 x i8]
%2 = alloca [15 x i8]
%3 = alloca [15 x i8]
%4 = alloca i64
%5 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%8 = bitcast i64* %4 to i8*
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%12 = call i64 @fscanf(i32* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %6, i8* %5, i64* %4)
%13 = load i64, i64* @EOF
%14 = icmp eq i64 %12, %13
br i1 %14, label %46, label %15
15: ; preds = %0, %39
%16 = phi i64 [ %42, %39 ], [ 0, %0 ]
%17 = phi i64 [ %41, %39 ], [ 0, %0 ]
%18 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = call i32 @fputs(i8* %5, i32* %10)
%22 = call i32 @fputc(i8 signext 10, i32* %10)
br label %23
23: ; preds = %20, %15
%24 = load i64, i64* %4
%25 = icmp sgt i64 %24, 999999
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = call i32 @fputs(i8* %5, i32* %9)
%28 = call i32 @fputc(i8 signext 32, i32* %9)
%29 = load i64, i64* %4
%30 = call i32 @fprintf(i32* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i64 %29)
%31 = call i32 @fputc(i8 signext 10, i32* %9)
%32 = load i64, i64* %4
br label %33
33: ; preds = %26, %23
%34 = phi i64 [ %32, %26 ], [ %24, %23 ]
%35 = icmp sgt i64 %34, %17
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = call i32 @strcpy(i8* %7, i8* %5)
%38 = load i64, i64* %4
br label %39
39: ; preds = %36, %33
%40 = phi i64 [ %38, %36 ], [ %34, %33 ]
%41 = phi i64 [ %34, %36 ], [ %17, %33 ]
%42 = add nsw i64 %40, %16
%43 = call i64 @fscanf(i32* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %6, i8* %5, i64* %4)
%44 = load i64, i64* @EOF
%45 = icmp eq i64 %43, %44
br i1 %45, label %46, label %15
46: ; preds = %39, %0
%47 = phi i64 [ 0, %0 ], [ %41, %39 ]
%48 = phi i64 [ 0, %0 ], [ %42, %39 ]
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i64 %48)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i8* %7, i64 %47)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%52 = call i32 (...) @getchar()
%53 = call i32 @fclose(i32* %9)
%54 = call i32 @fclose(i32* %10)
%55 = call i32 @fclose(i32* %11)
ret i32 0
}