#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 */
int EOF;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ stderr;
int toupper(int /*<<< orphan*/);
int load_cities(char cities[42][101]) {
  int character = 0;
  int char_count = 0;
  int cities_count = 0;
  int long_name = 0;
  while ((character = toupper(getchar())) != EOF) {
    while (character != '\n') {
      if (!(character > 31 && character < 127)) {
        return -1;
      }
      if (char_count < 100)
        cities[cities_count][char_count] = character;
      char_count++;
      character = toupper(getchar());
    }
    if (char_count > 100) {
      cities[cities_count][100] = '\0';
      if (long_name == 0) {
        fprintf(stderr,
                "Warning: Some of city name is longer than 100 characters! "
                "Rest of characters in that name will be dropped!\n");
        long_name = 1;
      }
    } else {
      cities[cities_count][char_count] = '\0';
    }
    char_count = 0;
    cities_count++;
  }
  return cities_count;
}


x86 assembly (clang, -O0):
<load_cities>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%edi
call   1030 <toupper@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e78(%rip),%rcx
cmp    (%rcx),%eax
je     125f <load_cities+0x12f>
jmp    117d <load_cities+0x4d>
cmpl   $0xa,-0x14(%rbp)
je     11eb <load_cities+0xbb>
cmpl   $0x1f,-0x14(%rbp)
jle    119b <load_cities+0x6b>
cmpl   $0x7f,-0x14(%rbp)
jl     11a7 <load_cities+0x77>
movl   $0xffffffff,-0x4(%rbp)
jmp    1265 <load_cities+0x135>
cmpl   $0x64,-0x18(%rbp)
jge    11cc <load_cities+0x9c>
mov    -0x14(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x65,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%edi
call   1030 <toupper@plt>
mov    %eax,-0x14(%rbp)
jmp    117d <load_cities+0x4d>
cmpl   $0x64,-0x18(%rbp)
jle    1233 <load_cities+0x103>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x65,%rcx,%rcx
add    %rcx,%rax
movb   $0x0,0x64(%rax)
cmpl   $0x0,-0x20(%rbp)
jne    122e <load_cities+0xfe>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
lea    0xdde(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x20(%rbp)
jmp    124a <load_cities+0x11a>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x65,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1158 <load_cities+0x28>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_cities>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%edi
call   1030 <toupper@plt>
mov    0x2e93(%rip),%r12
cmp    (%r12),%eax
je     1225 <load_cities+0xf5>
mov    %r14,%rbp
xor    %ebx,%ebx
xor    %r13d,%r13d
xor    %r15d,%r15d
cmp    $0xa,%eax
jne    1197 <load_cities+0x67>
jmp    11f0 <load_cities+0xc0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%edi
call   1030 <toupper@plt>
cmp    $0xa,%eax
je     11b0 <load_cities+0x80>
lea    -0x20(%rax),%ecx
cmp    $0x5e,%ecx
ja     1220 <load_cities+0xf0>
cmp    $0x63,%r15
ja     1180 <load_cities+0x50>
mov    %al,0x0(%rbp,%r15,1)
jmp    1180 <load_cities+0x50>
cmp    $0x65,%r15d
jb     11f0 <load_cities+0xc0>
imul   $0x65,%rbx,%rax
movb   $0x0,0x64(%r14,%rax,1)
test   %r13d,%r13d
jne    11da <load_cities+0xaa>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
lea    0xe2b(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%r13d
jmp    11fe <load_cities+0xce>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15d,%eax
imul   $0x65,%rbx,%rcx
add    %r14,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%edi
call   1030 <toupper@plt>
add    $0x65,%rbp
cmp    (%r12),%eax
jne    1167 <load_cities+0x37>
jmp    1225 <load_cities+0xf5>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@stderr = global i32 0
@.str = [108 x i8] c"Warning: Some of city name is longer than 100 characters! Rest of characters in that name will be dropped!\0A\00"
define i32 @load_cities([101 x i8]* %0) {
%2 = alloca i32
%3 = alloca [101 x i8]*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store [101 x i8]* %0, [101 x i8]** %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %65, %1
%9 = call i32 (...) @getchar()
%10 = call i32 @toupper(i32 %9)
store i32 %10, i32* %4
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %68
13: ; preds = %8
br label %14
14: ; preds = %37, %13
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 10
br i1 %16, label %17, label %42
17: ; preds = %14
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 31
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* %4
%22 = icmp slt i32 %21, 127
br i1 %22, label %24, label %23
23: ; preds = %20, %17
store i32 -1, i32* %2
br label %70
24: ; preds = %20
%25 = load i32, i32* %5
%26 = icmp slt i32 %25, 100
br i1 %26, label %27, label %37
27: ; preds = %24
%28 = load i32, i32* %4
%29 = trunc i32 %28 to i8
%30 = load [101 x i8]*, [101 x i8]** %3
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [101 x i8], [101 x i8]* %30, i64 %32
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [101 x i8], [101 x i8]* %33, i64 0, i64 %35
store i8 %29, i8* %36
br label %37
37: ; preds = %27, %24
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
%40 = call i32 (...) @getchar()
%41 = call i32 @toupper(i32 %40)
store i32 %41, i32* %4
br label %14
42: ; preds = %14
%43 = load i32, i32* %5
%44 = icmp sgt i32 %43, 100
br i1 %44, label %45, label %57
45: ; preds = %42
%46 = load [101 x i8]*, [101 x i8]** %3
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [101 x i8], [101 x i8]* %46, i64 %48
%50 = getelementptr inbounds [101 x i8], [101 x i8]* %49, i64 0, i64 100
store i8 0, i8* %50
%51 = load i32, i32* %7
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %45
%54 = load i32, i32* @stderr
%55 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([108 x i8], [108 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %7
br label %56
56: ; preds = %53, %45
br label %65
57: ; preds = %42
%58 = load [101 x i8]*, [101 x i8]** %3
%59 = load i32, i32* %6
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [101 x i8], [101 x i8]* %58, i64 %60
%62 = load i32, i32* %5
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [101 x i8], [101 x i8]* %61, i64 0, i64 %63
store i8 0, i8* %64
br label %65
65: ; preds = %57, %56
store i32 0, i32* %5
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
store i32 %67, i32* %6
br label %8
68: ; preds = %8
%69 = load i32, i32* %6
store i32 %69, i32* %2
br label %70
70: ; preds = %68, %23
%71 = load i32, i32* %2
ret i32 %71
}

LLVM IR (-O2):
@EOF = global i32 0
@stderr = global i32 0
@.str = [108 x i8] c"Warning: Some of city name is longer than 100 characters! Rest of characters in that name will be dropped!\0A\00"
define i32 @load_cities([101 x i8]* nocapture writeonly %0) {
%2 = tail call i32 (...) @getchar()
%3 = tail call i32 @toupper(i32 %2)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %48, label %6
6: ; preds = %1, %39
%7 = phi i64 [ %41, %39 ], [ 0, %1 ]
%8 = phi i32 [ %43, %39 ], [ %3, %1 ]
%9 = phi i32 [ %40, %39 ], [ 0, %1 ]
%10 = icmp eq i32 %8, 10
br i1 %10, label %35, label %11
11: ; preds = %6, %21
%12 = phi i64 [ %22, %21 ], [ 0, %6 ]
%13 = phi i32 [ %24, %21 ], [ %8, %6 ]
%14 = add i32 %13, -32
%15 = icmp ult i32 %14, 95
br i1 %15, label %16, label %48
16: ; preds = %11
%17 = icmp ult i64 %12, 100
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = trunc i32 %13 to i8
%20 = getelementptr inbounds [101 x i8], [101 x i8]* %0, i64 %7, i64 %12
store i8 %19, i8* %20
br label %21
21: ; preds = %18, %16
%22 = add nuw i64 %12, 1
%23 = tail call i32 (...) @getchar()
%24 = tail call i32 @toupper(i32 %23)
%25 = icmp eq i32 %24, 10
br i1 %25, label %26, label %11
26: ; preds = %21
%27 = trunc i64 %22 to i32
%28 = icmp ugt i32 %27, 100
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = getelementptr inbounds [101 x i8], [101 x i8]* %0, i64 %7, i64 100
store i8 0, i8* %30
%31 = icmp eq i32 %9, 0
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([108 x i8], [108 x i8]* @.str, i64 0, i64 0))
br label %39
35: ; preds = %6, %26
%36 = phi i64 [ %22, %26 ], [ 0, %6 ]
%37 = and i64 %36, 4294967295
%38 = getelementptr inbounds [101 x i8], [101 x i8]* %0, i64 %7, i64 %37
store i8 0, i8* %38
br label %39
39: ; preds = %29, %32, %35
%40 = phi i32 [ 1, %32 ], [ 1, %29 ], [ %9, %35 ]
%41 = add nuw i64 %7, 1
%42 = tail call i32 (...) @getchar()
%43 = tail call i32 @toupper(i32 %42)
%44 = load i32, i32* @EOF
%45 = icmp eq i32 %43, %44
br i1 %45, label %46, label %6
46: ; preds = %39
%47 = trunc i64 %41 to i32
br label %48
48: ; preds = %11, %46, %1
%49 = phi i32 [ 0, %1 ], [ %47, %46 ], [ -1, %11 ]
ret i32 %49
}