int mgetstr(hstring, mkey, keyword, lstr, str) const char *hstring;
const char *mkey;
const char *keyword;
const int lstr;
char *str;
{
  char *mstring;
  mstring = malloc(2000);
  if (hgetm(hstring, mkey, 2000, mstring)) {
    if (igets(mstring, keyword, lstr, str)) {
      free(mstring);
      return (1);
    } else {
      free(mstring);
      return (0);
    }
  } else {
    free(mstring);
    return (0);
  }
}


x86 assembly (clang, -O0):
<mgetstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
mov    $0x7d0,%edi
call   1050 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x38(%rbp),%rcx
mov    $0x7d0,%edx
mov    $0x0,%al
call   1040 <hgetm@plt>
cmp    $0x0,%eax
je     11d3 <mgetstr+0x93>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    $0x0,%al
call   1060 <igets@plt>
cmp    $0x0,%eax
je     11be <mgetstr+0x7e>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e3 <mgetstr+0xa3>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e3 <mgetstr+0xa3>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mgetstr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,(%rsp)
mov    %ecx,%r15d
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%r14
mov    $0x7d0,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0x7d0,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <hgetm@plt>
test   %eax,%eax
je     119f <mgetstr+0x5f>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    (%rsp),%rcx
xor    %eax,%eax
call   1060 <igets@plt>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mgetstr(i8* %0, i8* %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
%13 = call i8* @malloc(i64 2000)
store i8* %13, i8** %12
%14 = load i8*, i8** %7
%15 = load i8*, i8** %8
%16 = load i8*, i8** %12
%17 = call i32 (i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @hgetm to i32 (i8*, i8*, i32, i8*, ...)*)(i8* %14, i8* %15, i32 2000, i8* %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %5
%20 = load i8*, i8** %12
%21 = load i8*, i8** %9
%22 = load i32, i32* %10
%23 = load i8*, i8** %11
%24 = call i32 (i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @igets to i32 (i8*, i8*, i32, i8*, ...)*)(i8* %20, i8* %21, i32 %22, i8* %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = load i8*, i8** %12
store i32 1, i32* %6
br label %32
28: ; preds = %19
%29 = load i8*, i8** %12
store i32 0, i32* %6
br label %32
30: ; preds = %5
%31 = load i8*, i8** %12
store i32 0, i32* %6
br label %32
32: ; preds = %30, %28, %26
%33 = load i32, i32* %6
ret i32 %33
}

LLVM IR (-O2):
define i32 @mgetstr(i8* %0, i8* %1, i8* %2, i32 %3, i8* %4) {
%6 = tail call dereferenceable_or_null(2000) i8* @malloc(i64 2000)
%7 = tail call i32 (i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @hgetm to i32 (i8*, i8*, i32, i8*, ...)*)(i8* %0, i8* %1, i32 2000, i8* %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %5
%10 = tail call i32 (i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @igets to i32 (i8*, i8*, i32, i8*, ...)*)(i8* %6, i8* %2, i32 %3, i8* %4)
%11 = icmp ne i32 %10, 0
tail call void @free(i8* %6)
%12 = zext i1 %11 to i32
br label %14
13: ; preds = %5
tail call void @free(i8* %6)
br label %14
14: ; preds = %9, %13
%15 = phi i32 [ 0, %13 ], [ %12, %9 ]
ret i32 %15
}