#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 reminders[50][60 + 3];
  char day_str[3], msg_str[60 + 1];
  int day, i, j, num_remind = 0;
  for (;;) {
    if (num_remind == 50) {
      printf("--No space left--\n");
      break;
    }
    printf("Enter day and reminder: ");
    scanf("%2d", &day);
    if (day == 0)
      break;
    sprintf(day_str, "%2d", day);
    read_line(msg_str, 60);
    for (i = 0; i < num_remind; i++)
      if (strcmp(day_str, reminders[i]) < 0)
        break;
    for (j = num_remind; j > i; j--)
      strcpy(reminders[j], reminders[j - 1]);
    strcpy(reminders[i], day_str);
    strcat(reminders[i], msg_str);
    num_remind++;
  }
  printf("\nDay Reminder\n");
  for (i = 0; i < num_remind; i++)
    printf(" %s\n", reminders[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xcb0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xcb0(%rbp)
cmpl   $0x32,-0xcb0(%rbp)
jne    11ac <main+0x3c>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1329 <main+0x1b9>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe6b(%rip),%rdi
lea    -0xca4(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0xca4(%rbp)
jne    11df <main+0x6f>
jmp    1329 <main+0x1b9>
lea    -0xc63(%rbp),%rdi
mov    -0xca4(%rbp),%edx
lea    0xe39(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0xca0(%rbp),%rdi
mov    $0x3c,%esi
call   1070 <read_line@plt>
movl   $0x0,-0xca8(%rbp)
mov    -0xca8(%rbp),%eax
cmp    -0xcb0(%rbp),%eax
jge    126e <main+0xfe>
lea    -0xc63(%rbp),%rdi
movslq -0xca8(%rbp),%rax
lea    -0xc60(%rbp),%rsi
imul   $0x3f,%rax,%rax
add    %rax,%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jge    1255 <main+0xe5>
jmp    126e <main+0xfe>
jmp    125a <main+0xea>
mov    -0xca8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xca8(%rbp)
jmp    1213 <main+0xa3>
mov    -0xcb0(%rbp),%eax
mov    %eax,-0xcac(%rbp)
mov    -0xcac(%rbp),%eax
cmp    -0xca8(%rbp),%eax
jle    12d3 <main+0x163>
movslq -0xcac(%rbp),%rax
lea    -0xc60(%rbp),%rdi
imul   $0x3f,%rax,%rax
add    %rax,%rdi
mov    -0xcac(%rbp),%eax
sub    $0x1,%eax
cltq
lea    -0xc60(%rbp),%rsi
imul   $0x3f,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0xcac(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xcac(%rbp)
jmp    127a <main+0x10a>
movslq -0xca8(%rbp),%rax
lea    -0xc60(%rbp),%rdi
imul   $0x3f,%rax,%rax
add    %rax,%rdi
lea    -0xc63(%rbp),%rsi
call   1030 <strcpy@plt>
movslq -0xca8(%rbp),%rax
lea    -0xc60(%rbp),%rdi
imul   $0x3f,%rax,%rax
add    %rax,%rdi
lea    -0xca0(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0xcb0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xcb0(%rbp)
jmp    118c <main+0x1c>
lea    0xd00(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xca8(%rbp)
mov    -0xca8(%rbp),%eax
cmp    -0xcb0(%rbp),%eax
jge    138a <main+0x21a>
movslq -0xca8(%rbp),%rax
lea    -0xc60(%rbp),%rsi
imul   $0x3f,%rax,%rax
add    %rax,%rsi
lea    0xcd0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xca8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xca8(%rbp)
jmp    1341 <main+0x1d1>
xor    %eax,%eax
add    $0xcb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xca8,%rsp
lea    0x50(%rsp),%r14
lea    0xe7c(%rip),%rbx
lea    0x9(%rsp),%r12
lea    0x10(%rsp),%rbp
xor    %r13d,%r13d
jmp    11fb <main+0x7b>
nopl   0x0(%rax)
mov    %r15,%rax
shl    $0x6,%rax
sub    %r15,%rax
lea    (%rsp,%rax,1),%rbp
add    $0x50,%rbp
mov    %rbp,%rdi
lea    0x9(%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    $0x3f,%r14
cmp    $0x32,%r13
lea    0xe24(%rip),%rbx
je     12bd <main+0x13d>
lea    0xdfe(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%edx
test   %edx,%edx
je     12dd <main+0x15d>
mov    %r12,%rdi
mov    %rbx,%rsi
call   10a0 <sprintf@plt>
mov    %rbp,%rdi
mov    $0x3c,%esi
call   1080 <read_line@plt>
test   %r13,%r13
je     1280 <main+0x100>
lea    0x50(%rsp),%rbp
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbp,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
js     1283 <main+0x103>
add    $0x1,%r15
add    $0x3f,%rbp
cmp    %r15,%r13
jne    1250 <main+0xd0>
mov    %r13,%r15
jmp    1283 <main+0x103>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %r15d,%r15d
mov    %r15d,%r15d
cmp    %r15,%r13
jbe    11b0 <main+0x30>
movslq %r15d,%rbx
mov    %r14,%rdi
mov    %r13,%r12
nopl   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%r12
lea    -0x3f(%rdi),%rbp
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
cmp    %rbx,%r12
jg     12a0 <main+0x120>
jmp    11b0 <main+0x30>
lea    0xd6c(%rip),%rdi
call   1040 <puts@plt>
lea    0xd52(%rip),%rdi
call   1040 <puts@plt>
mov    $0x32,%r13d
jmp    12ee <main+0x16e>
lea    0xd3e(%rip),%rdi
call   1040 <puts@plt>
test   %r13d,%r13d
je     1317 <main+0x197>
lea    0x50(%rsp),%rbx
lea    0xd23(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x3f,%rbx
add    $0xffffffffffffffff,%r13
jne    1300 <main+0x180>
xor    %eax,%eax
add    $0xca8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"--No space left--\0A\00"
@.str.1 = [25 x i8] c"Enter day and 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 [63 x i8]]
%3 = alloca [3 x i8]
%4 = alloca [61 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %8
br label %9
9: ; preds = %63, %0
%10 = load i32, i32* %8
%11 = icmp eq i32 %10, 50
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %78
14: ; preds = %9
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 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 [61 x i8], [61 x i8]* %4, i64 0, i64 0
%25 = call i32 @read_line(i8* %24, i32 60)
store i32 0, i32* %6
br label %26
26: ; preds = %40, %20
%27 = load i32, i32* %6
%28 = load i32, i32* %8
%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* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [50 x [63 x i8]], [50 x [63 x i8]]* %2, i64 0, i64 %33
%35 = getelementptr inbounds [63 x i8], [63 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* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %26
43: ; preds = %38, %26
%44 = load i32, i32* %8
store i32 %44, i32* %7
br label %45
45: ; preds = %60, %43
%46 = load i32, i32* %7
%47 = load i32, i32* %6
%48 = icmp sgt i32 %46, %47
br i1 %48, label %49, label %63
49: ; preds = %45
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [50 x [63 x i8]], [50 x [63 x i8]]* %2, i64 0, i64 %51
%53 = getelementptr inbounds [63 x i8], [63 x i8]* %52, i64 0, i64 0
%54 = load i32, i32* %7
%55 = sub nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [50 x [63 x i8]], [50 x [63 x i8]]* %2, i64 0, i64 %56
%58 = getelementptr inbounds [63 x i8], [63 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* %7
%62 = add nsw i32 %61, -1
store i32 %62, i32* %7
br label %45
63: ; preds = %45
%64 = load i32, i32* %6
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [50 x [63 x i8]], [50 x [63 x i8]]* %2, i64 0, i64 %65
%67 = getelementptr inbounds [63 x i8], [63 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* %6
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [50 x [63 x i8]], [50 x [63 x i8]]* %2, i64 0, i64 %71
%73 = getelementptr inbounds [63 x i8], [63 x i8]* %72, i64 0, i64 0
%74 = getelementptr inbounds [61 x i8], [61 x i8]* %4, i64 0, i64 0
%75 = call i32 @strcat(i8* %73, i8* %74)
%76 = load i32, i32* %8
%77 = add nsw i32 %76, 1
store i32 %77, i32* %8
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* %6
br label %80
80: ; preds = %90, %78
%81 = load i32, i32* %6
%82 = load i32, i32* %8
%83 = icmp slt i32 %81, %82
br i1 %83, label %84, label %93
84: ; preds = %80
%85 = load i32, i32* %6
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [50 x [63 x i8]], [50 x [63 x i8]]* %2, i64 0, i64 %86
%88 = getelementptr inbounds [63 x i8], [63 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* %6
%92 = add nsw i32 %91, 1
store i32 %92, i32* %6
br label %80
93: ; preds = %80
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [25 x i8] c"Enter day and 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 = [18 x i8] c"--No space left--\00"
define i32 @main() {
%1 = alloca [50 x [63 x i8]]
%2 = alloca [3 x i8]
%3 = alloca [61 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [50 x [63 x i8]], [50 x [63 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 [61 x i8], [61 x i8]* %3, i64 0, i64 0
%8 = bitcast i32* %4 to i8*
br label %12
9: ; preds = %46
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 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, %46
%13 = phi i64 [ 0, %0 ], [ %50, %46 ]
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 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 60)
%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 [63 x i8]], [50 x [63 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 %46
37: ; preds = %33
%38 = sext i32 %34 to i64
br label %39
39: ; preds = %37, %39
%40 = phi i64 [ %13, %37 ], [ %42, %39 ]
%41 = getelementptr inbounds [50 x [63 x i8]], [50 x [63 x i8]]* %1, i64 0, i64 %40, i64 0
%42 = add nsw i64 %40, -1
%43 = getelementptr inbounds [50 x [63 x i8]], [50 x [63 x i8]]* %1, i64 0, i64 %42, i64 0
%44 = call i32 @strcpy(i8* %41, i8* %43)
%45 = icmp sgt i64 %42, %38
br i1 %45, label %39, label %46
46: ; preds = %39, %33
%47 = getelementptr inbounds [50 x [63 x i8]], [50 x [63 x i8]]* %1, i64 0, i64 %35, i64 0
%48 = call i32 @strcpy(i8* %47, i8* %6)
%49 = call i32 @strcat(i8* %47, i8* %7)
%50 = add nuw nsw i64 %13, 1
%51 = icmp eq i64 %50, 50
br i1 %51, label %9, label %12
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 [63 x i8]], [50 x [63 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
}