#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*/ my_read_line(char *, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
char *strcpy(char *, char *);
int strlen(char *);
int main(void) {
  char smallest_word[20 + 1], largest_word[20 + 1];
  char word[20 + 1];
  printf("Enter word: ");
  my_read_line(word, 20);
  strcpy(smallest_word, strcpy(largest_word, word));
  while (strlen(word) != 4) {
    printf("Enter word: ");
    my_read_line(word, 20);
    if (strcmp(word, smallest_word) < 0)
      strcpy(smallest_word, word);
    if (strcmp(word, largest_word) > 0)
      strcpy(largest_word, word);
  }
  printf("\nSmallest word: %s\n", smallest_word);
  printf("Largest word: %s\n", largest_word);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    $0x14,%esi
call   1070 <my_read_line@plt>
lea    -0x20(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x68(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x4,%eax
je     1217 <main+0xc7>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    $0x14,%esi
call   1070 <my_read_line@plt>
lea    -0x60(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jge    11ee <main+0x9e>
lea    -0x20(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x60(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jle    1212 <main+0xc2>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    119c <main+0x4c>
lea    -0x20(%rbp),%rsi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1070 <my_read_line@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0x20(%rsp),%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x4,%eax
jne    11d5 <main+0x85>
lea    0xe63(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe64(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe24(%rip),%r14
lea    0x40(%rsp),%rbx
lea    0x20(%rsp),%r15
mov    %rsp,%r12
jmp    11fd <main+0xad>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x4,%eax
je     11a3 <main+0x53>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1070 <my_read_line@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jns    122f <main+0xdf>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jle    11f0 <main+0xa0>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
jmp    11f0 <main+0xa0>

LLVM IR (-O0):
@.str = [13 x i8] c"Enter word: \00"
@.str.1 = [20 x i8] c"\0ASmallest word: %s\0A\00"
@.str.2 = [18 x i8] c"Largest word: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [21 x i8]
%3 = alloca [21 x i8]
%4 = alloca [21 x i8]
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%7 = call i32 @my_read_line(i8* %6, i32 20)
%8 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%11 = call i8* @strcpy(i8* %9, i8* %10)
%12 = call i8* @strcpy(i8* %8, i8* %11)
br label %13
13: ; preds = %38, %0
%14 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = icmp ne i32 %15, 4
br i1 %16, label %17, label %39
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%19 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%20 = call i32 @my_read_line(i8* %19, i32 20)
%21 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%22 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%23 = call i64 @strcmp(i8* %21, i8* %22)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %17
%26 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%27 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%28 = call i8* @strcpy(i8* %26, i8* %27)
br label %29
29: ; preds = %25, %17
%30 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%31 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%32 = call i64 @strcmp(i8* %30, i8* %31)
%33 = icmp sgt i64 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%36 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%37 = call i8* @strcpy(i8* %35, i8* %36)
br label %38
38: ; preds = %34, %29
br label %13
39: ; preds = %13
%40 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %40)
%42 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %42)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"Enter word: \00"
@.str.1 = [20 x i8] c"\0ASmallest word: %s\0A\00"
@.str.2 = [18 x i8] c"Largest word: %s\0A\00"
define i32 @main() {
%1 = alloca [21 x i8]
%2 = alloca [21 x i8]
%3 = alloca [21 x i8]
%4 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @my_read_line(i8* %6, i32 20)
%9 = call i8* @strcpy(i8* %5, i8* %6)
%10 = call i8* @strcpy(i8* %4, i8* %5)
%11 = call i32 @strlen(i8* %6)
%12 = icmp eq i32 %11, 4
br i1 %12, label %28, label %13
13: ; preds = %0, %25
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @my_read_line(i8* %6, i32 20)
%16 = call i64 @strcmp(i8* %6, i8* %4)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i8* @strcpy(i8* %4, i8* %6)
br label %20
20: ; preds = %18, %13
%21 = call i64 @strcmp(i8* %6, i8* %5)
%22 = icmp sgt i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i8* @strcpy(i8* %5, i8* %6)
br label %25
25: ; preds = %23, %20
%26 = call i32 @strlen(i8* %6)
%27 = icmp eq i32 %26, 4
br i1 %27, label %28, label %13
28: ; preds = %25, %0
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %5)
ret i32 0
}