#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*/ time_t;
typedef int /*<<< orphan*/ tc;
struct tm {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int getchar();
char *getenv(char *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printUsage(char *);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  if ((argc >= 2 &&
       (strcmp("-h", argv[1]) == 0 || strcmp("--help", argv[1]) == 0)) ||
      argc == 1) {
    printUsage(argv[0]);
    return 0;
  }
  char *nh = getenv("NOTES_HOME");
  FILE *fp;
  if (nh == NULL) {
    fprintf(stderr,
            "%s environment variable is not set\nSending output to stdout.\n\n",
            "NOTES_HOME");
    fp = stdout;
  } else {
    fp = fopen(nh, "a");
  }
  int c, i = 0;
  time_t t = time(NULL);
  struct tm *z = localtime(&t);
  char tc[81];
  fprintf(fp, "==============================\n");
  strftime(tc, sizeof(tc), "%a-%x-%H:%M:%S%n", z);
  fprintf(fp, "%s", tc);
  if (argc >= 2 && strcmp("-", argv[1]) != 0) {
    while ((c = (char)argv[1][i++]) != 0) {
      fprintf(fp, "%c", c);
    }
    if (argc >= 3) {
      fprintf(fp, "\nt=");
      int argi;
      for (argi = 2; argi < argc; ++argi) {
        i = 0;
        fprintf(fp, argi == 2 ? "" : "~");
        while ((c = (char)argv[argi][i++]) != 0) {
          fprintf(fp, "%c", c);
        }
      }
    }
    fprintf(fp, "\n%s\n\n\n", "==============================");
    fclose(fp);
  } else {
    if (strcmp("-", argv[1]) == 0) {
      fprintf(stderr, "Go ahead and type your note. Ctrl+d will end input.\n");
      while ((c = getchar()) != EOF) {
        fprintf(fp, "%c", c);
      }
      fprintf(fp, "\n%s\n", "==============================");
      fclose(fp);
    } else
      printUsage(argv[0]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     11ff <main+0x5f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe2e(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1209 <main+0x69>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe13(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1209 <main+0x69>
cmpl   $0x1,-0x8(%rbp)
jne    1221 <main+0x81>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <printUsage@plt>
movl   $0x0,-0x4(%rbp)
jmp    14ec <main+0x34c>
lea    0xde2(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    126e <main+0xce>
mov    0x2d95(%rip),%rax
mov    (%rax),%rdi
lea    0xdc8(%rip),%rsi
lea    0xdb6(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1282 <main+0xe2>
mov    -0x18(%rbp),%rdi
lea    0xddb(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x2c(%rbp),%rdi
call   1040 <localtime@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xda9(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
lea    -0x90(%rbp),%rdi
mov    -0x38(%rbp),%rcx
mov    $0x51,%esi
lea    0xdab(%rip),%rdx
call   10a0 <strftime@plt>
mov    -0x20(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xda5(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
cmpl   $0x2,-0x8(%rbp)
jl     1444 <main+0x2a4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd88(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1444 <main+0x2a4>
jmp    1316 <main+0x176>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x28(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
je     1356 <main+0x1b6>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xd42(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1316 <main+0x176>
cmpl   $0x3,-0x8(%rbp)
jl     141d <main+0x27d>
mov    -0x20(%rbp),%rdi
lea    0xd24(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x2,-0x94(%rbp)
mov    -0x94(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1418 <main+0x278>
movl   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x94(%rbp),%ecx
lea    0xcf0(%rip),%rsi
lea    0xcf1(%rip),%rax
cmp    $0x2,%ecx
cmove  %rax,%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
movslq -0x94(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x28(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
je     13ff <main+0x25f>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xc99(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    13b8 <main+0x218>
jmp    1404 <main+0x264>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    137c <main+0x1dc>
jmp    141d <main+0x27d>
mov    -0x20(%rbp),%rdi
lea    0xc6d(%rip),%rsi
lea    0xc6d(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
jmp    14e5 <main+0x345>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xc37(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    14d4 <main+0x334>
mov    0x2b6f(%rip),%rax
mov    (%rax),%rdi
lea    0xc48(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %eax,-0x24(%rbp)
mov    0x2b5d(%rip),%rcx
cmp    (%rcx),%eax
je     14ad <main+0x30d>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xbeb(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    147a <main+0x2da>
mov    -0x20(%rbp),%rdi
lea    0xc38(%rip),%rsi
lea    0xbdd(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
jmp    14e0 <main+0x340>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <printUsage@plt>
jmp    14e5 <main+0x345>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbx
mov    %edi,%r15d
cmp    $0x2,%edi
jl     121c <main+0x4c>
mov    0x8(%rbx),%rsi
lea    0xe0c(%rip),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13c3 <main+0x1f3>
mov    0x8(%rbx),%rsi
lea    0xdf6(%rip),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1226 <main+0x56>
jmp    13c3 <main+0x1f3>
cmp    $0x1,%r15d
je     13c3 <main+0x1f3>
lea    0xddd(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     124b <main+0x7b>
lea    0xe16(%rip),%rsi
mov    %rax,%rdi
call   10e0 <fopen@plt>
mov    %rax,%r14
jmp    1274 <main+0xa4>
mov    0x2d86(%rip),%rax
mov    (%rax),%rdi
lea    0xdb9(%rip),%rsi
lea    0xda7(%rip),%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%r14
xor    %edi,%edi
call   10b0 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1040 <localtime@plt>
mov    %rax,%rbp
lea    0xdc3(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10f0 <fwrite@plt>
lea    0xdca(%rip),%rdx
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x51,%esi
mov    %rbp,%rcx
call   10c0 <strftime@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1060 <fputs@plt>
cmp    $0x2,%r15d
jl     13ae <main+0x1de>
mov    0x8(%rbx),%rsi
lea    0xda6(%rip),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13ae <main+0x1de>
mov    0x8(%rbx),%rax
mov    (%rax),%al
test   %al,%al
je     131b <main+0x14b>
mov    $0x1,%ebp
xchg   %ax,%ax
movsbl %al,%edi
mov    %r14,%rsi
call   1070 <fputc@plt>
mov    0x8(%rbx),%rax
movzbl (%rax,%rbp,1),%eax
add    $0x1,%rbp
test   %al,%al
jne    1300 <main+0x130>
cmp    $0x3,%r15d
jl     13cd <main+0x1fd>
lea    0xd5d(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10f0 <fwrite@plt>
mov    %r15d,%r15d
mov    $0x2,%ebp
lea    0xd40(%rip),%r13
jmp    1359 <main+0x189>
nop
add    $0x1,%rbp
cmp    %r15,%rbp
je     13cd <main+0x1fd>
cmp    $0x2,%rbp
mov    %r13,%rsi
lea    0xd2e(%rip),%rax
cmove  %rax,%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx,%rbp,8),%rax
mov    (%rax),%al
test   %al,%al
je     1350 <main+0x180>
mov    $0x1,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
mov    %r14,%rsi
call   1070 <fputc@plt>
mov    (%rbx,%rbp,8),%rax
movzbl (%rax,%r12,1),%eax
add    $0x1,%r12
test   %al,%al
jne    1390 <main+0x1c0>
jmp    1350 <main+0x180>
mov    0x8(%rbx),%rsi
lea    0xcce(%rip),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13d6 <main+0x206>
mov    (%rbx),%rdi
call   10d0 <printUsage@plt>
jmp    1445 <main+0x275>
lea    0xcbb(%rip),%rsi
jmp    142c <main+0x25c>
mov    0x2bfb(%rip),%rax
mov    (%rax),%rcx
lea    0xcce(%rip),%rdi
mov    $0x34,%esi
mov    $0x1,%edx
call   10f0 <fwrite@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
mov    0x2be4(%rip),%rbx
cmp    (%rbx),%eax
je     1425 <main+0x255>
nopl   0x0(%rax,%rax,1)
mov    %eax,%edi
mov    %r14,%rsi
call   1070 <fputc@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
cmp    (%rbx),%eax
jne    1410 <main+0x240>
lea    0xcbe(%rip),%rsi
lea    0xc63(%rip),%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [11 x i8] c"NOTES_HOME\00"
@stderr = global i32* null
@.str.3 = [63 x i8] c"%s environment variable is not set\0ASending output to stdout.\0A\0A\00"
@stdout = global i32* null
@.str.4 = [2 x i8] c"a\00"
@.str.5 = [32 x i8] c"==============================\0A\00"
@.str.6 = [17 x i8] c"%a-%x-%H:%M:%S%n\00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [2 x i8] c"-\00"
@.str.9 = [3 x i8] c"%c\00"
@.str.10 = [4 x i8] c"\0At=\00"
@.str.11 = [1 x i8] zeroinitializer
@.str.12 = [2 x i8] c"~\00"
@.str.13 = [7 x i8] c"\0A%s\0A\0A\0A\00"
@.str.14 = [31 x i8] c"==============================\00"
@.str.15 = [53 x i8] c"Go ahead and type your note. Ctrl+d will end input.\0A\00"
@EOF = global i32 0
@.str.16 = [5 x i8] c"\0A%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.tm*
%12 = alloca [81 x i8]
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp sge i32 %14, 2
br i1 %15, label %16, label %28
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %31, label %22
22: ; preds = %16
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %22, %2
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %36
31: ; preds = %28, %22, %16
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i32 @printUsage(i8* %34)
store i32 0, i32* %3
br label %155
36: ; preds = %28
%37 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i8* %37, i8** %6
%38 = load i8*, i8** %6
%39 = icmp eq i8* %38, null
br i1 %39, label %40, label %44
40: ; preds = %36
%41 = load i32*, i32** @stderr
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%43 = load i32*, i32** @stdout
store i32* %43, i32** %7
br label %47
44: ; preds = %36
%45 = load i8*, i8** %6
%46 = call i32* @fopen(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %46, i32** %7
br label %47
47: ; preds = %44, %40
store i32 0, i32* %9
%48 = call i32 @time(i32* null)
store i32 %48, i32* %10
%49 = call %struct.tm* @localtime(i32* %10)
store %struct.tm* %49, %struct.tm** %11
%50 = load i32*, i32** %7
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%52 = getelementptr inbounds [81 x i8], [81 x i8]* %12, i64 0, i64 0
%53 = load %struct.tm*, %struct.tm** %11
%54 = call i32 @strftime(i8* %52, i32 81, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), %struct.tm* %53)
%55 = load i32*, i32** %7
%56 = getelementptr inbounds [81 x i8], [81 x i8]* %12, i64 0, i64 0
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %56)
%58 = load i32, i32* %4
%59 = icmp sge i32 %58, 2
br i1 %59, label %60, label %126
60: ; preds = %47
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 1
%63 = load i8*, i8** %62
%64 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* %63)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %126
66: ; preds = %60
br label %67
67: ; preds = %78, %66
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 1
%70 = load i8*, i8** %69
%71 = load i32, i32* %9
%72 = add nsw i32 %71, 1
store i32 %72, i32* %9
%73 = sext i32 %71 to i64
%74 = getelementptr inbounds i8, i8* %70, i64 %73
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
store i32 %76, i32* %8
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %82
78: ; preds = %67
%79 = load i32*, i32** %7
%80 = load i32, i32* %8
%81 = call i32 (i32*, i8*, ...) @fprintf(i32* %79, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %80)
br label %67
82: ; preds = %67
%83 = load i32, i32* %4
%84 = icmp sge i32 %83, 3
br i1 %84, label %85, label %121
85: ; preds = %82
%86 = load i32*, i32** %7
%87 = call i32 (i32*, i8*, ...) @fprintf(i32* %86, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
store i32 2, i32* %13
br label %88
88: ; preds = %117, %85
%89 = load i32, i32* %13
%90 = load i32, i32* %4
%91 = icmp slt i32 %89, %90
br i1 %91, label %92, label %120
92: ; preds = %88
store i32 0, i32* %9
%93 = load i32*, i32** %7
%94 = load i32, i32* %13
%95 = icmp eq i32 %94, 2
%96 = zext i1 %95 to i64
%97 = select i1 %95, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0)
%98 = call i32 (i32*, i8*, ...) @fprintf(i32* %93, i8* %97)
br label %99
99: ; preds = %112, %92
%100 = load i8**, i8*** %5
%101 = load i32, i32* %13
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i8*, i8** %100, i64 %102
%104 = load i8*, i8** %103
%105 = load i32, i32* %9
%106 = add nsw i32 %105, 1
store i32 %106, i32* %9
%107 = sext i32 %105 to i64
%108 = getelementptr inbounds i8, i8* %104, i64 %107
%109 = load i8, i8* %108
%110 = sext i8 %109 to i32
store i32 %110, i32* %8
%111 = icmp ne i32 %110, 0
br i1 %111, label %112, label %116
112: ; preds = %99
%113 = load i32*, i32** %7
%114 = load i32, i32* %8
%115 = call i32 (i32*, i8*, ...) @fprintf(i32* %113, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %114)
br label %99
116: ; preds = %99
br label %117
117: ; preds = %116
%118 = load i32, i32* %13
%119 = add nsw i32 %118, 1
store i32 %119, i32* %13
br label %88
120: ; preds = %88
br label %121
121: ; preds = %120, %82
%122 = load i32*, i32** %7
%123 = call i32 (i32*, i8*, ...) @fprintf(i32* %122, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0))
%124 = load i32*, i32** %7
%125 = call i32 @fclose(i32* %124)
br label %154
126: ; preds = %60, %47
%127 = load i8**, i8*** %5
%128 = getelementptr inbounds i8*, i8** %127, i64 1
%129 = load i8*, i8** %128
%130 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* %129)
%131 = icmp eq i64 %130, 0
br i1 %131, label %132, label %148
132: ; preds = %126
%133 = load i32*, i32** @stderr
%134 = call i32 (i32*, i8*, ...) @fprintf(i32* %133, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.15, i64 0, i64 0))
br label %135
135: ; preds = %139, %132
%136 = call i32 (...) @getchar()
store i32 %136, i32* %8
%137 = load i32, i32* @EOF
%138 = icmp ne i32 %136, %137
br i1 %138, label %139, label %143
139: ; preds = %135
%140 = load i32*, i32** %7
%141 = load i32, i32* %8
%142 = call i32 (i32*, i8*, ...) @fprintf(i32* %140, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %141)
br label %135
143: ; preds = %135
%144 = load i32*, i32** %7
%145 = call i32 (i32*, i8*, ...) @fprintf(i32* %144, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0))
%146 = load i32*, i32** %7
%147 = call i32 @fclose(i32* %146)
br label %153
148: ; preds = %126
%149 = load i8**, i8*** %5
%150 = getelementptr inbounds i8*, i8** %149, i64 0
%151 = load i8*, i8** %150
%152 = call i32 @printUsage(i8* %151)
br label %153
153: ; preds = %148, %143
br label %154
154: ; preds = %153, %121
store i32 0, i32* %3
br label %155
155: ; preds = %154, %31
%156 = load i32, i32* %3
ret i32 %156
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [11 x i8] c"NOTES_HOME\00"
@stderr = global i32* null
@.str.3 = [63 x i8] c"%s environment variable is not set\0ASending output to stdout.\0A\0A\00"
@stdout = global i32* null
@.str.4 = [2 x i8] c"a\00"
@.str.5 = [32 x i8] c"==============================\0A\00"
@.str.6 = [17 x i8] c"%a-%x-%H:%M:%S%n\00"
@.str.8 = [2 x i8] c"-\00"
@.str.10 = [4 x i8] c"\0At=\00"
@.str.11 = [1 x i8] zeroinitializer
@.str.12 = [2 x i8] c"~\00"
@.str.13 = [7 x i8] c"\0A%s\0A\0A\0A\00"
@.str.14 = [31 x i8] c"==============================\00"
@.str.15 = [53 x i8] c"Go ahead and type your note. Ctrl+d will end input.\0A\00"
@EOF = global i32 0
@.str.16 = [5 x i8] c"\0A%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [81 x i8]
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %15
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %6
%12 = load i8*, i8** %7
%13 = tail call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %20
15: ; preds = %2
%16 = icmp eq i32 %0, 1
br i1 %16, label %17, label %20
17: ; preds = %15, %11, %6
%18 = load i8*, i8** %1
%19 = tail call i32 @printUsage(i8* %18)
br label %111
20: ; preds = %11, %15
%21 = tail call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load i32*, i32** @stderr
%25 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32*, i32** @stdout
br label %29
27: ; preds = %20
%28 = tail call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %29
29: ; preds = %27, %23
%30 = phi i32* [ %26, %23 ], [ %28, %27 ]
%31 = bitcast i32* %3 to i8*
%32 = tail call i32 @time(i32* null)
store i32 %32, i32* %3
%33 = call %struct.tm* @localtime(i32* %3)
%34 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%35 = call i64 @fwrite(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i64 31, i64 1, i32* %30)
%36 = call i32 @strftime(i8* %34, i32 81, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), %struct.tm* %33)
%37 = call i32 @fputs(i8* %34, i32* %30)
br i1 %5, label %38, label %87
38: ; preds = %29
%39 = getelementptr inbounds i8*, i8** %1, i64 1
%40 = load i8*, i8** %39
%41 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %87, label %43
43: ; preds = %38
%44 = load i8*, i8** %39
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, 0
br i1 %46, label %57, label %47
47: ; preds = %43, %47
%48 = phi i64 [ %51, %47 ], [ 0, %43 ]
%49 = phi i8 [ %55, %47 ], [ %45, %43 ]
%50 = sext i8 %49 to i32
%51 = add nuw i64 %48, 1
%52 = call i32 @fputc(i32 %50, i32* %30)
%53 = load i8*, i8** %39
%54 = getelementptr inbounds i8, i8* %53, i64 %51
%55 = load i8, i8* %54
%56 = icmp eq i8 %55, 0
br i1 %56, label %57, label %47
57: ; preds = %47, %43
%58 = icmp sgt i32 %0, 2
br i1 %58, label %59, label %84
59: ; preds = %57
%60 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i64 3, i64 1, i32* %30)
%61 = zext i32 %0 to i64
br label %62
62: ; preds = %59, %81
%63 = phi i64 [ 2, %59 ], [ %82, %81 ]
%64 = icmp eq i64 %63, 2
%65 = select i1 %64, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0)
%66 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* %65)
%67 = getelementptr inbounds i8*, i8** %1, i64 %63
%68 = load i8*, i8** %67
%69 = load i8, i8* %68
%70 = icmp eq i8 %69, 0
br i1 %70, label %81, label %71
71: ; preds = %62, %71
%72 = phi i64 [ %75, %71 ], [ 0, %62 ]
%73 = phi i8 [ %79, %71 ], [ %69, %62 ]
%74 = sext i8 %73 to i32
%75 = add nuw i64 %72, 1
%76 = call i32 @fputc(i32 %74, i32* %30)
%77 = load i8*, i8** %67
%78 = getelementptr inbounds i8, i8* %77, i64 %75
%79 = load i8, i8* %78
%80 = icmp eq i8 %79, 0
br i1 %80, label %81, label %71
81: ; preds = %71, %62
%82 = add nuw nsw i64 %63, 1
%83 = icmp eq i64 %82, %61
br i1 %83, label %84, label %62
84: ; preds = %81, %57
%85 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0))
%86 = call i32 @fclose(i32* %30)
br label %110
87: ; preds = %38, %29
%88 = getelementptr inbounds i8*, i8** %1, i64 1
%89 = load i8*, i8** %88
%90 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* %89)
%91 = icmp eq i64 %90, 0
br i1 %91, label %92, label %107
92: ; preds = %87
%93 = load i32*, i32** @stderr
%94 = call i64 @fwrite(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.15, i64 0, i64 0), i64 52, i64 1, i32* %93)
%95 = call i32 (...) @getchar()
%96 = load i32, i32* @EOF
%97 = icmp eq i32 %95, %96
br i1 %97, label %104, label %98
98: ; preds = %92, %98
%99 = phi i32 [ %101, %98 ], [ %95, %92 ]
%100 = call i32 @fputc(i32 %99, i32* %30)
%101 = call i32 (...) @getchar()
%102 = load i32, i32* @EOF
%103 = icmp eq i32 %101, %102
br i1 %103, label %104, label %98
104: ; preds = %98, %92
%105 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0))
%106 = call i32 @fclose(i32* %30)
br label %110
107: ; preds = %87
%108 = load i8*, i8** %1
%109 = call i32 @printUsage(i8* %108)
br label %110
110: ; preds = %104, %107, %84
br label %111
111: ; preds = %110, %17
ret i32 0
}