void gereplace(line, msg, maxllen) int line;
char **msg;
int maxllen;
{
  char *x;
  int i;
  if ((i = gnum("Replace line: ", line, 1, msg)) == 0)
    return;
  x = malloc(maxllen + 1);
  puts("Replace:");
  puts(msg[i - 1]);
  puts("With:");
  readdefault("", x, maxllen, "");
  free(msg[i - 1]);
  msg[i - 1] = x;
}


x86 assembly (clang, -O0):
<gereplace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rcx
lea    0xe90(%rip),%rdi
mov    $0x1,%edx
mov    $0x0,%al
call   1070 <gnum@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jne    118d <gereplace+0x3d>
jmp    1216 <gereplace+0xc6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1050 <puts@plt>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x0,%al
call   1050 <puts@plt>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1050 <puts@plt>
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe2d(%rip),%rcx
mov    %rcx,%rdi
mov    $0x0,%al
call   1040 <readdefault@plt>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gereplace>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %edi,%esi
lea    0xe9a(%rip),%rdi
mov    $0x1,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1070 <gnum@plt>
test   %eax,%eax
je     11db <gereplace+0x8b>
mov    %eax,%ebp
lea    0x1(%r14),%eax
movslq %eax,%rdi
call   1060 <malloc@plt>
mov    %rax,%r15
lea    0xe7e(%rip),%rdi
xor    %eax,%eax
call   1050 <puts@plt>
movslq %ebp,%rbp
mov    -0x8(%rbx,%rbp,8),%rdi
xor    %eax,%eax
call   1050 <puts@plt>
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1050 <puts@plt>
lea    0xe52(%rip),%rcx
mov    %rcx,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <readdefault@plt>
mov    -0x8(%rbx,%rbp,8),%rdi
call   1030 <free@plt>
mov    %r15,-0x8(%rbx,%rbp,8)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Replace line: \00"
@.str.1 = [9 x i8] c"Replace:\00"
@.str.2 = [6 x i8] c"With:\00"
@.str.3 = [1 x i8] zeroinitializer
define void @gereplace(i32 %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 (i8*, i32, i32, i8**, ...) bitcast (i32 (...)* @gnum to i32 (i8*, i32, i32, i8**, ...)*)(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %9, i32 1, i8** %10)
store i32 %11, i32* %8
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %3
br label %43
14: ; preds = %3
%15 = load i32, i32* %6
%16 = add nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = call i8* @malloc(i64 %17)
store i8* %18, i8** %7
%19 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%20 = load i8**, i8*** %5
%21 = load i32, i32* %8
%22 = sub nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %20, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* %25)
%27 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%28 = load i8*, i8** %7
%29 = load i32, i32* %6
%30 = call i32 (i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @readdefault to i32 (i8*, i8*, i32, i8*, ...)*)(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %28, i32 %29, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%31 = load i8**, i8*** %5
%32 = load i32, i32* %8
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %31, i64 %34
%36 = load i8*, i8** %35
%37 = load i8*, i8** %7
%38 = load i8**, i8*** %5
%39 = load i32, i32* %8
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %38, i64 %41
store i8* %37, i8** %42
br label %43
43: ; preds = %14, %13
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"Replace line: \00"
@.str.1 = [9 x i8] c"Replace:\00"
@.str.2 = [6 x i8] c"With:\00"
@.str.3 = [1 x i8] zeroinitializer
define void @gereplace(i32 %0, i8** %1, i32 %2) {
%4 = tail call i32 (i8*, i32, i32, i8**, ...) bitcast (i32 (...)* @gnum to i32 (i8*, i32, i32, i8**, ...)*)(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %0, i32 1, i8** %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %3
%7 = add nsw i32 %2, 1
%8 = sext i32 %7 to i64
%9 = tail call i8* @malloc(i64 %8)
%10 = tail call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%11 = add nsw i32 %4, -1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* %14)
%16 = tail call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 (i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @readdefault to i32 (i8*, i8*, i32, i8*, ...)*)(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %9, i32 %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%18 = load i8*, i8** %13
tail call void @free(i8* %18)
store i8* %9, i8** %13
br label %19
19: ; preds = %3, %6
ret void
}