#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*/ printf(char *, ...);
int /*<<< orphan*/ read_line(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(void) {
  char reminder[50][81];
  char day_string[3];
  char msg_string[81];
  int day = 0;
  int reminders = 0;
  int i = 0;
  while (true) {
    if (reminders == 50) {
      printf("--- No space left ---\n");
      break;
    }
    printf("Enter a day, and a reminder: ");
    scanf("%2d", &day);
    if (day == 0) {
      break;
    }
    sprintf(day_string, "%2d", day);
    read_line(msg_string, 81);
    for (i = 0; i < reminders; i += 1) {
      if (strcmp(day_string, reminder[i]) < 0) {
        break;
      }
    }
    for (int j = reminders; j > i; j -= 1) {
      strcpy(reminder[j], reminder[j - 1]);
    }
    strcpy(reminder[i], day_string);
    strcat(reminder[i], msg_string);
    reminders += 1;
  }
  printf("\nDay Reminder\n");
  for (i = 0; i < reminders; i += 1) {
    printf(" %s\n", reminder[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1044(%rbp)
movl   $0x0,-0x1048(%rbp)
movl   $0x0,-0x104c(%rbp)
cmpl   $0x32,-0x1048(%rbp)
jne    11c0 <main+0x50>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    133d <main+0x1cd>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe60(%rip),%rdi
lea    -0x1044(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0x1044(%rbp)
jne    11f3 <main+0x83>
jmp    133d <main+0x1cd>
lea    -0xfe3(%rbp),%rdi
mov    -0x1044(%rbp),%edx
lea    0xe2e(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x1040(%rbp),%rdi
mov    $0x51,%esi
call   1070 <read_line@plt>
movl   $0x0,-0x104c(%rbp)
mov    -0x104c(%rbp),%eax
cmp    -0x1048(%rbp),%eax
jge    1282 <main+0x112>
lea    -0xfe3(%rbp),%rdi
movslq -0x104c(%rbp),%rax
lea    -0xfe0(%rbp),%rsi
imul   $0x51,%rax,%rax
add    %rax,%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jge    1269 <main+0xf9>
jmp    1282 <main+0x112>
jmp    126e <main+0xfe>
mov    -0x104c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104c(%rbp)
jmp    1227 <main+0xb7>
mov    -0x1048(%rbp),%eax
mov    %eax,-0x1050(%rbp)
mov    -0x1050(%rbp),%eax
cmp    -0x104c(%rbp),%eax
jle    12e7 <main+0x177>
movslq -0x1050(%rbp),%rax
lea    -0xfe0(%rbp),%rdi
imul   $0x51,%rax,%rax
add    %rax,%rdi
mov    -0x1050(%rbp),%eax
sub    $0x1,%eax
cltq
lea    -0xfe0(%rbp),%rsi
imul   $0x51,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x1050(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1050(%rbp)
jmp    128e <main+0x11e>
movslq -0x104c(%rbp),%rax
lea    -0xfe0(%rbp),%rdi
imul   $0x51,%rax,%rax
add    %rax,%rdi
lea    -0xfe3(%rbp),%rsi
call   1030 <strcpy@plt>
movslq -0x104c(%rbp),%rax
lea    -0xfe0(%rbp),%rdi
imul   $0x51,%rax,%rax
add    %rax,%rdi
lea    -0x1040(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x1048(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1048(%rbp)
jmp    11a0 <main+0x30>
lea    0xcf5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x104c(%rbp)
mov    -0x104c(%rbp),%eax
cmp    -0x1048(%rbp),%eax
jge    139e <main+0x22e>
movslq -0x104c(%rbp),%rax
lea    -0xfe0(%rbp),%rsi
imul   $0x51,%rax,%rax
add    %rax,%rsi
lea    0xcc5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x104c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104c(%rbp)
jmp    1355 <main+0x1e5>
xor    %eax,%eax
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1048,%rsp
movl   $0x0,0x8(%rsp)
lea    0x70(%rsp),%r14
lea    0xe79(%rip),%rbx
lea    0xd(%rsp),%r12
lea    0x10(%rsp),%rbp
xor    %r13d,%r13d
jmp    1209 <main+0x89>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%r15,%r15,8),%rax
lea    (%rax,%rax,8),%rax
lea    (%rsp,%rax,1),%rbp
add    $0x70,%rbp
mov    %rbp,%rdi
lea    0xd(%rsp),%r12
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
lea    0x10(%rsp),%rbp
mov    %rbp,%rsi
call   1090 <strcat@plt>
add    $0x1,%r13
add    $0x51,%r14
cmp    $0x32,%r13
lea    0xe1b(%rip),%rbx
je     12cd <main+0x14d>
lea    0xdf0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x8(%rsp),%edx
test   %edx,%edx
je     12ed <main+0x16d>
mov    %r12,%rdi
mov    %rbx,%rsi
call   10a0 <sprintf@plt>
mov    %rbp,%rdi
mov    $0x51,%esi
call   1080 <read_line@plt>
test   %r13,%r13
je     1290 <main+0x110>
lea    0x70(%rsp),%rbp
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    %rbp,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
js     1293 <main+0x113>
add    $0x1,%r15
add    $0x51,%rbp
cmp    %r15,%r13
jne    1260 <main+0xe0>
mov    %r13,%r15
jmp    1293 <main+0x113>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %r15d,%r15d
mov    %r15d,%r15d
cmp    %r15,%r13
jbe    11c0 <main+0x40>
movslq %r15d,%rbx
mov    %r14,%rdi
mov    %r13,%r12
nopl   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%r12
lea    -0x51(%rdi),%rbp
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
cmp    %rbx,%r12
jg     12b0 <main+0x130>
jmp    11c0 <main+0x40>
lea    0xd61(%rip),%rdi
call   1040 <puts@plt>
lea    0xd47(%rip),%rdi
call   1040 <puts@plt>
mov    $0x32,%r13d
jmp    12fe <main+0x17e>
lea    0xd33(%rip),%rdi
call   1040 <puts@plt>
test   %r13d,%r13d
je     1327 <main+0x1a7>
lea    0x70(%rsp),%rbx
lea    0xd18(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x51,%rbx
add    $0xffffffffffffffff,%r13
jne    1310 <main+0x190>
xor    %eax,%eax
add    $0x1048,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"--- No space left ---\0A\00"
@.str.1 = [30 x i8] c"Enter a day, and a reminder: \00"
@.str.2 = [4 x i8] c"%2d\00"
@.str.3 = [15 x i8] c"\0ADay Reminder\0A\00"
@.str.4 = [5 x i8] c" %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x [81 x i8]]
%3 = alloca [3 x i8]
%4 = alloca [81 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %0, %63
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, 50
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %78
14: ; preds = %9
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
br label %78
20: ; preds = %14
%21 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%22 = load i32, i32* %5
%23 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%25 = call i32 @read_line(i8* %24, i32 81)
store i32 0, i32* %7
br label %26
26: ; preds = %40, %20
%27 = load i32, i32* %7
%28 = load i32, i32* %6
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %43
30: ; preds = %26
%31 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [50 x [81 x i8]], [50 x [81 x i8]]* %2, i64 0, i64 %33
%35 = getelementptr inbounds [81 x i8], [81 x i8]* %34, i64 0, i64 0
%36 = call i64 @strcmp(i8* %31, i8* %35)
%37 = icmp slt i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %30
br label %43
39: ; preds = %30
br label %40
40: ; preds = %39
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %26
43: ; preds = %38, %26
%44 = load i32, i32* %6
store i32 %44, i32* %8
br label %45
45: ; preds = %60, %43
%46 = load i32, i32* %8
%47 = load i32, i32* %7
%48 = icmp sgt i32 %46, %47
br i1 %48, label %49, label %63
49: ; preds = %45
%50 = load i32, i32* %8
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [50 x [81 x i8]], [50 x [81 x i8]]* %2, i64 0, i64 %51
%53 = getelementptr inbounds [81 x i8], [81 x i8]* %52, i64 0, i64 0
%54 = load i32, i32* %8
%55 = sub nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [50 x [81 x i8]], [50 x [81 x i8]]* %2, i64 0, i64 %56
%58 = getelementptr inbounds [81 x i8], [81 x i8]* %57, i64 0, i64 0
%59 = call i32 @strcpy(i8* %53, i8* %58)
br label %60
60: ; preds = %49
%61 = load i32, i32* %8
%62 = sub nsw i32 %61, 1
store i32 %62, i32* %8
br label %45
63: ; preds = %45
%64 = load i32, i32* %7
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [50 x [81 x i8]], [50 x [81 x i8]]* %2, i64 0, i64 %65
%67 = getelementptr inbounds [81 x i8], [81 x i8]* %66, i64 0, i64 0
%68 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%69 = call i32 @strcpy(i8* %67, i8* %68)
%70 = load i32, i32* %7
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [50 x [81 x i8]], [50 x [81 x i8]]* %2, i64 0, i64 %71
%73 = getelementptr inbounds [81 x i8], [81 x i8]* %72, i64 0, i64 0
%74 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%75 = call i32 @strcat(i8* %73, i8* %74)
%76 = load i32, i32* %6
%77 = add nsw i32 %76, 1
store i32 %77, i32* %6
br label %9
78: ; preds = %19, %12
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
br label %80
80: ; preds = %90, %78
%81 = load i32, i32* %7
%82 = load i32, i32* %6
%83 = icmp slt i32 %81, %82
br i1 %83, label %84, label %93
84: ; preds = %80
%85 = load i32, i32* %7
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [50 x [81 x i8]], [50 x [81 x i8]]* %2, i64 0, i64 %86
%88 = getelementptr inbounds [81 x i8], [81 x i8]* %87, i64 0, i64 0
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %88)
br label %90
90: ; preds = %84
%91 = load i32, i32* %7
%92 = add nsw i32 %91, 1
store i32 %92, i32* %7
br label %80
93: ; preds = %80
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [30 x i8] c"Enter a day, and a reminder: \00"
@.str.2 = [4 x i8] c"%2d\00"
@.str.4 = [5 x i8] c" %s\0A\00"
@str = [14 x i8] c"\0ADay Reminder\00"
@str.5 = [22 x i8] c"--- No space left ---\00"
define i32 @main() {
%1 = alloca [50 x [81 x i8]]
%2 = alloca [3 x i8]
%3 = alloca [81 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [50 x [81 x i8]], [50 x [81 x i8]]* %1, i64 0, i64 0, i64 0
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
br label %12
9: ; preds = %39
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.5, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %56
12: ; preds = %0, %39
%13 = phi i64 [ 0, %0 ], [ %43, %39 ]
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 0
br i1 %17, label %52, label %18
18: ; preds = %12
%19 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%20 = call i32 @read_line(i8* %7, i32 81)
%21 = icmp eq i64 %13, 0
br i1 %21, label %33, label %22
22: ; preds = %18, %27
%23 = phi i64 [ %28, %27 ], [ 0, %18 ]
%24 = getelementptr inbounds [50 x [81 x i8]], [50 x [81 x i8]]* %1, i64 0, i64 %23, i64 0
%25 = call i64 @strcmp(i8* %6, i8* %24)
%26 = icmp slt i64 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %22
%28 = add nuw nsw i64 %23, 1
%29 = icmp eq i64 %28, %13
br i1 %29, label %30, label %22
30: ; preds = %22, %27
%31 = phi i64 [ %13, %27 ], [ %23, %22 ]
%32 = trunc i64 %31 to i32
br label %33
33: ; preds = %30, %18
%34 = phi i32 [ 0, %18 ], [ %32, %30 ]
%35 = zext i32 %34 to i64
%36 = icmp ugt i64 %13, %35
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = sext i32 %34 to i64
br label %45
39: ; preds = %45, %33
%40 = getelementptr inbounds [50 x [81 x i8]], [50 x [81 x i8]]* %1, i64 0, i64 %35, i64 0
%41 = call i32 @strcpy(i8* %40, i8* %6)
%42 = call i32 @strcat(i8* %40, i8* %7)
%43 = add nuw nsw i64 %13, 1
%44 = icmp eq i64 %43, 50
br i1 %44, label %9, label %12
45: ; preds = %37, %45
%46 = phi i64 [ %13, %37 ], [ %48, %45 ]
%47 = getelementptr inbounds [50 x [81 x i8]], [50 x [81 x i8]]* %1, i64 0, i64 %46, i64 0
%48 = add nsw i64 %46, -1
%49 = getelementptr inbounds [50 x [81 x i8]], [50 x [81 x i8]]* %1, i64 0, i64 %48, i64 0
%50 = call i32 @strcpy(i8* %47, i8* %49)
%51 = icmp sgt i64 %48, %38
br i1 %51, label %45, label %39
52: ; preds = %12
%53 = trunc i64 %13 to i32
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%55 = icmp eq i32 %53, 0
br i1 %55, label %65, label %56
56: ; preds = %9, %52
%57 = phi i64 [ 50, %9 ], [ %13, %52 ]
%58 = and i64 %57, 4294967295
br label %59
59: ; preds = %56, %59
%60 = phi i64 [ 0, %56 ], [ %63, %59 ]
%61 = getelementptr inbounds [50 x [81 x i8]], [50 x [81 x i8]]* %1, i64 0, i64 %60, i64 0
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %61)
%63 = add nuw nsw i64 %60, 1
%64 = icmp eq i64 %63, %58
br i1 %64, label %65, label %59
65: ; preds = %59, %52
ret i32 0
}