#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 /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
void *calloc(size_t, int);
int /*<<< orphan*/ check_intInput(int *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ free_array(char **, int);
char *line_reading(int);
int /*<<< orphan*/ print_array(char **, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
char *strerror(int /*<<< orphan*/);
size_t strlen(char *);
char *strtok(char *, char *);
int main() {
  printf("Enter number of city: ");
  int n;
  check_intInput(&n);
  char *line = NULL;
  char **cities = calloc(n, sizeof(char *));
  if (!cities) {
    fprintf(stderr, "%s", strerror(errno));
    exit(EXIT_FAILURE);
  }
  size_t lineLenght = 0;
  int i;
  for (i = 0; i < n; i++) {
    line = line_reading(50);
    char *token = strtok(line, " ");
    int ctrToken = 0;
    while (ctrToken <= i) {
      if (i == ctrToken) {
        lineLenght = strlen(token);
        cities[i] = calloc((lineLenght + 1), sizeof(char));
        if (!cities) {
          fprintf(stderr, "%s", strerror(errno));
          exit(EXIT_FAILURE);
        }
        strcpy(cities[i], token);
      }
      token = strtok(NULL, " ");
      ctrToken++;
    }
    free(line);
  }
  if (cities) {
    print_array(cities, n);
    free_array(cities, n);
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe1a(%rip),%rdi
call   1080 <printf@plt>
lea    -0x8(%rbp),%rdi
call   1040 <check_intInput@plt>
movq   $0x0,-0x10(%rbp)
movslq -0x8(%rbp),%rdi
mov    $0x8,%esi
call   10a0 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1253 <main+0x83>
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x38(%rbp),%edi
mov    %rax,%rdx
lea    0xdd7(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1370 <main+0x1a0>
mov    $0x32,%edi
call   10d0 <line_reading@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd8e(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     1359 <main+0x189>
mov    -0x24(%rbp),%eax
cmp    -0x34(%rbp),%eax
jne    1337 <main+0x167>
mov    -0x30(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
cmpq   $0x0,-0x18(%rbp)
jne    1322 <main+0x152>
mov    0x2cf1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    %rax,%rdx
lea    0xd08(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2cb5(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <strcpy@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xcd3(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1297 <main+0xc7>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1262 <main+0x92>
cmpq   $0x0,-0x18(%rbp)
je     1393 <main+0x1c3>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <print_array@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1090 <free_array@plt>
mov    0x2c2e(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe1b(%rip),%rdi
call   1080 <printf@plt>
lea    0xc(%rsp),%rdi
call   1040 <check_intInput@plt>
movslq 0xc(%rsp),%rdi
mov    $0x8,%esi
call   10a0 <calloc@plt>
test   %rax,%rax
je     12df <main+0x10f>
mov    %rax,%r14
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    12b3 <main+0xe3>
xor    %r15d,%r15d
lea    0xdf0(%rip),%r12
xor    %ebp,%ebp
jmp    124c <main+0x7c>
nopl   0x0(%rax)
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rsi
add    $0xffffffffffffffff,%r15
cmp    %rsi,%rbp
jge    12b3 <main+0xe3>
mov    $0x32,%edi
call   10d0 <line_reading@plt>
mov    %rax,0x10(%rsp)
mov    %rax,%rdi
mov    %r12,%rsi
call   10c0 <strtok@plt>
mov    %rax,%rbx
mov    %r15,%r13
jmp    1287 <main+0xb7>
xchg   %ax,%ax
xor    %edi,%edi
mov    %r12,%rsi
call   10c0 <strtok@plt>
mov    %rax,%rbx
add    $0x1,%r13
cmp    $0x1,%r13d
je     1230 <main+0x60>
test   %r13,%r13
jne    1270 <main+0xa0>
mov    %rbx,%rdi
call   1070 <strlen@plt>
lea    0x1(%rax),%rdi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,(%r14,%rbp,8)
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <strcpy@plt>
jmp    1270 <main+0xa0>
mov    %r14,%rdi
call   1060 <print_array@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
call   1090 <free_array@plt>
mov    0x2cfa(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cfa(%rip),%rax
mov    (%rax),%ebx
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xd1a(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   10b0 <fprintf@plt>
mov    0x2cc2(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Enter number of city: \00"
@stderr = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [2 x i8] c" \00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @check_intInput(i32* %2)
store i8* null, i8** %3
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = call i8* @calloc(i64 %12, i32 8)
%14 = bitcast i8* %13 to i8**
store i8** %14, i8*** %4
%15 = load i8**, i8*** %4
%16 = icmp ne i8** %15, null
br i1 %16, label %24, label %17
17: ; preds = %0
%18 = load i32, i32* @stderr
%19 = load i32, i32* @errno
%20 = call i8* @strerror(i32 %19)
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %0
store i64 0, i64* %5
store i32 0, i32* %6
br label %25
25: ; preds = %75, %24
%26 = load i32, i32* %6
%27 = load i32, i32* %2
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %78
29: ; preds = %25
%30 = call i8* @line_reading(i32 50)
store i8* %30, i8** %3
%31 = load i8*, i8** %3
%32 = call i8* @strtok(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %32, i8** %7
store i32 0, i32* %8
br label %33
33: ; preds = %68, %29
%34 = load i32, i32* %8
%35 = load i32, i32* %6
%36 = icmp sle i32 %34, %35
br i1 %36, label %37, label %72
37: ; preds = %33
%38 = load i32, i32* %6
%39 = load i32, i32* %8
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %68
41: ; preds = %37
%42 = load i8*, i8** %7
%43 = call i64 @strlen(i8* %42)
store i64 %43, i64* %5
%44 = load i64, i64* %5
%45 = add i64 %44, 1
%46 = call i8* @calloc(i64 %45, i32 1)
%47 = load i8**, i8*** %4
%48 = load i32, i32* %6
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
store i8* %46, i8** %50
%51 = load i8**, i8*** %4
%52 = icmp ne i8** %51, null
br i1 %52, label %60, label %53
53: ; preds = %41
%54 = load i32, i32* @stderr
%55 = load i32, i32* @errno
%56 = call i8* @strerror(i32 %55)
%57 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %56)
%58 = load i32, i32* @EXIT_FAILURE
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %41
%61 = load i8**, i8*** %4
%62 = load i32, i32* %6
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i8*, i8** %64
%66 = load i8*, i8** %7
%67 = call i32 @strcpy(i8* %65, i8* %66)
br label %68
68: ; preds = %60, %37
%69 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %69, i8** %7
%70 = load i32, i32* %8
%71 = add nsw i32 %70, 1
store i32 %71, i32* %8
br label %33
72: ; preds = %33
%73 = load i8*, i8** %3
%74 = call i32 @free(i8* %73)
br label %75
75: ; preds = %72
%76 = load i32, i32* %6
%77 = add nsw i32 %76, 1
store i32 %77, i32* %6
br label %25
78: ; preds = %25
%79 = load i8**, i8*** %4
%80 = icmp ne i8** %79, null
br i1 %80, label %81, label %88
81: ; preds = %78
%82 = load i8**, i8*** %4
%83 = load i32, i32* %2
%84 = call i32 @print_array(i8** %82, i32 %83)
%85 = load i8**, i8*** %4
%86 = load i32, i32* %2
%87 = call i32 @free_array(i8** %85, i32 %86)
br label %88
88: ; preds = %81, %78
%89 = load i32, i32* @EXIT_SUCCESS
ret i32 %89
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter number of city: \00"
@stderr = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [2 x i8] c" \00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%3 = bitcast i32* %1 to i8*
%4 = call i32 @check_intInput(i32* %1)
%5 = load i32, i32* %1
%6 = sext i32 %5 to i64
%7 = call i8* @calloc(i64 %6, i32 8)
%8 = bitcast i8* %7 to i8**
%9 = icmp eq i8* %7, null
br i1 %9, label %13, label %10
10: ; preds = %0
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %20, label %47
13: ; preds = %0
%14 = load i32, i32* @stderr
%15 = load i32, i32* @errno
%16 = call i8* @strerror(i32 %15)
%17 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %10, %40
%21 = phi i64 [ %42, %40 ], [ 0, %10 ]
%22 = phi i32 [ %46, %40 ], [ 1, %10 ]
%23 = call i8* @line_reading(i32 50)
%24 = call i8* @strtok(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = getelementptr inbounds i8*, i8** %8, i64 %21
br label %26
26: ; preds = %20, %36
%27 = phi i32 [ 0, %20 ], [ %38, %36 ]
%28 = phi i8* [ %24, %20 ], [ %37, %36 ]
%29 = zext i32 %27 to i64
%30 = icmp eq i64 %21, %29
br i1 %30, label %31, label %36
31: ; preds = %26
%32 = call i64 @strlen(i8* dereferenceable(1) %28)
%33 = add i64 %32, 1
%34 = call i8* @calloc(i64 %33, i32 1)
store i8* %34, i8** %25
%35 = call i32 @strcpy(i8* %34, i8* %28)
br label %36
36: ; preds = %31, %26
%37 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%38 = add nuw nsw i32 %27, 1
%39 = icmp eq i32 %38, %22
br i1 %39, label %40, label %26
40: ; preds = %36
%41 = call i32 @free(i8* %23)
%42 = add nuw nsw i64 %21, 1
%43 = load i32, i32* %1
%44 = sext i32 %43 to i64
%45 = icmp slt i64 %42, %44
%46 = add nuw i32 %22, 1
br i1 %45, label %20, label %47
47: ; preds = %40, %10
%48 = phi i32 [ %11, %10 ], [ %43, %40 ]
%49 = call i32 @print_array(i8** %8, i32 %48)
%50 = load i32, i32* %1
%51 = call i32 @free_array(i8** %8, i32 %50)
%52 = load i32, i32* @EXIT_SUCCESS
ret i32 %52
}