#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 get_mday_today();
int /*<<< orphan*/ load_aphorisms(char *, char **);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  char *sayings[31];
  if (argc > 1) {
    load_aphorisms(argv[1], sayings);
  } else {
    load_aphorisms("/usr/local/share/games/zen-thought/jotaiga-aphorisms.txt",
                   sayings);
  }
  int i, today = get_mday_today() - 1;
  for (i = 0; i < strlen(sayings[today]); i++) {
    if (sayings[today][i] == '|') {
      sayings[today][i] = '\n';
    }
  }
  printf("\n%s\n\n", sayings[today]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    117c <main+0x3c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x110(%rbp),%rsi
call   1060 <load_aphorisms@plt>
jmp    118f <main+0x4f>
lea    -0x110(%rbp),%rsi
lea    0xe76(%rip),%rdi
call   1060 <load_aphorisms@plt>
mov    $0x0,%al
call   1050 <get_mday_today@plt>
sub    $0x1,%eax
mov    %eax,-0x118(%rbp)
movl   $0x0,-0x114(%rbp)
mov    -0x114(%rbp),%eax
mov    %eax,-0x11c(%rbp)
movslq -0x118(%rbp),%rax
mov    -0x110(%rbp,%rax,8),%rdi
ff
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x11c(%rbp),%eax
cmp    %ecx,%eax
jge    122f <main+0xef>
movslq -0x118(%rbp),%rax
mov    -0x110(%rbp,%rax,8),%rax
ff
movslq -0x114(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7c,%eax
jne    1216 <main+0xd6>
movslq -0x118(%rbp),%rax
mov    -0x110(%rbp,%rax,8),%rax
ff
movslq -0x114(%rbp),%rcx
movb   $0xa,(%rax,%rcx,1)
jmp    121b <main+0xdb>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    11a9 <main+0x69>
movslq -0x118(%rbp),%rax
mov    -0x110(%rbp,%rax,8),%rsi
ff
lea    0xdf4(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xf8,%rsp
cmp    $0x2,%edi
jl     1155 <main+0x15>
mov    0x8(%rsi),%rdi
jmp    115c <main+0x1c>
lea    0xea4(%rip),%rdi
mov    %rsp,%rsi
call   1060 <load_aphorisms@plt>
xor    %eax,%eax
call   1050 <get_mday_today@plt>
movslq %eax,%r14
mov    -0x8(%rsp,%r14,8),%rdi
add    $0xffffffffffffffff,%r14
call   1030 <strlen@plt>
test   %eax,%eax
jle    11b4 <main+0x74>
xor    %ebx,%ebx
jmp    11a0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11b4 <main+0x74>
mov    (%rsp,%r14,8),%rdi
cmpb   $0x7c,(%rdi,%rbx,1)
jne    1190 <main+0x50>
movb   $0xa,(%rdi,%rbx,1)
mov    (%rsp,%r14,8),%rdi
jmp    1190 <main+0x50>
mov    (%rsp,%r14,8),%rsi
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [57 x i8] c"/usr/local/share/games/zen-thought/jotaiga-aphorisms.txt\00"
@.str.1 = [6 x i8] c"\0A%s\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [31 x i8*]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = getelementptr inbounds [31 x i8*], [31 x i8*]* %6, i64 0, i64 0
%16 = call i32 @load_aphorisms(i8* %14, i8** %15)
br label %20
17: ; preds = %2
%18 = getelementptr inbounds [31 x i8*], [31 x i8*]* %6, i64 0, i64 0
%19 = call i32 @load_aphorisms(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8** %18)
br label %20
20: ; preds = %17, %11
%21 = call i32 (...) @get_mday_today()
%22 = sub nsw i32 %21, 1
store i32 %22, i32* %8
store i32 0, i32* %7
br label %23
23: ; preds = %51, %20
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [31 x i8*], [31 x i8*]* %6, i64 0, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 @strlen(i8* %28)
%30 = icmp slt i32 %24, %29
br i1 %30, label %31, label %54
31: ; preds = %23
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [31 x i8*], [31 x i8*]* %6, i64 0, i64 %33
%35 = load i8*, i8** %34
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 124
br i1 %41, label %42, label %50
42: ; preds = %31
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [31 x i8*], [31 x i8*]* %6, i64 0, i64 %44
%46 = load i8*, i8** %45
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
store i8 10, i8* %49
br label %50
50: ; preds = %42, %31
br label %51
51: ; preds = %50
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %23
54: ; preds = %23
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [31 x i8*], [31 x i8*]* %6, i64 0, i64 %56
%58 = load i8*, i8** %57
%59 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %58)
ret i32 0
}

LLVM IR (-O2):
@.str = [57 x i8] c"/usr/local/share/games/zen-thought/jotaiga-aphorisms.txt\00"
@.str.1 = [6 x i8] c"\0A%s\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [31 x i8*]
%4 = bitcast [31 x i8*]* %3 to i8*
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
br label %9
9: ; preds = %2, %6
%10 = phi i8* [ %8, %6 ], [ getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), %2 ]
%11 = getelementptr inbounds [31 x i8*], [31 x i8*]* %3, i64 0, i64 0
%12 = call i32 @load_aphorisms(i8* %10, i8** %11)
%13 = call i32 (...) @get_mday_today()
%14 = add nsw i32 %13, -1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [31 x i8*], [31 x i8*]* %3, i64 0, i64 %15
%17 = load i8*, i8** %16
%18 = call i32 @strlen(i8* %17)
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %34
20: ; preds = %9, %28
%21 = phi i64 [ %30, %28 ], [ 0, %9 ]
%22 = load i8*, i8** %16
%23 = getelementptr inbounds i8, i8* %22, i64 %21
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 124
br i1 %25, label %26, label %28
26: ; preds = %20
store i8 10, i8* %23
%27 = load i8*, i8** %16
br label %28
28: ; preds = %20, %26
%29 = phi i8* [ %22, %20 ], [ %27, %26 ]
%30 = add nuw nsw i64 %21, 1
%31 = call i32 @strlen(i8* %29)
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
br i1 %33, label %20, label %34
34: ; preds = %28, %9
%35 = load i8*, i8** %16
%36 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %35)
ret i32 0
}