void rebuilddata(src, uflds, flds, deflt, dst) char *src, *uflds, *flds, *deflt,
    *dst;
{
  char fldval[257], tmp[61];
  int i, j;
  dst[0] = 0;
  for (j = 2; getfield(j, flds, fldval, 60, '|') != 0; j++) {
    if (fldval[0] == 0)
      break;
    for (i = 1; getfield(i, uflds, tmp, 60, '|') != 0; i++)
      if (tmp[0] == 0 || strcmp(fldval, tmp) == 0)
        break;
    if (tmp[0]) {
      getfield(i, src, fldval, 256, '|');
      strcat(dst, fldval);
    } else
      strcat(dst, deflt);
    strcat(dst, "|");
  }
}


x86 assembly (clang, -O0):
<rebuilddata>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x2,-0x178(%rbp)
mov    -0x178(%rbp),%edi
mov    -0x18(%rbp),%rsi
lea    -0x130(%rbp),%rdx
mov    $0x3c,%ecx
mov    $0x7c,%r8d
mov    $0x0,%al
call   1030 <getfield@plt>
cmp    $0x0,%eax
je     1297 <rebuilddata+0x167>
movsbl -0x130(%rbp),%eax
cmp    $0x0,%eax
jne    11a1 <rebuilddata+0x71>
jmp    1297 <rebuilddata+0x167>
movl   $0x1,-0x174(%rbp)
mov    -0x174(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x170(%rbp),%rdx
mov    $0x3c,%ecx
mov    $0x7c,%r8d
mov    $0x0,%al
call   1030 <getfield@plt>
cmp    $0x0,%eax
je     1221 <rebuilddata+0xf1>
movsbl -0x170(%rbp),%eax
cmp    $0x0,%eax
je     1203 <rebuilddata+0xd3>
lea    -0x130(%rbp),%rdi
lea    -0x170(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1208 <rebuilddata+0xd8>
jmp    1221 <rebuilddata+0xf1>
jmp    120d <rebuilddata+0xdd>
mov    -0x174(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x174(%rbp)
jmp    11ab <rebuilddata+0x7b>
cmpb   $0x0,-0x170(%rbp)
je     1266 <rebuilddata+0x136>
mov    -0x174(%rbp),%edi
mov    -0x8(%rbp),%rsi
lea    -0x130(%rbp),%rdx
mov    $0x100,%ecx
mov    $0x7c,%r8d
mov    $0x0,%al
call   1030 <getfield@plt>
mov    -0x28(%rbp),%rdi
lea    -0x130(%rbp),%rsi
call   1050 <strcat@plt>
jmp    1273 <rebuilddata+0x143>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x28(%rbp),%rdi
lea    0xd82(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x178(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x178(%rbp)
jmp    1160 <rebuilddata+0x30>
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rebuilddata>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x168,%rsp
mov    %r8,%r12
mov    %rcx,0x8(%rsp)
mov    %rdx,%rax
mov    %rsi,%rbx
mov    %rdi,0x10(%rsp)
movb   $0x0,(%r8)
lea    0x60(%rsp),%rdx
mov    $0x2,%edi
mov    %rax,0x18(%rsp)
mov    %rax,%rsi
mov    $0x3c,%ecx
mov    $0x7c,%r8d
xor    %eax,%eax
call   1030 <getfield@plt>
test   %eax,%eax
je     12a5 <rebuilddata+0x165>
cmpb   $0x0,0x60(%rsp)
je     12a5 <rebuilddata+0x165>
mov    $0x2,%ebp
lea    0x20(%rsp),%r14
lea    0x60(%rsp),%r13
xchg   %ax,%ax
mov    $0x1,%r15d
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    $0x3c,%ecx
mov    $0x7c,%r8d
xor    %eax,%eax
call   1030 <getfield@plt>
mov    0x20(%rsp),%dl
test   %dl,%dl
sete   %cl
test   %eax,%eax
je     1230 <rebuilddata+0xf0>
test   %dl,%dl
je     1230 <rebuilddata+0xf0>
mov    $0x1,%r15d
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1240 <rebuilddata+0x100>
add    $0x1,%r15d
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    $0x3c,%ecx
mov    $0x7c,%r8d
xor    %eax,%eax
call   1030 <getfield@plt>
movzbl 0x20(%rsp),%edx
test   %dl,%dl
sete   %cl
test   %eax,%eax
je     1230 <rebuilddata+0xf0>
test   %dl,%dl
jne    11f0 <rebuilddata+0xb0>
test   %cl,%cl
je     1240 <rebuilddata+0x100>
mov    %r12,%rdi
mov    0x8(%rsp),%rsi
jmp    1263 <rebuilddata+0x123>
xchg   %ax,%ax
mov    %r15d,%edi
mov    0x10(%rsp),%rsi
mov    %r13,%rdx
mov    $0x100,%ecx
mov    $0x7c,%r8d
xor    %eax,%eax
call   1030 <getfield@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1060 <strcat@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
movw   $0x7c,(%r12,%rax,1)
add    $0x1,%ebp
mov    %ebp,%edi
mov    0x18(%rsp),%rsi
mov    %r13,%rdx
mov    $0x3c,%ecx
mov    $0x7c,%r8d
xor    %eax,%eax
call   1030 <getfield@plt>
test   %eax,%eax
je     12a5 <rebuilddata+0x165>
cmpb   $0x0,0x60(%rsp)
jne    11b0 <rebuilddata+0x70>
add    $0x168,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"|\00"
define void @rebuilddata(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [257 x i8]
%12 = alloca [61 x i8]
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%15 = load i8*, i8** %10
%16 = getelementptr inbounds i8, i8* %15, i64 0
store i8 0, i8* %16
store i32 2, i32* %14
br label %17
17: ; preds = %70, %5
%18 = load i32, i32* %14
%19 = load i8*, i8** %8
%20 = getelementptr inbounds [257 x i8], [257 x i8]* %11, i64 0, i64 0
%21 = call i32 (i32, i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @getfield to i32 (i32, i8*, i8*, i32, i32, ...)*)(i32 %18, i8* %19, i8* %20, i32 60, i32 124)
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %73
23: ; preds = %17
%24 = getelementptr inbounds [257 x i8], [257 x i8]* %11, i64 0, i64 0
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23
br label %73
29: ; preds = %23
store i32 1, i32* %13
br label %30
30: ; preds = %48, %29
%31 = load i32, i32* %13
%32 = load i8*, i8** %7
%33 = getelementptr inbounds [61 x i8], [61 x i8]* %12, i64 0, i64 0
%34 = call i32 (i32, i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @getfield to i32 (i32, i8*, i8*, i32, i32, ...)*)(i32 %31, i8* %32, i8* %33, i32 60, i32 124)
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %51
36: ; preds = %30
%37 = getelementptr inbounds [61 x i8], [61 x i8]* %12, i64 0, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 0
br i1 %40, label %46, label %41
41: ; preds = %36
%42 = getelementptr inbounds [257 x i8], [257 x i8]* %11, i64 0, i64 0
%43 = getelementptr inbounds [61 x i8], [61 x i8]* %12, i64 0, i64 0
%44 = call i32 @strcmp(i8* %42, i8* %43)
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %41, %36
br label %51
47: ; preds = %41
br label %48
48: ; preds = %47
%49 = load i32, i32* %13
%50 = add nsw i32 %49, 1
store i32 %50, i32* %13
br label %30
51: ; preds = %46, %30
%52 = getelementptr inbounds [61 x i8], [61 x i8]* %12, i64 0, i64 0
%53 = load i8, i8* %52
%54 = icmp ne i8 %53, 0
br i1 %54, label %55, label %63
55: ; preds = %51
%56 = load i32, i32* %13
%57 = load i8*, i8** %6
%58 = getelementptr inbounds [257 x i8], [257 x i8]* %11, i64 0, i64 0
%59 = call i32 (i32, i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @getfield to i32 (i32, i8*, i8*, i32, i32, ...)*)(i32 %56, i8* %57, i8* %58, i32 256, i32 124)
%60 = load i8*, i8** %10
%61 = getelementptr inbounds [257 x i8], [257 x i8]* %11, i64 0, i64 0
%62 = call i8* @strcat(i8* %60, i8* %61)
br label %67
63: ; preds = %51
%64 = load i8*, i8** %10
%65 = load i8*, i8** %9
%66 = call i8* @strcat(i8* %64, i8* %65)
br label %67
67: ; preds = %63, %55
%68 = load i8*, i8** %10
%69 = call i8* @strcat(i8* %68, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %70
70: ; preds = %67
%71 = load i32, i32* %14
%72 = add nsw i32 %71, 1
store i32 %72, i32* %14
br label %17
73: ; preds = %28, %17
ret void
}

LLVM IR (-O2):
define void @rebuilddata(i8* %0, i8* %1, i8* %2, i8* nocapture %3, i8* %4) {
%6 = alloca [257 x i8]
%7 = alloca [61 x i8]
%8 = getelementptr inbounds [257 x i8], [257 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [61 x i8], [61 x i8]* %7, i64 0, i64 0
store i8 0, i8* %4
%10 = call i32 (i32, i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @getfield to i32 (i32, i8*, i8*, i32, i32, ...)*)(i32 2, i8* %2, i8* %8, i32 60, i32 124)
%11 = icmp eq i32 %10, 0
%12 = load i8, i8* %8
%13 = icmp eq i8 %12, 0
%14 = select i1 %11, i1 true, i1 %13
br i1 %14, label %52, label %15
15: ; preds = %5, %42
%16 = phi i32 [ %46, %42 ], [ 2, %5 ]
%17 = call i32 (i32, i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @getfield to i32 (i32, i8*, i8*, i32, i32, ...)*)(i32 1, i8* %1, i8* %9, i32 60, i32 124)
%18 = icmp eq i32 %17, 0
%19 = load i8, i8* %9
%20 = icmp eq i8 %19, 0
%21 = select i1 %18, i1 true, i1 %20
br i1 %21, label %33, label %22
22: ; preds = %15, %26
%23 = phi i32 [ %27, %26 ], [ 1, %15 ]
%24 = call i32 @strcmp(i8* %8, i8* %9)
%25 = icmp eq i32 %24, 0
br i1 %25, label %36, label %26
26: ; preds = %22
%27 = add nuw nsw i32 %23, 1
%28 = call i32 (i32, i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @getfield to i32 (i32, i8*, i8*, i32, i32, ...)*)(i32 %27, i8* %1, i8* %9, i32 60, i32 124)
%29 = icmp eq i32 %28, 0
%30 = load i8, i8* %9
%31 = icmp eq i8 %30, 0
%32 = select i1 %29, i1 true, i1 %31
br i1 %32, label %33, label %22
33: ; preds = %26, %15
%34 = phi i32 [ 1, %15 ], [ %27, %26 ]
%35 = phi i1 [ %20, %15 ], [ %31, %26 ]
br i1 %35, label %40, label %36
36: ; preds = %22, %33
%37 = phi i32 [ %34, %33 ], [ %23, %22 ]
%38 = call i32 (i32, i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @getfield to i32 (i32, i8*, i8*, i32, i32, ...)*)(i32 %37, i8* %0, i8* %8, i32 256, i32 124)
%39 = call i8* @strcat(i8* %4, i8* %8)
br label %42
40: ; preds = %33
%41 = call i8* @strcat(i8* %4, i8* dereferenceable(1) %3)
br label %42
42: ; preds = %40, %36
%43 = call i64 @strlen(i8* %4)
%44 = getelementptr i8, i8* %4, i64 %43
%45 = bitcast i8* %44 to i16*
store i16 124, i16* %45
%46 = add nuw nsw i32 %16, 1
%47 = call i32 (i32, i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @getfield to i32 (i32, i8*, i8*, i32, i32, ...)*)(i32 %46, i8* %2, i8* %8, i32 60, i32 124)
%48 = icmp eq i32 %47, 0
%49 = load i8, i8* %8
%50 = icmp eq i8 %49, 0
%51 = select i1 %48, i1 true, i1 %50
br i1 %51, label %52, label %15
52: ; preds = %42, %5
ret void
}