#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*/ temp;
struct node201 {
  int dummy;
};
struct node20 {
  int dummy;
};

/* Variables and functions */
struct node20 *add_list20(struct node20 *, struct node20 *, char *);
struct node201 *compare_list20(struct node20 *, struct node20 *,
                               struct node201 *, struct node201 *);
struct node20 *create_list20(struct node20 *, struct node20 *, char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ frequency20(struct node20 *, struct node20 *,
                               struct node201 *, struct node201 *);
struct node201 *getHighest20(struct node201 *, struct node201 *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
void Problem20() {
  struct node20 *head = NULL, *current;
  struct node201 *head1 = NULL, *current1;
  char string[1000], temp[1000] = "";
  int i, num;
  printf("Problem 20: Given a sequence of words, the program will sort and "
         "print the words with respect to frequency.\n");
  printf("Enter a series of words: ");
  fgets(string, 1000, stdin);
  string[strlen(string) - 1] = '\0';
  printf("The output is: ");
  for (i = 0; i < strlen(string); i++) {
    while (string[i] != ' ' && i < strlen(string)) {
      strncat(temp, &string[i], 1);
      i++;
    }
    if (head == NULL) {
      head = create_list20(head, current, temp);
      memset(temp, 0, sizeof(temp));
      continue;
    } else {
      head = add_list20(head, current, temp);
      memset(temp, 0, sizeof(temp));
    }
  }
  current = head;
  head1 = compare_list20(head, current, head1, current1);
  current1 = head1;
  frequency20(head, current, head1, current1);
  while (head1) {
    current1 = head1;
    head1 = getHighest20(current1, head1);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<Problem20>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x800(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1080 <memset@plt>
lea    0xe2b(%rip),%rdi
call   1060 <printf@plt>
lea    0xe8c(%rip),%rdi
call   1060 <printf@plt>
lea    -0x410(%rbp),%rdi
mov    0x2df4(%rip),%rax
mov    (%rax),%edx
mov    $0x3e8,%esi
call   10a0 <fgets@plt>
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x410(%rbp,%rax,1)
lea    0xe67(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x804(%rbp)
mov    -0x804(%rbp),%eax
mov    %eax,-0x80c(%rbp)
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x80c(%rbp),%eax
cmp    %ecx,%eax
jge    136f <Problem20+0x1cf>
jmp    125c <Problem20+0xbc>
movslq -0x804(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%ecx
ff
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x80d(%rbp)
je     12a7 <Problem20+0x107>
mov    -0x804(%rbp),%eax
mov    %eax,-0x814(%rbp)
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x814(%rbp),%eax
cmp    %ecx,%eax
setl   %al
mov    %al,-0x80d(%rbp)
mov    -0x80d(%rbp),%al
test   $0x1,%al
jne    12ba <Problem20+0x11a>
jmp    12f0 <Problem20+0x150>
lea    -0x800(%rbp),%rdi
movslq -0x804(%rbp),%rax
lea    -0x410(%rbp),%rsi
add    %rax,%rsi
mov    $0x1,%edx
call   1090 <strncat@plt>
mov    -0x804(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x804(%rbp)
jmp    125c <Problem20+0xbc>
cmpq   $0x0,-0x8(%rbp)
jne    132b <Problem20+0x18b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x800(%rbp),%rdx
call   1030 <create_list20@plt>
mov    %rax,-0x8(%rbp)
lea    -0x800(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1080 <memset@plt>
jmp    135b <Problem20+0x1bb>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x800(%rbp),%rdx
call   10c0 <add_list20@plt>
mov    %rax,-0x8(%rbp)
lea    -0x800(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1080 <memset@plt>
jmp    135b <Problem20+0x1bb>
mov    -0x804(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x804(%rbp)
jmp    122f <Problem20+0x8f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <compare_list20@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1070 <frequency20@plt>
cmpq   $0x0,-0x18(%rbp)
je     13d6 <Problem20+0x236>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10b0 <getHighest20@plt>
mov    %rax,-0x18(%rbp)
jmp    13ad <Problem20+0x20d>
lea    0xc8e(%rip),%rdi
call   1060 <printf@plt>
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Problem20>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7e0,%rsp
lea    0x3f0(%rsp),%rdi
xor    %r13d,%r13d
mov    $0x3e8,%edx
xor    %esi,%esi
call   10a0 <memset@plt>
lea    0xe3c(%rip),%rdi
call   1050 <puts@plt>
lea    0xe06(%rip),%rdi
call   1080 <printf@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x3e8,%esi
call   10c0 <fgets@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
lea    0xdeb(%rip),%rdi
call   1080 <printf@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
test   %eax,%eax
jle    12dc <Problem20+0x11c>
lea    0x3f0(%rsp),%r12
mov    %rsp,%r15
xor    %r14d,%r14d
jmp    1296 <Problem20+0xd6>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%r13
test   %r14,%r14
je     12d0 <Problem20+0x110>
mov    %r14,%rdi
mov    %r12,%rdx
call   10e0 <add_list20@plt>
mov    %rax,%r14
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   10a0 <memset@plt>
add    $0x1,%r13d
mov    %r15,%rdi
call   1070 <strlen@plt>
cmp    %eax,%r13d
jge    12df <Problem20+0x11f>
movslq %r13d,%rbx
cmpb   $0x20,(%rsp,%rbx,1)
je     1263 <Problem20+0xa3>
nop
mov    %r15,%rdi
call   1070 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1260 <Problem20+0xa0>
lea    (%rsp,%rbx,1),%rsi
mov    %r12,%rdi
mov    $0x1,%edx
call   10b0 <strncat@plt>
lea    0x1(%rbx),%r13
cmpb   $0x20,0x1(%rsp,%rbx,1)
mov    %r13,%rbx
jne    12a0 <Problem20+0xe0>
jmp    1263 <Problem20+0xa3>
xor    %edi,%edi
mov    %r12,%rdx
call   1030 <create_list20@plt>
jmp    1273 <Problem20+0xb3>
xor    %r14d,%r14d
mov    %r14,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1060 <compare_list20@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
mov    %rax,%rcx
call   1090 <frequency20@plt>
test   %rbx,%rbx
je     1323 <Problem20+0x163>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %rbx,%rsi
call   10d0 <getHighest20@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1310 <Problem20+0x150>
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x7e0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.node20 = type { i32 }
%struct.node201 = type { i32 }
@.str = [109 x i8] c"Problem 20: Given a sequence of words, the program will sort and print the words with respect to frequency.\0A\00"
@.str.1 = [26 x i8] c"Enter a series of words: \00"
@stdin = global i32 0
@.str.2 = [16 x i8] c"The output is: \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @Problem20() {
%1 = alloca %struct.node20*
%2 = alloca %struct.node20*
%3 = alloca %struct.node201*
%4 = alloca %struct.node201*
%5 = alloca [1000 x i8]
%6 = alloca [1000 x i8]
%7 = alloca i32
%8 = alloca i32
store %struct.node20* null, %struct.node20** %1
store %struct.node201* null, %struct.node201** %3
%9 = bitcast [1000 x i8]* %6 to i8*
%10 = call i32 @printf(i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %12, i32 1000, i32 %13)
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = sub nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 %18
store i8 0, i8* %19
%20 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %21
21: ; preds = %67, %0
%22 = load i32, i32* %7
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%24 = call i32 @strlen(i8* %23)
%25 = icmp slt i32 %22, %24
br i1 %25, label %26, label %70
26: ; preds = %21
br label %27
27: ; preds = %41, %26
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 32
br i1 %33, label %34, label %39
34: ; preds = %27
%35 = load i32, i32* %7
%36 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%37 = call i32 @strlen(i8* %36)
%38 = icmp slt i32 %35, %37
br label %39
39: ; preds = %34, %27
%40 = phi i1 [ false, %27 ], [ %38, %34 ]
br i1 %40, label %41, label %49
41: ; preds = %39
%42 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 %44
%46 = call i32 @strncat(i8* %42, i8* %45, i32 1)
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %27
49: ; preds = %39
%50 = load %struct.node20*, %struct.node20** %1
%51 = icmp eq %struct.node20* %50, null
br i1 %51, label %52, label %59
52: ; preds = %49
%53 = load %struct.node20*, %struct.node20** %1
%54 = load %struct.node20*, %struct.node20** %2
%55 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%56 = call %struct.node20* @create_list20(%struct.node20* %53, %struct.node20* %54, i8* %55)
store %struct.node20* %56, %struct.node20** %1
%57 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%58 = call i32 @memset(i8* %57, i32 0, i32 1000)
br label %67
59: ; preds = %49
%60 = load %struct.node20*, %struct.node20** %1
%61 = load %struct.node20*, %struct.node20** %2
%62 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%63 = call %struct.node20* @add_list20(%struct.node20* %60, %struct.node20* %61, i8* %62)
store %struct.node20* %63, %struct.node20** %1
%64 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%65 = call i32 @memset(i8* %64, i32 0, i32 1000)
br label %66
66: ; preds = %59
br label %67
67: ; preds = %66, %52
%68 = load i32, i32* %7
%69 = add nsw i32 %68, 1
store i32 %69, i32* %7
br label %21
70: ; preds = %21
%71 = load %struct.node20*, %struct.node20** %1
store %struct.node20* %71, %struct.node20** %2
%72 = load %struct.node20*, %struct.node20** %1
%73 = load %struct.node20*, %struct.node20** %2
%74 = load %struct.node201*, %struct.node201** %3
%75 = load %struct.node201*, %struct.node201** %4
%76 = call %struct.node201* @compare_list20(%struct.node20* %72, %struct.node20* %73, %struct.node201* %74, %struct.node201* %75)
store %struct.node201* %76, %struct.node201** %3
%77 = load %struct.node201*, %struct.node201** %3
store %struct.node201* %77, %struct.node201** %4
%78 = load %struct.node20*, %struct.node20** %1
%79 = load %struct.node20*, %struct.node20** %2
%80 = load %struct.node201*, %struct.node201** %3
%81 = load %struct.node201*, %struct.node201** %4
%82 = call i32 @frequency20(%struct.node20* %78, %struct.node20* %79, %struct.node201* %80, %struct.node201* %81)
br label %83
83: ; preds = %86, %70
%84 = load %struct.node201*, %struct.node201** %3
%85 = icmp ne %struct.node201* %84, null
br i1 %85, label %86, label %91
86: ; preds = %83
%87 = load %struct.node201*, %struct.node201** %3
store %struct.node201* %87, %struct.node201** %4
%88 = load %struct.node201*, %struct.node201** %4
%89 = load %struct.node201*, %struct.node201** %3
%90 = call %struct.node201* @getHighest20(%struct.node201* %88, %struct.node201* %89)
store %struct.node201* %90, %struct.node201** %3
br label %83
91: ; preds = %83
%92 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.node20 = type { i32 }
%struct.node201 = type { i32 }
@.str.1 = [26 x i8] c"Enter a series of words: \00"
@stdin = global i32 0
@.str.2 = [16 x i8] c"The output is: \00"
@str = [108 x i8] c"Problem 20: Given a sequence of words, the program will sort and print the words with respect to frequency.\00"
define void @Problem20() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([108 x i8], [108 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %3, i32 1000, i32 %7)
%9 = call i32 @strlen(i8* %3)
%10 = add nsw i32 %9, -1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %11
store i8 0, i8* %12
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @strlen(i8* %3)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %51
16: ; preds = %0, %45
%17 = phi %struct.node20* [ %46, %45 ], [ null, %0 ]
%18 = phi i32 [ %48, %45 ], [ 0, %0 ]
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 32
br i1 %22, label %38, label %23
23: ; preds = %16, %29
%24 = phi i64 [ %31, %29 ], [ %19, %16 ]
%25 = phi i8* [ %32, %29 ], [ %20, %16 ]
%26 = call i32 @strlen(i8* %3)
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %24, %27
br i1 %28, label %29, label %35
29: ; preds = %23
%30 = call i32 @strncat(i8* %4, i8* %25, i32 1)
%31 = add nsw i64 %24, 1
%32 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 32
br i1 %34, label %35, label %23
35: ; preds = %29, %23
%36 = phi i64 [ %24, %23 ], [ %31, %29 ]
%37 = trunc i64 %36 to i32
br label %38
38: ; preds = %35, %16
%39 = phi i32 [ %18, %16 ], [ %37, %35 ]
%40 = icmp eq %struct.node20* %17, null
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call %struct.node20* @create_list20(%struct.node20* null, %struct.node20* undef, i8* %4)
br label %45
43: ; preds = %38
%44 = call %struct.node20* @add_list20(%struct.node20* %17, %struct.node20* undef, i8* %4)
br label %45
45: ; preds = %43, %41
%46 = phi %struct.node20* [ %42, %41 ], [ %44, %43 ]
%47 = call i32 @memset(i8* %4, i32 0, i32 1000)
%48 = add nsw i32 %39, 1
%49 = call i32 @strlen(i8* %3)
%50 = icmp slt i32 %48, %49
br i1 %50, label %16, label %51
51: ; preds = %45, %0
%52 = phi %struct.node20* [ null, %0 ], [ %46, %45 ]
%53 = call %struct.node201* @compare_list20(%struct.node20* %52, %struct.node20* %52, %struct.node201* null, %struct.node201* undef)
%54 = call i32 @frequency20(%struct.node20* %52, %struct.node20* %52, %struct.node201* %53, %struct.node201* %53)
%55 = icmp eq %struct.node201* %53, null
br i1 %55, label %60, label %56
56: ; preds = %51, %56
%57 = phi %struct.node201* [ %58, %56 ], [ %53, %51 ]
%58 = call %struct.node201* @getHighest20(%struct.node201* %57, %struct.node201* %57)
%59 = icmp eq %struct.node201* %58, null
br i1 %59, label %60, label %56
60: ; preds = %56, %51
%61 = call i32 @putchar(i32 10)
ret void
}