#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 */
char *getenv(char *);
int /*<<< orphan*/ output(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  char *COMPLETION_FILE = getenv("TODO_COMPLETION_FILE");
  if (NULL == COMPLETION_FILE) {
    COMPLETION_FILE = "/etc/todo-completions";
  }
  if (1 == argc) {
    output(COMPLETION_FILE);
  } else {
    printf("Unknown option: %s\n", argv[1]);
    usage();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    117d <main+0x3d>
lea    0xe9c(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
jne    1199 <main+0x59>
mov    -0x18(%rbp),%rdi
call   1040 <output@plt>
jmp    11b4 <main+0x74>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe83(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <usage@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xeb1(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x1,%ebp
jne    116e <main+0x2e>
test   %rax,%rax
lea    0xeb2(%rip),%rdi
cmovne %rax,%rdi
call   1040 <output@plt>
jmp    1185 <main+0x45>
mov    0x8(%rbx),%rsi
lea    0xeb2(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <usage@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"TODO_COMPLETION_FILE\00"
@.str.1 = [22 x i8] c"/etc/todo-completions\00"
@.str.2 = [20 x i8] c"Unknown option: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i8* @getenv(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %6
%8 = load i8*, i8** %6
%9 = icmp eq i8* null, %8
br i1 %9, label %10, label %11
10: ; preds = %2
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8** %6
br label %11
11: ; preds = %10, %2
%12 = load i32, i32* %4
%13 = icmp eq i32 1, %12
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i8*, i8** %6
%16 = call i32 @output(i8* %15)
br label %23
17: ; preds = %11
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = call i32 (...) @usage()
br label %23
23: ; preds = %17, %14
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"TODO_COMPLETION_FILE\00"
@.str.1 = [22 x i8] c"/etc/todo-completions\00"
@.str.2 = [20 x i8] c"Unknown option: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %0, 1
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = icmp eq i8* %3, null
%7 = select i1 %6, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %3
%8 = tail call i32 @output(i8* %7)
br label %14
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = tail call i32 (...) @usage()
br label %14
14: ; preds = %9, %5
ret i32 0
}