#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*/ args;

/* Variables and functions */
char *getvar(char *);
int spawn(int, char **);
int main(int argc, char *argv[]) {
  char *bbs = getvar("notesfiles");
  if (bbs == NULL)
    bbs = "*";
  char *args[] = {"/fat-dragon/bin/notes", bbs, NULL};
  return (spawn((sizeof(args) / sizeof((args)[0])) - 1, args));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <getvar@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    115c <main+0x3c>
lea    0xeb3(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x30(%rbp),%rsi
mov    $0x2,%edi
call   1040 <spawn@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
call   1030 <getvar@plt>
test   %rax,%rax
lea    0xed1(%rip),%rcx
cmovne %rax,%rcx
lea    0xec8(%rip),%rax
mov    %rax,(%rsp)
mov    %rcx,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    %rsp,%rsi
mov    $0x2,%edi
call   1040 <spawn@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"notesfiles\00"
@.str.1 = [2 x i8] c"*\00"
@.str.2 = [22 x i8] c"/fat-dragon/bin/notes\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [3 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i8* @getvar(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %2
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %6
br label %12
12: ; preds = %11, %2
%13 = getelementptr inbounds [3 x i8*], [3 x i8*]* %7, i64 0, i64 0
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8** %13
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %6
store i8* %15, i8** %14
%16 = getelementptr inbounds i8*, i8** %14, i64 1
store i8* null, i8** %16
%17 = getelementptr inbounds [3 x i8*], [3 x i8*]* %7, i64 0, i64 0
%18 = call i32 @spawn(i32 2, i8** %17)
ret i32 %18
}

LLVM IR (-O2):
@.str = [11 x i8] c"notesfiles\00"
@.str.1 = [2 x i8] c"*\00"
@.str.2 = [22 x i8] c"/fat-dragon/bin/notes\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x i8*]
%4 = tail call i8* @getvar(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
%6 = select i1 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %4
%7 = bitcast [3 x i8*]* %3 to i8*
%8 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 1
store i8* %6, i8** %9
%10 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 2
store i8* null, i8** %10
%11 = call i32 @spawn(i32 2, i8** %8)
ret i32 %11
}