void find_external_mon(imon_start, imon_stop) char *imon_start, *imon_stop;
{
  char *start, *stop;
  imon_start[0] = (char)0;
  imon_stop[0] = (char)0;
  start = (char *)getenv("IMON_START");
  if (start) {
    strcpy(imon_start, start);
  }
  stop = (char *)getenv("IMON_STOP");
  if (stop) {
    strcpy(imon_stop, stop);
  }
  return;
}


x86 assembly (clang, -O0):
<find_external_mon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <getenv@plt>
cltq
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     116a <find_external_mon+0x4a>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <getenv@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1196 <find_external_mon+0x76>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_external_mon>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movb   $0x0,(%rdi)
movb   $0x0,(%rsi)
lea    0xec9(%rip),%rdi
xor    %eax,%eax
call   1030 <getenv@plt>
test   %eax,%eax
je     114d <find_external_mon+0x2d>
movslq %eax,%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
call   1030 <getenv@plt>
test   %eax,%eax
je     1171 <find_external_mon+0x51>
movslq %eax,%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <strcpy@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"IMON_START\00"
@.str.1 = [10 x i8] c"IMON_STOP\00"
define void @find_external_mon(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i64 0
store i8 0, i8* %8
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i64 0
store i8 0, i8* %10
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @getenv to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %5
%14 = load i8*, i8** %5
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load i8*, i8** %3
%18 = load i8*, i8** %5
%19 = call i8* @strcpy(i8* %17, i8* %18)
br label %20
20: ; preds = %16, %2
%21 = call i32 (i8*, ...) bitcast (i32 (...)* @getenv to i32 (i8*, ...)*)(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %6
%24 = load i8*, i8** %6
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %30
26: ; preds = %20
%27 = load i8*, i8** %4
%28 = load i8*, i8** %6
%29 = call i8* @strcpy(i8* %27, i8* %28)
br label %30
30: ; preds = %26, %20
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"IMON_START\00"
@.str.1 = [10 x i8] c"IMON_STOP\00"
define void @find_external_mon(i8* %0, i8* %1) {
store i8 0, i8* %0
store i8 0, i8* %1
%3 = tail call i32 (i8*, ...) bitcast (i32 (...)* @getenv to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = sext i32 %3 to i64
%7 = inttoptr i64 %6 to i8*
%8 = tail call i8* @strcpy(i8* %0, i8* %7)
br label %9
9: ; preds = %5, %2
%10 = tail call i32 (i8*, ...) bitcast (i32 (...)* @getenv to i32 (i8*, ...)*)(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = sext i32 %10 to i64
%14 = inttoptr i64 %13 to i8*
%15 = tail call i8* @strcpy(i8* %1, i8* %14)
br label %16
16: ; preds = %12, %9
ret void
}